Sending information up to parent macro

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
dbish
Junior Coder
Posts: 49
Joined: Wed Jan 08, 2003 8:38 am

Sending information up to parent macro

Post by dbish » Mon Feb 17, 2003 7:46 pm

I am using Msched 5.10. I have a shell macro that calls another macro to do some porcessing. I pass it variables to be operated on. Works fine. I want to take a value from the called macro and pass it back up to the parent shell macro. The information pass seems to operate only down - not up.

I realize that 7.1 supports true subroutines - can this be done in 5.10?

Snippet of Shell Macro:
.
.
.
Let>CELL4=0
Macro>SpiderRun /CSVNUM=%T4% /CELL=%CELL4%
.

The SpiderRun (child) macro does some processing and changes the value of CELL. I want that info back in the parent.

Thanks

Dave

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon Feb 17, 2003 8:27 pm

Hi,

With that version the only workaround would be to store the value that you want passed back in an INI file, text file or in the Registry. I'd use a small INI file in your macro directory:

[macroname]
settingname=value

Then use EditIniFile in the called macro to save the value and ReadIniFile in the calling macro to read the value after it has called the macro.
MJT Net Support
[email protected]

dbish
Junior Coder
Posts: 49
Joined: Wed Jan 08, 2003 8:38 am

Another alternative

Post by dbish » Mon Feb 17, 2003 8:40 pm

So I am guessing an upgrade to 7.1 is a better fix. Are all my 5.10 scripts going to run without problem?

If so, how do I upgrade - download and pay upgrade fee pay first and get link with download file address?

Thanks

Dave

P.S. - your great product keeps going strong. I am glad it is working out!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon Feb 17, 2003 8:44 pm

Hi,

7.1 will let you create subroutines. However, you still can't return values from called macros with the Macro> command.

The only change is that you now have to specify the full filename in the Macro> command - you can't just specify a macro name.

Otherwise all your scripts will still run - everything else is backward compatible.

You can order the upgrade at http://www.mjtnet.com/sales.htm ($23.98 for the Standard version which now includes VBScript).

Just install over the top of your existing version selecting the minimal install option to keep your scripts and settings intact. Or install into a different directory if you want to keep the old version, and copy the scripts over.
MJT Net Support
[email protected]

Lumumba

Post by Lumumba » Mon Feb 17, 2003 9:46 pm

Regardless that you should upgrade (there's a bunch of reasons to do so !)- you could pass the variable "backwards" through the clipboard.

Parent script:
...
Macro>C:\Child Script.scp /CELL=%CELL4%


Child script:
PutClipboard>NewValueOfCELL


Parent script:
GetClipboard>CELL
...

dbish
Junior Coder
Posts: 49
Joined: Wed Jan 08, 2003 8:38 am

Post by dbish » Tue Feb 18, 2003 12:17 am

Reply to Lumumba - I like your idea - I'll have to think how I can use it in my app - may be just the ticket.

Reply to Marcus - Two things:
1) If I can't get the information up to the parent macro via the Macro command - Is there some other, better subroutine command which will work or am I still going to need to use one of the creative mechanisms such as clipboard or ini file?

2) Regarding upgrade to 7.1 standard - if someday down the road I need the compiler version will I be able to further upgrade for the cost difference?

Thanks to both of you

Dave

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Feb 18, 2003 12:28 am

1. Unless you want your "sub macros" to be able to be run independently then use subroutines and the Gosub command.

2. Yes, you can upgrade to the Pro version with compiler at any time.
MJT Net Support
[email protected]

dbish
Junior Coder
Posts: 49
Joined: Wed Jan 08, 2003 8:38 am

Gosub

Post by dbish » Tue Feb 18, 2003 12:47 am

I have not used Gosub - will that mechanism allow the information to flow through variables up to the parent as well as down to child?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Feb 18, 2003 1:20 am

Yes, subroutines are routines within the same macro so you can set a variable that the entire script can see. Subroutines can be branched to with Gosub and return to the point at which they were called.

See the Gosub help topic in the online help at http://www.mjtnet.com/support.htm

e.g.

Gosub>SubroutineA
Message>SubAReturnVal
etc

SRT>SubroutineA
..
..
Let>SubAReturnVal=Something
END>SubroutineA
MJT Net Support
[email protected]

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