On this Page

    _file.resolveName

    String substitution

    Syntax

    _file.resolveName(text)

    Parameters

    text - a text string with all manner of placeholders to be replaced. These include [fieldname] or [!autofield] placeholders, %x placeholders (see File Naming Conventions), and $X placeholders (see $X String Substitutions).

    Returned Value

    A new string with substitutions is done.

    Description

    This routine is a script equivalent of the [fieldname] and [!autofield] substitution available in normal text labels. See the Auto/Embedded Fields section for a list of available [!autofield] variables. If used in the context of Merge, i.e in the script in a Form, where there is a Document DOM available, _resolveName looks for substrings of the form [fieldname] and replaces them with the Field's value from the current document. This function uses the same substitution logic as the Merge embedded fields, including [!pagenum] etc. If the text between the left and right square brackets is not a known name the text and square brackets are left unchanged in the text string.

    Unlike _mergeEmbedded, in any context, e.g. Merge, RunScript, or Job Processing scripts, _file.resolveName will also do substitution of the % variables (typically date elements) that is done for output file names. See any PRT file.

    Further, any $X style variable will be substituted as well. Note that the string is presumed to be a file name, so replacement of characters that are invalid for file names is done. Also, backslashes are converted to forward slashes. By contrast, see _resolve.

    _file.resolveName is generically related to files and hence is a function of the _file object itself. It is not a function of an opened file instance, i.e. (not) fp._resolveName.

    CAUTION: _file.resolveName will create any paths that are referred to in the provided name template string. It does not create the file, but it does create the path. If you do not want that to happen, use _resolve.

    Example

    In RunScript one might use:

     myFileName = _file.resolveName("$T/CriticalStats_%U.txt");
     fp = _file.fopen(myFileName, "w");

    See Also

    Auto/Embedded Fields
    _auto
     _resolve
    _mergeEmbedded