Welcome!

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

SignUp Now!

%@if[DEFINED

Feb
50
1
Being a bit naive I tried the following which did not work:

Code:
SET in_Directory=%@If[DEFINED 1,%[1],.]

I guess %1 qualifies as internal variable which always fails DEFINED so I guess I have to look for an alternative. I just wonder which might be the best alternative.

Martin
 
Being a bit naive I tried the following which did not work:

Code:
SET in_Directory=%@If[DEFINED 1,%[1],.]
I guess %1 qualifies as internal variable which always fails DEFINED so I guess I have to look for an alternative. I just wonder which might be the best alternative.

DEFINED is just for environment variables. You might instead do something like this:

Code:
set in_directory=%@if[%1. != .,%1,.]
 
Charles Dye wrote:

| Quote:
| Originally Posted by krischik
|| Being a bit naive I tried the following which did not work:
||
||
|| Code:
|| SET in_Directory=%@If[DEFINED 1,%[1],.]
|| I guess %1 qualifies as
|| internal variable which always fails DEFINED so I guess I have to
|| look for an alternative. I just wonder which might be the best
|| alternative.
||
| DEFINED is just for environment variables. You might instead do
| something like this:
|
|
| Code:
| set in_directory=%@if[%1. != .,%1,.]

Since %1 is always a parameter, whether to a batch file or to an alias,
if it is not present the parameter count %# is zero. I thus use this form:

SET in_Directory=%@If[%# GT 0,%1,.]

Note that this works only for the LAST (or ONLY) parameter of the batch
file/alias. Much more elaborate parsing is required if an earlier
parameter's presence is optional.

BTW, I would use something like @TRUENAME[.] or @FULL[.], rather than
just .; if there is a possibility that the path name includes special
characters, I'd use this:

SET in_Directory=%@quote[%@full[%@If[%# GT 0,%1,.]]]
--
HTH, Steve
 
Back
Top