Get the value of a specified variable in an open UJP


This function reads the value of a variable, but in addition allows a file to be kept open while reading multiple variables.  It operates in three modes:

Open File and Read Value

Inputs:  Parm1 = UJP pathname
         Parm2 = Name of variable (with NO @ or ` prefix)
         Parm3 = 0

Outputs: Parm2 = Value of requested variable

Returns: -1 = error opening or reading UJP or invalid variable name
         otherwise: handle for open UJP file

Read Value from Open File

Inputs:  Parm1 = (not used)
         Parm2 = Name of variable (with NO @ or ` prefix)
         Parm3 = Handle for open UJP file

Outputs: Parm2 = Value of requested variable

Returns: Handle passed in parm3

Close File

Inputs:  Parm1 = (not used)
         Parm2 = (empty buffer)
         Parm3 = Handle for open UJP file

Returns: 0

Before looking up a variable value, any $fs_template $var_def commands are converted to normal $var_def commands.  The use of $fs_template for $var_def commands is deprecated (but continues to be supported).

The variable name passed in Parm2 should not contain embedded blanks.

The value returned in Parm2 is the effective value of the variable, from the last definition of the variable in the file.  Absence of a definition for the variable is not an error and will result in an empty string in Parm2.  If the value selected from the $var_def command is a double-quoted string, the double-quotes will be stripped before the result is placed in Parm2.

Variables (for example @FFBASE) in the value are NOT expanded before the value is placed in Parm2.

The result placed in Parm2 will be truncated if necessary to a length of 255 (or MaxBuf - 1) bytes plus a terminating null byte.

Do not pass a literal string as parm2 because the parameter is also used to return the result.

This function is independent of the other Direct UJP functions.  The Close operation should be done in the same thread as the Open operation, and the DLL must not be unloaded and reloaded during the operations.  If you are unlucky, there is a small chance that you would not get an exception if you pass in a closed or junk handle, but bad things would then result.  Failure to close an open handle will result in a memory leak but the file will have been closed immediately after it was read.

Example:

Get several variables:

strcopy(parm1, "@FFJOBS\\00001234\\NO_JTYPE\\JOB12345678.UJP");

strcopy(parm2, "VARIABLE1");

if ((handle = JobDllEntry("GetFastVarValue", parm1, parm2, 0)) == INVALID_HANDLE_VALUE)

{ ... };

strcopy(value1, parm2);

__try {

strcopy(parm2, "VARIABLE2");

JobDllEntry("GetFastVarValue", parm1, parm2, handle)

strcopy(value2, parm2);

strcopy(parm2, "VARIABLE3");

JobDllEntry("GetFastVarValue", parm1, parm2, handle)

strcopy(value3, parm2); 

} __finally {

strcopy(parm2, "");

JobDllEntry("GetFastVarValue", parm1, parm2, handle)  // close

}