|
scanFolder
At 18:32 02.07.98 +0000, Kevin Dowd wrote:
>Hello,
>
>In my project the user gets to do a lot of frame recording/deleting.
>
>I'd like to be able to generate unique frame label names so that I can add
>them to a list and do my navigation from that list - go next and go previous
>won't suffice.
>
>So the only idea I've had so far is
>
>set the framelabel = string(ticks()) -- could use timer instead but in reality
>its the same thing
>
>
>Is there a better way generate unique names. In an ideal world framelabels
>would be chars and there would be an unlimited amount of them
>
>
Hi Kevin,
unlimited is a big thing, but the 2 handlers below garantee uniqueness.
AsciSalat(integer) returns a random string of x chars. The other function checks whether
the result is truly unique and continues until it is. I#m using the labellist here but if
you maintain a real list, checking against that list will speed up the process.
There are about 1,411670956534e+14 different strings with 10 chars. If you feel that is not
enough, just call asciSalat() with another parameter.
on asciSalat lang
set erg=""
repeat with rum=1 to lang
set teil=numToChar(random(26)+64)
set erg=erg & teil
end repeat
return erg
end
on uniqueLabel
set ok = FALSE
repeat while not ok
set unique = ascisalat(10)
set ok = not(the labellist contains (unique & RETURN))
end repeat
return unique
end
-- Welcome to Director --
-- "Now loading LINGO.INI 02.07.98 18:03 "
put uniquelabel()
-- "ZVQZJPXPKU"
-- "ZVLZKSYGLR"
-- "RPIGTYIERK"
|