4.1.1 Types of Variables

    There are several different types of variables which can be included in RES-Reach template or "NBT" files; some of these have group names which can be used to resolve name ambiguities.


    Variable Type

    Group Identifier

    Variable Names

    When Applicable

    Form input variables

    _FRM

    specified in HTML for the form used to call this NBT file. Imagemap and input type image variables will have 2 variables, with the postfix ".x" and ".y", to transmit which pixel was clicked. There is no distinction made between GET and POST queries.

    When sent by referring form. Visible throughout the NBT file. For multiple-valued variables, iterate through the values using

    <RECORD Name=VarName> Imagemap and input type image variables will have 2 variables, with the postfix ".x" and ".y", to transmit which pixel was clicked. There is no distinction made between GET and POST queries.

    Current query

    _DAT

    TotalRows, DBQ, RO, EX

    Within <DATA></DATA> , except action queries. The value of "TotalRows" is very unreliable (often "-1") except after the </RECORD> tag. "DBQ" contains the name of the database. RO is "1" if the mode is READONLY, "0" otherwise. "EX" is "1" if the mode is EXCLUSIVE, "0" otherwise.

    Current record

    _REC

    [Alias.Field Name], RecNo

    Within <RECORD></RECORD>

    Run-time variables

    _RUN

    ErrNo, ErrString, LIBS, WAIT

    ErrNo and ErrString refer to the last error; LIBS must be set before calling a library function; and WAIT indicates the number of milliseconds to try an operation on a global variable or to wait for the results of an external function or program call.

    HTTP, CGI, and Server Environment Variables

    _ENV

    REQUEST_METHOD, SERVER_NAME, SERVER_PORT, REMOTE_ADDR, REMOTE_USER, CONTENT_TYPE, CONTENT_LENGTH, HTTP_USER_AGENT, REFERER, etc. Also most environment variable values in the RES-Reach server's environment.

    Set by the Web server

    Program functions

    _SYS

    Date, Time, Version, Unknown, ThreadCount

    The Unknown program variable has the value of the "Unknown" profile variable if it it exists. Otherwise, it has the value "???". ThreadCount contains the number of template files being executed by the RES-Reach service.

    Always.

    Profile settings

    _INI

    for example, CALL_NBT, GET_NBT, DB, UNKNOWN, or any other variable can be defined

    Set by [VARIABLES] section of NETBASE.INI file.

    Private variables

    _PRI

    Any variable can be defined for use within a single RES-Reach template.

    Created using the <SET> tag, these variables are assigned values in the NBT file and disappear when the template interpretation is finished.

    Public variables

    not applicable

    Any variable can be defined for use by several different RES-Reach templates.

    Created using the <SET> tag, these variables last as long as the RES-Reach programmer specifies. They are accessible by any template file which knows of their existence.

    File name with variable replacement

    not applicable

    @filename

    Special pseudo-variables beginning with "@" indicate file names. The contents of the file, found in the NBT Root directory, are inserted into the stream and variable replacement is performed on the contents of the file. For example,

    {@MALL/RES/CATALG01.ENG}

    specifies that the file named "CATALG01.ENG" should be found in the "MALL/RES" sub-directory off the RES-Reach root and included in the RES-Reach template being processed.

    Always.

    File name without variable replacement

    not applicable

    @@filename

    Special pseudo-variables beginning with "@@" also indicate file names. The contents of the file, found in the NBT Root directory, are inserted into the stream but variable replacement is NOT performed on the contents of the file. For example,

    {@MALL/RES/CATALG01.ENG}

    specifies that the file named "CATALG01.ENG" should be found in the "MALL/RES" sub-directory off the RES-Reach root and included in the RES-Reach template being processed.

    Always.

    It is possible for variables from a form input field, a profile setting, and an HTTP variable to have the same name. The precedence is as follows:

    1. private, temporary variables
    2. if not found, HTTP variables
    3. if not found, Form variables
    4. if blank or not found, Profile variables
    5. if blank or not found, Unknown, (The default is "???", but this can be changed in netbase.ini.)

    In other words, when a group prefix is NOT supplied, the search order of groups during variable replacement is _PRI, _ENV, _FRM, and _INI. _DAT, _REC and _SYS groups rank with the _ENV group. To circumvent the variable precedence rules when looking for the value of a variable, prefix its name with the group identifier.

    4.1.1.1 Notes on Variables

    1. If a file variable does not exist, the value of the Unknown profile variable is substituted.
    2. When using the syntax {[Alias.Field]}, if the alias does not match a valid one, the current recordset is used. If the syntax {[Alias.Table.Field]} is used and if the alias does not match a valid one, the "Table" name is ignored, and the current recordset is used. If a field does not exist within a DATA SQL query or it is referenced outside a RECORD tag, then it is assigned the value of the Unknown profile variable. If the Unknown profile variable does not exist, the string "???" is assigned.
    3. Some HTTP environment variables are set to "(null)" or blank "" by the Web server when they are undefined.
    4. By accident or design, it is possible for the global program variable "Unknown" to acquire a value; for example, a user may actually pass it as a CGI variable. In this case, all error handling using the value of this profile variable will fail badly.