$LstFld
The $LstFld function returns to an image the field names (in alphabetical order) and the field descriptions of each field in a file. $LstFld requires a prepared image into which Model 204 can store the field description.
$LstFld works only for files (not groups).
Syntax
The format for the $LstFld function is:
%rc = $LstFld([FILE] filename [AT location],imagename,loopvar)
%rc | A numeric %variable to receive a return code. The return codes are:
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
filename | This required argument is the name of the file that contains the fields. A file synonym name can also be used.
If you specify a null argument for the file location (At phrase), Model 204 uses the reference context (at compile time) of the statement that calls the function. If filename is the name of a group, $LstFld assumes that the name passed is a file name, not a group name. | ||||||||||||
imagename | This required argument is the name of the image to which the information is returned. | ||||||||||||
loopvar | This required argument is the loop variable of the image. You must initialize the loop variable (as in the sample image shown with the $FDef function) before invoking $LstFld. The value returned in loopvar is used the next time $LstFld is invoked to retrieve subsequent field names.
Note: Changing any of the loop control information in the $LstFld loop variable after the image is initialized is not allowed; it might cause the run to snap. |
Locating the ZFIELD image
An image is required by the $LstFld function. The ZFIELD image, provided with the Model 204 installation, can give you complete field attribute information (as described in $FDef).
The size of the name field for the ZFIELD image is 255 bytes.
The location of ZFIELD for your site is shown below:
Operating system | Storage location of the ZFIELD image |
---|---|
z/OS | V7.5 and later: The distributed macro library Pre-V7.5: The distributed JCL library |
z/VM | On the 193 MAINT204 disk as an EXEC |
z/VSE | The JCL library |
Example
In this example, the procedure DFIELDS
displays the name and definition of each field in the file specified by %FILE
.
PROCEDURE DFIELDS BEGIN * * include ZFIELD IMAGE as defined for $FDef * * PRINT 'DFIELDS STARTS' %FILE = '??FILE' NP PREPARE ZFIELD %ZFIELD:BIN1 = 0 %ZFIELD:BIN2 = 0 %ZFIELD:BIN3 = 0 %ZFIELD:BIN4 = 0 %X = 0 REPEAT WHILE %X = 0 %X = $LSTFLD(%FILE,'ZFIELD',%ZFIELD:LOOPVAR) IF %X = 0 THEN PRINT %ZFIELD:NAME PRINT %ZFIELD:FDEF END IF END REPEAT PRINT '-- END OF FIELDS RC=' %X END END PROCEDURE