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


Using createVarsForQuestions in the message window clearly shows that child 
objects are being created BUT they are not receiving the parameters.

So why is this?
Or am I looking at this through the wrong end of the telescope?

Thanks in advance
Neil


_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

[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