@ifexists and variables

I'd like to be able to set a variable and then use it in an @ifexists test. When the following sample code is executed the /argsmsgbox confirms that the @ifexists statement is being constructed correctly, however it never fires.

@set tgt=c:\windows
dopusrt /argsmsgbox @ifexists:{$tgt}
@ifexists:{$tgt}
Help 
@ifexists:c:\windows
Help ABOUT

No doubt I can construct a script if this "easy way" is not supported.

Regards, AB

For the record, I mentioned this in my second posting in the following thread:
[url]DOpus11: @IfExists, variables, and inverted commas]
(and also in my over-detailed first posting there). The @IfExists test seems to work with an explicit filepath, an environment variable, a parameter, or an alias, so the fact that it doesn't work with a previously-set DOpus global variable does seem rather an anomaly.

Other postings suggest that even if the anomaly were sorted out, the DOpus variable would have to be set in an earlier button, because (and I may be way off track here) @IfExists is expanded as the first step in executing a button containing it. The @IfExists test is an extremely useful addition in DOpus11 (particularly when restoring a configuration to other home network computers that are slightly different), but it would be helpful if the Help screens, as they evolve, eventually give more clarification of these details.

Thanks. You prompted my next test which was to establish if it works with a parameter on a user command. It does, and that is a perfectly viable way of achieving my objective.

Regards, AB

. . . which is precisely how I solved my problem — it's easy to pass the path as a parameter to a user-defined command. I still reckon, however, that the problem of @IfExists not working with a DOpus variable needs sorting out as DOpus11 develops.

We recommend you use scripting if you want to combine things like variables and branching logic. That's what it's for! :slight_smile:

We'd rather put time into improving the new scripting support than in making the command system more like a scripting language, since the command system will never be as good as the real languages you can use already.

This is also ineffective. :upside_down_face:

@output:{sourcepath}
@ifexists:{sourcepath}
dopusrt /argsmsgbox Hello

I don't think {...} codes work with things like @ifexists, as they're parsed later on.

But that line doesn't really make sense in most situations, either:

If the sourcepath doesn't exist, the lister would usually go up a level automatically (unless you ran the button really fast after deleting the folder, or it's on a network server with broken change notification, or similar).

OTOH, if you do really need to do that for some reason, scripting can do it without issues.

Ok, maybe the evaluator has a solution, so I'm posting it. . .