Depending on how you want to use the objects that you will be 
creating, you could create these objects and store the object 
references in a linear list.  It's not clear from your code what the 
second parameter you are trying to use is.  But that aside, you could 
create one global list:

global gMyObjects

Initialize it somewhere appropriate:

gMyObjects = []

Then as you create each object, you add the returned object reference 
to the global list:

repeat with r = 1 to numOfQuestionsCatA
    param2 = ???   -- whatever you want here

    -- Now create a new object, which returns an object reference
    oNewlyCreatedObjectRef = new(parentScriptName, r, param2)

    -- Now add that object reference to your global list
    append(gMyObjects, oNewlyCreatedObjecrRef)
end repeat


After doing this, you will have a linear list of object references. 
You can refer to any item in that list by pulling out an a specific 
element in the list.  For example, the reference to the third object 
in the list is:  gMyObjects[3].  If you want to call some method 
(handler) in your "TestParentScript" using, say, the fourth object, 
it would be like this:

gMyObjects[4].mSomeMethodName(anyParametersYouWantToPass)

If you wanted to run down the list of objects and call the same 
method for each:


repeat with oMyObject in gMyObjects
    oMyObject.mSomeMethodName(params ...)
end repeat

Good luck,

Irv

PS: The "global testNumber" in your parent script doesn't do 
anything.  What you really want is to output the value of the first 
parameter passed in, which is put in the local variable "a".  That 
will tell you the number of the object created.

PPS:  Unless you declare:  "property a" (and property b) at the top 
of your script, the value of both variables will be lost as soon as 
the new method exits since a and b are local variables, not property 
variables.

At 9:24 AM +0000 7/9/02, Neil Sandbach wrote:
>Can anyone give me some help please?
>
>What I want to do is to dynamicaly create a number of child objects 
>from a parent script, and assign each child object to a dynamically 
>created variable. The variable names and parameters passed to the 
>child object simply increment by one each time such as:
>
>myVariable1 = new(script "ParentScriptName", 1, X)
>myVariable2 = new(script "ParentScriptName", 2, X)
>myVariable3 = new(script "ParentScriptName", 3, X)
>etc.
>
>So I tried a test:
>
>
>
>on   createVarsForQuestions
>    numOfQuestionsCatA = 5 --initialise with total number of 
>questions in this category
>
>  repeat with r = 1 to numOfQuestionsCatA
>    global testNumber
>    testNumber = r
>    oQuestionNum = "varQuestionNum" & r --a string!
>    parentScriptName = "TestParentScript"
>    newScript = "=new(script" & parentScriptName & ", 1, 2)"
>    do(oQuestionNum & newScript)
>
>    put oQuestionNum
>    put "-----------"
>  end repeat
>end
>
>
>
>The parent script "TestParentScript" is:
>
>on new me, a, b
>  global testNumber
>  put "child number:"&&testNumber
>  put "parameter 1="
>  put a
>  put "parameter 2="
>  put b
>  return me
>end
>


-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/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