Subrountine String literals

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
srhamy
Newbie
Posts: 9
Joined: Sun Nov 26, 2006 12:38 am

Subrountine String literals

Post by srhamy » Mon Dec 26, 2016 7:50 pm

I was trying to write a subroutine that handles file initialization, and some default values for INI filename and path if not passed. Here's an excerpt showing my trouble.

Code: Select all

Let>Modules=a,b,c,d
Gosub>WriteINIFile,,Settings,modules,%modules%

SRT>WriteINIFile
Let>INIFile=%WriteINIFile_VAR_1%
Let>INISection=%WriteINIFile_VAR_2%
Let>INIEntryName=%WriteINIFile_VAR_3%
Let>INIValue=%WriteINIFile_VAR_4%
End>WriteINI
When observing the watchlist, the 3rd argument comes through as var content (a.b.c.d) not as literal (modules)
I am trying to avoid setting VAREXPLICIT=1 because I am new to MS, and don't want all examples/help files to be viewed in light of this functional change

I also wanted to avoid something like...

Code: Select all

Gosub>WriteINIFile,,Settings,{"modules"},%modules%
But wan't sure the there is a way since the subroutine argument variable are assigned behind the scenes.

Any thoughts??
Scott Rhamy

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

Re: Subrountine String literals

Post by JRL » Tue Dec 27, 2016 12:42 am

Does something like this work for you?

Code: Select all

Let>Modules=a,b,c,d
Gosub>WriteINIFile,,Settings,.modules,%modules%
SRT>WriteINIFile
Let>INIFile=%WriteINIFile_VAR_1%
Let>INISection=%WriteINIFile_VAR_2%
Let>INIEntryName=%WriteINIFile_VAR_3%
StringReplace>INIEntryName,.,,INIEntryName
Let>INIValue=%WriteINIFile_VAR_4%
End>WriteINIFile

srhamy
Newbie
Posts: 9
Joined: Sun Nov 26, 2006 12:38 am

Re: Subrountine String literals

Post by srhamy » Fri Jan 06, 2017 11:53 am

Thank you, and yes it does work.
Scott Rhamy

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