Code Question - Call Sub / Return Value

dcolligan

New member
Joined
Oct 3, 2010
Messages
10
Reaction score
1
Points
0
I read the Wiki and found <quote>Sub without defined parameters

Sub MySub
/if (${Defined[Param0]}) /goto :DoThis
.
execute this code when /call MySub is executed. Parameters are not necessary.
.
/return [value|${varname}]</quote>

to describe how to return a value from a sub routine, but it says that the calling code will begin execution on the following line.

How do I USE the returned value.

I've tried the following......

/declare ALLOWED bool Inner /call CheckRights(${SenderName})

....

/declare ALLOWED bool Inner False
/varset ALLOWED /call CheckRights(${SenderName})

....

/if (CheckRights(${SenderName}).NotEquals[TRUE]) {
/return
} else {
/ do what I want my macro to do
}
/return

Sub CheckRights(string Sender)
/If (${Sender.Equal[PASSWORD]}) {
/return TRUE
} else {
/beep
/return False
}


Basically, this routine checks to see if the person sending the tell to the macro is the right person, just in case someone accidentally triggers one of my events. So when this is running and I'm out of the room, it'll beep to alert me, and NOT respond with the event code.

No matter what, when I echo the ALLOWED variable it gives me NULL or errors out on the if statement.

Any and all help from the people that know more than I do, would be greatly appreciated.
 
You use ${Macro.Return}

Which is a string.

so it would be like, in the calling routine:
/call CheckRights(${SenderName})
/do whatever with ${Macro.Return}

in your sub, you would /return a value
 
Thanks

Thanks HTW, I'll give that a go when I get home from work this evening.

I'll repost with the results.