Can the argument to RETURN be a function expansion?

Apr 13, 2010
310
7
61
The Hague
Could it be that the function @AppStatus (that expands to a number) is not allowed there?

Code:
function AppStatus=`%@MAX[%?,%_?,%_syserr,%nAppExit]`
function ValidValue=`%@IF[defined %1 .AND. %@AppStatus[] == 0,0,1]`

Please advice.
 
May 20, 2008
11,415
99
Syracuse, NY, USA
Your example seems to work.
Code:
v:\> function AppStatus=`%@MAX[%?,%_?,%_syserr,%nAppExit]`

v:\> function ValidValue=`%@IF[defined %1 .AND. %@AppStatus[] == 0,0,1]`

v:\> echo %@AppStatus[]
0

v:\> echo %@validvalue[path]
0

v:\> echo %@validvalue[pat]
1

v:\> seterror 5

v:\> echo %@AppStatus[]
5

v:\> echo %@validvalue[path]
1

v:\> echo %@validvalue[pat]
1
 
May 20, 2008
11,415
99
Syracuse, NY, USA
I don't know what that had to do with the subject of your post, but, yes, RETURN's argument can be a function expansion.
Code:
v:\> type return.btm
echo %@exec[gosub foo]
quit

:foo
return %@eval[1+1]

v:\> return.btm
2
 
Apr 13, 2010
310
7
61
The Hague
Thanks for your reply, Vince.
I am getting stubborn errors and am grasping for reasons.
Well not errors, but errand behavior. The errors occur when I use

return %@ValidValue[...]

which expands @AppStatus[] internally - and disappear when I simply

return %@IF[defined <envar>,1,0]

This happens not in one location of the code but in several locations and independently.

The debugger doesn't help much either in scenario's like this.
So, in a bout of despair . . . I began to wonder if perhaps that particular combination of function expansions could somehow be against a rule I overlooked or forgot about. I didn't and don't see any problem with it either, but - it appears at least - that we're both wrong.

Never mind, I'm working around it with the simpler variant, so at least I'm not stuck. I just can't code what I want to code.
 
Similar threads
Thread starter Title Forum Replies Date
D Keystroke to copy previous argument Support 3
C Replace 1st argument on command line Support 4
Fross TabComplete Argument Issue Support 1
jbanaszczyk @Full and unquoted argument Support 4
rps Fixed Using last argument variable ! Support 5
Jay Sage TCMD 14 Ignores Argument Support 6
A How to? Remove last argument on command line Support 4
D Help says @fileage accepts u argument Support 3
M Just an argument-passing "strangeness" that I didn't expect... Support 19
M A probably stupid question about .btm file argument parsing... Support 6
vefatica Is EOF an implied RETURN? Support 3
Joe Caverly Why does TCCRT return VIEW as an internal command? Support 6
A Inconsistent return code for TCC scripts Support 4
J How to? Speedup of gosub/return Support 8
vefatica Can a subroutine return a 64-bit integer? Support 4
S Return of FTP copy bug in 16.02.48 Support 12
M How to? Get the return code from an external program... Support 8
A WAD function return values with parentheses prevent evaluation of additional functions Support 31
Stefano Piccardi How to? return values from @python Support 2
A How to? return to completion mask after auto-completion Support 14
ehab aboudaya How to? 2 GUI questions and return HWND using TakeCommandIPC Support 3
M echo %@index[1234,.,-1] return -21 in new version Support 3
Jay Sage Function to Return Selected Text Support 2
rconn Do NOT request return receipt! Support 7
rconn No return receipt!! Support 10
vefatica Documentation Function parameters Support 0
Jay Sage Documentation Function @DRIVE Missing in Help Lists Support 0
Joe Caverly How to? Get name of current LIBRARY function? Support 4
x13 WeekNum function? Support 3
Joe Caverly No blank line in TEXT...ENDTEXT in a LIBRARY function Support 8
cgunhouse Ctrl-C from within a library function Support 6
C email[string] function Support 10
R FUNCTION to count NUMBER of files matching a pattern and specific length/not length Support 4
Dick Johnson Using the @instr function Support 5
vefatica '}' in a library function? Support 3
J Trouble with @full[] function. Support 3
Fross Quick Function Question Support 17
vefatica Quoting @Function parameters? Support 0
Joe Caverly Debugging a LIBRARY function Support 10
Steve Pitts Documentation @CAPI function summary Support 0
x13 %x$ in function Support 3
thorntonpg @eval function, interesting results any explanation? Support 3
x13 Function to get interface user-defined name? Support 10
vefatica Fixed Help @FUNCTION, missing paragraph Support 8
Mordachai Variable followed by function constantly failing... Support 5
nickles Call a complex function Support 13
M Fixed Cannot use the "Browse..." function in "Find files/text" dialogbox Support 2
R Function #IDOW returns only 2 characters Support 10
T scrput `` in alias or function Support 2
S International characters - TYPE vs %@LINE function Support 5

Similar threads