Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Logic in functions...

May
855
0
I found out in another thread that one could place logical statements (if, do while, etc.) into alias definitions, which I didn't know. I would assume, but possibly incorrectly, that one could not do that in function definitions except by executing a batch file via @ExecStr. Am I correct in that assumption?
 
I found out in another thread that one could place logical statements (if, do while, etc.) into alias definitions, which I didn't know. I would assume, but possibly incorrectly, that one could not do that in function definitions except by executing a batch file via @ExecStr. Am I correct in that assumption?

There is the @IF function. Be aware, though, that all of its arguments are evaluated -- regardless of whether the test condition is true or false.
 
Dan, here's an example of using @ExecStr with a DO loop.

Code:
function DoLogic=`%@execstr[SetLocal & Set C=0 & Do I=1 to %1 (Set C=%@inc[c]) & Echo C: %C I: %I & EndLocal]`
 
echo %@DoLogic[500]
C: 500 I: 501

-Scott
 
Scott, thank you for both giving me the answer and making me laugh. You effectively did a batch file, you just put it directly into the @ExecStr. Somehow it was in my mind that you could just execute external programs and batch files that way. And looking at the documentation (note Rex) there's not a clue that you can do that (although it certainly doesn't explicitly prohibit either).
 
The last example shows it can execute "*dir /a:-d /h /o:-d /f".

Looks like a typo in the first example. Should be "echo %@execstr[2,ver /r]".
 
Back
Top
[FOX] Ultimate Translator
Translate