Pass variables between scripts

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Giles.Buist
Newbie
Posts: 15
Joined: Wed Feb 15, 2006 2:25 pm
Location: London

Pass variables between scripts

Post by Giles.Buist » Tue Apr 18, 2006 4:37 pm

Hi All,

Could anyone suggest how I can launch script B from script A and use any values generated in script B in script A?

So Script A is like

"... Do some stuff..."
Macro>C:\ScriptB
"... Do some stuff involving ProductName..."

ScriptB is like

VBSTART
"...open a file and retrieve a value calling it ProductName..."
VBEND

Any ideas?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Apr 18, 2006 4:58 pm

Several methods could be used. You could write the info to memory using PutClipBoard> and read it back using GetClipBoard> or you could write the informatin to a file using WriteLn> then read it back using ReadLn>. But the cleanest method would be to use the variable designed for this situation. The "MACRO_RESULT" variable is described in the help section under the Macro> command. A sample script follows:

Let>file1=C:\~~macroresulttest~~.scp
IfFileExists>%file1%
DeleteFile>%file1%
EndIf

WriteLn>%file1%,wresult,Let>test1=The first value
WriteLn>%file1%,wresult,Let>test2=The second value
WriteLn>%file1%,wresult,Let>test3=The third value
WriteLn>%file1%,wresult,Let>MACRO_RESULT=%test1%;%test2%;%test3%

Macro>%file1%

DeleteFile>%file1%
Separate>MACRO_RESULT,;,var

MDL>var_1 = %var_1%%CRLF%var_2 = %var_2%%CRLF%var_3 = %var_3%Let>file1=C:\~~macroresulttest~~.scp
IfFileExists>%file1%
DeleteFile>%file1%
EndIf

WriteLn>%file1%,wresult,Let>test1=The first value
WriteLn>%file1%,wresult,Let>test2=The second value
WriteLn>%file1%,wresult,Let>test3=The third value
WriteLn>%file1%,wresult,Let>MACRO_RESULT=%test1%;%test2%;%test3%

Macro>%file1%

DeleteFile>%file1%
Separate>MACRO_RESULT,;,var

MDL>var_1 = %var_1%%CRLF%var_2 = %var_2%%CRLF%var_3 = %var_3%

Hope this is helpful,
Dick

Giles.Buist
Newbie
Posts: 15
Joined: Wed Feb 15, 2006 2:25 pm
Location: London

Post by Giles.Buist » Tue Apr 18, 2006 5:04 pm

Cheers,

I'd found and used the MACRO_RESULT bit, it's the Separate function I hadn't found, need to pass more than one variable, hopefully I'll be able to now.

Thanks

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Apr 18, 2006 5:11 pm

I suspected as much. That was why I supplied the sample showing a method of passing multiple values in the one MACRO_RESULT variable.

Later,
Dick

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts