On this Page

    $X String Substitutions

    Using a parameter file, it is possible to set up some shortcuts or abbreviations for commonly used command strings. Any statement of the form:

    $X = string  or
    $X string

    where X is any single uppercase letter, and string is any string of characters.

    Subsequently, anywhere that $X appears in a value string, it will be replaced by the value of its associated string.

    For example, consider the following two files:

    Paths.prm

    * Paths.prm
    * $U User directory
    $U $R/User
    * $F is the user's forms directory
    $F $U/Forms
    * $L directory for log files
    $L $U/Logs

    Test.prm

    @Paths.prm
    -logfile $L/%d_%m_%y_logfile.txt
    -form $F/DynamicForm.xatw
    -data $F/DynamicForm.xml

    When the command line Merge @Test.prm is executed, each occurrence of $L and $F in Test.prm will be replaced by the path values defined in Paths.prm.

    This is recursive. $R is C:/DocOrigin (usually set at install time), hence one can define $U relative to $R and $F relative to $U.

    Whenever you run a script within a DocOrigin program these $ values are also automatically defined in the JavaScript environment. So if you set

    $Z "this is my string"

    on the command line (or in a .prm file), then when you run a script, the JavaScript variable named $Z will be pre-defined with the value this is my string. E.g., as if you had hand-coded the following at the start of your JavaScript (.wjs) file:

    $Z = "this is my string"

    Note that RunScript scripting is not PHP. RunScript does NOT do text substitution in string literals. For example, $F is indeed, literally "$F" and not automatically "C:\DocOrigin\User\Forms". But since $F is defined as a JavaScript variable, you could say
    var myForm = $F + "/MyForm.xatw";

    Notice that one includes the directory separator character in the concatenation.

    Update: Having said all that, if a string such as "$F/MyForm.xatw" were passed to a DocOrigin script utility, to a file open operation, DocOrigin does now automatically replace the $F  with whatever path is defined for it. That applies to any $X variable. But this is for those special file opening use cases only. As said before, it is not replaced automatically as PHP does, at value assignment time, but rather it is replaced when and if used in a file open operation. We call this operation HardenPath.

    By the way, within DocOrigin scripting and parameter files, you can always use / as the directory separator. \ works as well but often one has to escape it as in \\. It's easier and more consistent to use /.


    See Also
    _resolve and _file.resolveName for ways to explicitly resolve references to $X-type variables, and more.