DOpus11: @IfExists, variables, and inverted commas

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:

  1. How do I test the existence of a path when the path is the value of a global variable?
  2. How should inverted commas be used in this situation?
    I am expecting that, as usual, I have missed something very obvious.
1 Like

My apologies — I clearly misjudged the appropriate level of detail. Here is my problem in shorthand.


I can't use the new @IfExists: to test the existence of a file when the filepath is given as a global DOpus variable. (I can do it, however, using an explicit filepath, an environment variable, a parameter, or an alias.)

Specifically, when Glob:TheFile has the value D:\A Directory\A File.txt (such a file exists), I cannot test the file's existence either with
@IfExists:$Glob:TheFile, or with @IfExists:{$Glob:TheFile}

  • Adding inverted commas in every conceivable way doesn't make it work.
  • I can't even test just for the existence of the directory D:\A Directory
  • I can't even do it when the spaces are removed from the filepath.

What obvious thing am I doing wrong?

I would use scripting for this. Things like @ifexists only make sense for doing very simple tasks.