I've become confused trying to combine the new @IfExists: conditional, the new DOpus variables, and inverted commas. To simplify the problem:
- I created a file with path "D:\A Directory\A File.txt" so that the path has spaces.
- I created ButtonA with command
@Set Glob!:TheFile="D:\A Directory\A File.txt"
where I copied the filepath using Shift+RightClick to avoid transcription errors. - I created ButtonB with the commands:
@IfExists:{$Glob:TheFile}
@Confirm:The file is reported to exist.|OK
@IfExists:Else
@Confirm:The file is reported not to exist.|OK
When I press ButtonA (checking using dlgstring that this has set the global variable properly) and then press ButtonB, the message says, "The file is reported not to exist."
The result is the same when line 1 of ButtonB is any of the four variants:
@IfExists:{$Glob:TheFile} or @IfExists:"{$Glob:TheFile}" or
@IfExists:$Glob:TheFile or @IfExists:"$Glob:TheFile"
The result is the same if I omit the inverted commas from the first line, so that it reads:
@Set Glob!:TheFile=D:\A Directory\A File.txt
and combine this with each of the four variants above.
As a check, I omitted ButtonA and the global variable entirely, and rewrote the second button without inverted commas as:
@IfExists:D:\A Directory\A File.txt
@Confirm:The file is reported to exist.|OK
@IfExists:Else
@Confirm:The file is reported not to exist.|OK
Now when I press ButtonB, the message finally says that the file exists!!!
When, however, inverted commas are used in line 1:
@IfExists:"D:\A Directory\A File.txt"
the message says that the file does not exist.
As a further check, I converted ButtonB to a user-defined command UserButtonB with parameter &ThePath&, by changing its first line to
@IfExists:&ThePath&
and called it with a button having the command
UserButtonB "D:\A Directory\A File.txt"
This works — the file is reported to exist (but not if &ThePath& is replace by "&ThePath&"). I can thus make @IfExists: accept a parameter, but not a global variable.
Two questions:
- How do I test the existence of a path when the path is the value of a global variable?
- How should inverted commas be used in this situation?
I am expecting that, as usual, I have missed something very obvious.