Hints, tips and tricks for newbies
Moderators: Dorian (MJT support), JRL
-
bernd001
- Newbie
- Posts: 2
- Joined: Sun Jul 22, 2007 9:39 am
Post
by bernd001 » Sun Jul 22, 2007 9:48 am
Hi!
Is it possible to pass an array into MACRO_RESULT?
I tried following:
MyScript.scp:
Code: Select all
Let>ReturnArray[0]=a
Let>ReturnArray[1]=b
Let>MACRO_RESULT=ReturnArray
Main.scp
Code: Select all
Macro>%SCRIPT_DIR%\MyScript.scp
Let>MyArray=%MACRO_RESULT%
Let>MyFirstValue=MyArray[0]
Mesage>MyFirstValue
But I don't get the expected value a in the message...
Can anybody help?
Thanks a lot,
Bernd
-
JRL
- Automation Wizard
- Posts: 3526
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Mon Jul 23, 2007 1:40 pm
I'm not a programmer so my understanding of programming terminology is sometimes way off.
My understanding is that a variable name followed by braces around a number is not an array. An array is a variable that contains multiple values. A variable name followed by sequential numbers is a method to store or access the array's individual elements.
So think of MACRO_RESULT as an array variable. Put all of the values you want to pass from script "A" into MACRO_RESULT. Then return MACRO_RESULT back into its original elements in Script "B"
Script A
Code: Select all
Let>MaxReturnArray=5
Let>ReturnArray[1]=a
Let>ReturnArray[2]=b
Let>ReturnArray[3]=c
Let>ReturnArray[4]=d
Let>ReturnArray[5]=e
Let>MACRO_RESULT=
Let>Counter=0
Repeat>Counter
Add>Counter,1
Let>Value=ReturnArray[%Counter%]
Concat>MACRO_RESULT,%Value%%CRLF%
Until>Counter,MaxReturnArray
Script B
Code: Select all
Macro>%SCRIPT_DIR%\Script_A.scp
Let>Counter=0
Separate>%MACRO_RESULT%,%CRLF%,MyArray
//Next line is needed since we added an extra %CRLF%
Sub>MyArray_Count,1
Repeat>Counter
Add>Counter,1
Let>MyValue=MyArray_%Counter%
MessageModal>My number %Counter% value = %MyValue%
Until>Counter,MyArray_Count
-
bernd001
- Newbie
- Posts: 2
- Joined: Sun Jul 22, 2007 9:39 am
Post
by bernd001 » Mon Jul 23, 2007 7:42 pm
Hi JRL,
Thanks a lot!
Actually, the solution is not as expected, but the workaround is working and that is what counts
Cheers,
Bernd