Advice for passing variables

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Advice for passing variables

Post by mightycpa » Fri Mar 12, 2021 8:21 pm

I have a new project that I'm almost finished with. I have three different compiled MS scripts that need to pass variables back and forth to each other. When I have a small number of variables, I'm ok. But in one case, the variable is an array of three text elements, one short, one 20 chars and the other up to 100 characters. Generally there will be between 10- 20 items in the array whenever that needs to get passed.

I'm considering writing the contents of the array to a text file, and then having the receiving program read the file to get the input and do its thing.

I just wanted to ask if someone has experience with this sort of thing, and if there is another approach I should consider.

Thanks in advance.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Advice for passing variables

Post by Grovkillen » Sat Mar 13, 2021 1:13 am

A text file is perfectly fine, I use the approach myself. But you could also pass data through a text field which the receiving script have as a dialog box with size 0, 0 and perhaps coordinates -9999, -9999 if you don't want them to be shown in the Windows GUI.
Let>ME=%Script%

Running: 15.0.24
version history

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Advice for passing variables

Post by mightycpa » Sat Mar 13, 2021 2:08 am

Thanks, I decided to go with the text file approach, one advantage that has is that there is a record of the values I'm passing, and that will help with debugging.

I appreciate your input.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Advice for passing variables

Post by mightycpa » Sun Mar 14, 2021 1:27 am

Grovkillen!

So I had some serious problems with passing data through files: viewtopic.php?f=2&t=10909

It forced me to think about this question a little more, and I realized that there is indeed one method I had not considered: DATABASE

It is just as easy to do an HTTP call as it is to ReadLn or to WriteLn, and a database will give me historical data in a way that files cannot! It also nullifies the difficulty I have had, described in the post up above.

Just wanted to feed back to you in case you ever have the same kind of difficulty.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Advice for passing variables

Post by Grovkillen » Sun Mar 14, 2021 5:06 am

Thanks for the feedback :)
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
PepsiHog
Automation Wizard
Posts: 511
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Advice for passing variables

Post by PepsiHog » Sun Mar 14, 2021 5:33 pm

@mightycpa,
It seems like you are doing more work than is needed. You can pass info between macros by using command line.

ExecuteFile>YourPath\YourFilename.exe,YourParameters(you can just place your strings here.)

Like %string1%;%string2%;

Then in the called exe, you would import the parameters like this-

Let>MyString=%Command_Line%

***Rest Of Program ***

All your data is now in MyString.

Good Luck,
PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2021) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Advice for passing variables

Post by mightycpa » Sun Mar 14, 2021 6:13 pm

Thanks PH, I thought about doing it that way, and normally I do.

This time, it was the size (> 100 chars) of each potential string that was giving me some pause, and while I know the command line can probably handle them, still, I had my doubts. Also I'm dealing with multiple iterations of strings, so that affects the potential size of the variable being passed, depending on how I loop through them. Do I pass all of the records over at once? Do I repeatedly call my three programs over and over for every record I need to pass? Or do I call each program once, and let each one retrieve and save all the records in each run, and then call the downstream program to iterate though each of them? The latter seemed much cleaner.

Not sure that I made that clear in my original post.

At first, I decided to go with a file, but I had weird troubles with that

(viewtopic.php?f=2&t=10909)

so now I've moved on to doing it via HTTP calls to database-connected webpages. The one advantage that has over both passing and reading/writing text files is that I can easily archive my results, and use them to detect problems, unanticipated string handling, etc.

You're right, it was a little more work, but it's not hard work and the result is very orderly, very auditable.

I appreciate the help you suggested as well as the code to do it.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

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