passing arrays to scripts in other objects
Posted: Mon Sep 29, 2008 11:14 pm
Hi
encouraged by the success of my previous posting I have here another question to ask. This is a question to which today I have spent a good couple of hours seeking an answer in the documentation and by trial and error.
The problem concerns passing an array over to a method in the script of an object other than that of the sender.
I have a Scrolling Field: resultsField with the following script:
I have two buttons: passArrayInternally and passArrayExternally.
The script of passArrayInternally is as follows
The code of this button works perfectly.
The array is passed and the messages to display each element are sent to the resultsField successfully.
Here is the script of passArrayExternally
This executes ok as is shown by the fact that the string "hi from resultsField" is printed but the array is not printed.
I have found documentation that states that messages to custom methods use a different syntax than those to system methods but not documentation that illustrates how this is to be done for messages to scripts of other objects.
Is it possible that as in the case of calling functions in the scripts of other objects (e.g. http://forums.runrev.com/phpBB2/viewtopic.php?t=2128)
so here too it is necessary to employ a different approach?
Thanks
Julius
encouraged by the success of my previous posting I have here another question to ask. This is a question to which today I have spent a good couple of hours seeking an answer in the documentation and by trial and error.
The problem concerns passing an array over to a method in the script of an object other than that of the sender.
I have a Scrolling Field: resultsField with the following script:
Code: Select all
on printAry pAry
printValue "hi from resultsField"
repeat for each element tElem in pAry
printValue tElem
end repeat
end printAry
on printValue pValue
get the number of lines in me
put pValue into line it + 1 of me
end printValue
The script of passArrayInternally is as follows
Code: Select all
on mouseUp
repeat with tvar = 0 to 5
put tvar into tAry[tvar]
end repeat
localPrintAry tAry
end mouseUp
on localPrintAry pAry
repeat for each element tElem in pAry
send printValue && tElem to card field "resultsField"
end repeat
end localPrintAry
The array is passed and the messages to display each element are sent to the resultsField successfully.
Here is the script of passArrayExternally
Code: Select all
on mouseUp
repeat with tvar = 0 to 5
put tvar into tAry[tvar]
end repeat
send printAry && tAry to card field "resultsField"
end mouseUp
I have found documentation that states that messages to custom methods use a different syntax than those to system methods but not documentation that illustrates how this is to be done for messages to scripts of other objects.
Is it possible that as in the case of calling functions in the scripts of other objects (e.g. http://forums.runrev.com/phpBB2/viewtopic.php?t=2128)
so here too it is necessary to employ a different approach?
Thanks
Julius