Good one, Daniel. I hadn't come across that algorithm before. Using your
example, here's the mod to my previously submitted function:
on GetRandomAnswerList
set tText = member("Answers").text
set tMax = the number of lines in tText
set tAnswerList = []
repeat with i = tMax down to 1
tAnswerList.addAt(random(tAnswerList.count + 1), tText.line[i])
end repeat
return tAnswerList
end
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Christopher Watson
Sr. Software Engineer
Lightspan, Inc.
http://www.lightspan.com/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-----Original Message-----
From: Daniel Plaenitz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 13, 2001 1:55 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: <lingo-l> Random display of questions
At 12:37 13.02.2001 -0800, R Kumar wrote:
>Hi
>
>I have a field which has 4 possible answers to a
>question. How do i randomly change the order in which
>the answers
>appear, when the user enters the screen. Or is it
>advisable to do it with a list.
>
>Any help would be appreciated.
>
>ravi
ravi,
as a rule I always use fields for display only and keep any
computations in
variables for speed reasons. And what you need here can be
done easily with
a list:
on sortListAtRandom dL
-- creates a linear list with the
-- input list's items in random position
if dL.ilk <> #list then return
LTemp=[]
repeat with index = dL.count down to 1
LTemp.addat( random(LTemp.count + 1),dL[index] )
end repeat
return LTemp
end
from the messWin:
-- Welcome to Director --
dL = [1,2,3,4,5,6,7,8,9]
put sortListatRandom(dL)
-- [6, 3, 7, 2, 9, 1, 4, 8, 5]
-- [7, 2, 8, 1, 4, 6, 5, 3, 9]
best regards
daniel plaenitz
[To remove yourself from this list, or to change to digest
mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to
the list,
email [EMAIL PROTECTED] (Problems, email
[EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.
Thanks!]
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]