Constant variables between Sub Routines

Forum to discuss MLScript plugin that enables VBScript and JavaScript scripting within MLServer3.
bjdraw
Senior Member
Senior Member
Posts: 246
Joined: Thu May 24, 2007 4:55 pm
Contact:

Constant variables between Sub Routines

Postby bjdraw » Wed May 21, 2008 5:54 pm

I'm working on a script that has several sub routines, that all share constant variables.

I've tried a few different ways, but I can't seem to get the multiple subs to work without specifying the variables in each sub routine.

I've tried declaring the variables before the sub, but it doesn't work. I've also tried using the const keyword, with and without the public option, but neither worked.

Is there any way to specify constant variables that would be valid in every sub in one script?
Ben Drawbaugh
How good can it be, if it isn't HD?

bigDvette
Expert
Expert
Posts: 718
Joined: Thu Oct 12, 2006 12:19 pm
Contact:

Postby bigDvette » Wed May 21, 2008 7:38 pm

I assume you are calling subroutines in a script and I think MLScript treats them as independent units much like if you had built functions in an excel workbook and called them from a form.

YOu may try the Global or Public keyword (can't remember which) or you can call a single sub with a parameter that tells it which function you really want and set the variables in the controlling routine. That would also allow you to simply have 1 authentication message section for all the ISY commands you are trying to create :-)

bigDvette
Expert
Expert
Posts: 718
Joined: Thu Oct 12, 2006 12:19 pm
Contact:

Postby bigDvette » Wed May 21, 2008 7:43 pm

for clarity create a script with the following subs

declare variables

sub InitateISYAction (usr, pass, serverIP, device, command)

set variables
initiate authentication message

if command is DON
call donISYAction (serverIP, device, command)
if commandis DOF
call dofISYAction (serverIP, device, command)

...


end if

end sub

sub donISYAction (a,b,c)


...


Return to “MLScript”

Who is online

Users browsing this forum: No registered users and 1 guest