I want to assign a variable within a subroutine and make it available to the main scrip.
I've not found variable scope rules so far.
Am I missing something simple?
Thanks,
Carl
Variable Scope
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
All variables have global scope. Variables created in subroutines will be available in the rest of the script and vice versa.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Is there anything special required within the Subroutine to expose the variable? In the code below, the PW variable is correctly populated; but, I'm not seeing it in the script where I was calling the subroutine. I saw a mention of variable format under the SRT documentation; but, haven't found an example.
//Enter Showcase PW
SRT>GetPW
Label>ReEnterPW
Let>Input_Browse=0
Let>INPUT_PASSWORD=1
Input>PW1,Enter Your Showcase Password,
Input>PW2,Re-enter Your Showcase Password,
//Verify Credentials
If>%PW1%=%PW2%,,
Let>PW=%PW1%
Else
MessageModal>The passwords entered are NOT the same.%CRLF%%CRLF%Please try again.
GoTo>ReEnterPW
EndIf
End>GetPW
Thanks,
Carl
//Enter Showcase PW
SRT>GetPW
Label>ReEnterPW
Let>Input_Browse=0
Let>INPUT_PASSWORD=1
Input>PW1,Enter Your Showcase Password,
Input>PW2,Re-enter Your Showcase Password,
//Verify Credentials
If>%PW1%=%PW2%,,
Let>PW=%PW1%
Else
MessageModal>The passwords entered are NOT the same.%CRLF%%CRLF%Please try again.
GoTo>ReEnterPW
EndIf
End>GetPW
Thanks,
Carl
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Nothing special. Your code works fine:
Code: Select all
GoSub>GetPW
MessageModal>PW
//Enter Showcase PW
SRT>GetPW
Label>ReEnterPW
Let>Input_Browse=0
Let>INPUT_PASSWORD=1
Input>PW1,Enter Your Showcase Password,
Input>PW2,Re-enter Your Showcase Password,
//Verify Credentials
If>%PW1%=%PW2%,,
Let>PW=%PW1%
Else
MessageModal>The passwords entered are NOT the same.%CRLF%%CRLF%Please try again.
GoTo>ReEnterPW
EndIf
End>GetPW
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?