Nice 1 - Cheers Irv - that is a much neater solution.

Paul

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Irv Kalb
Sent: Wednesday, October 04, 2000 12:53 AM
To: [EMAIL PROTECTED]
Subject: Re: <lingo-l> Creating a variable name - troubles!


At 12:04 AM +0100 10/4/00, Paul Steven wrote:
>Hi there
>
>Facing another deadline and can't seem to do something I am sure I have
done
>many times before.
>
>I want to create a variable name on the fly


No, you don't.

People often think that they want to create variables on the fly,
until they start to really understand the power of lists.  Instead of
having four separate variables, pRow1_Correct_Vehicle, pRow2, etc.,
create one list:  pRow_Correct_Vehicle.  Initialize it to an empty
list then add your items to it in your repeat loop.  Something like
this (completely untested):

property pRow_Correct_Vehicle


   pRow_Correct_Vehicle = []
   repeat with vIndex=1 to 4

     -- Randomly Choose A Vehicle From The Remaining Vehicles

     vNumber_Of_Vehicles_Left=count(pList_Of_Vehicles)

     vRandom_Index=random(vNumber_Of_Vehicles_Left)

     vVehicle=getAt (pList_Of_Vehicles, vRandom_Index)

     -- Just add it to your list here
     append(pRow_Correct_Vehicle, vVehicle)

     -- Remove used vehicle from list of available vehicles

     deleteAt pList_Of_Vehicles, vRandom_Index
   end repeat

Then whereever you were using (for example) pRow1_Correct_Vehicle,
use pRow_Correct_Vehicle[1], etc.

Good luck,

Irv
--
Lingo / Director / Shockwave development for all occasions.

        (Over two millions lines of Lingo code served!)

[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!]

Reply via email to