$LstFld: Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 40: Line 40:
<li>imagename (required) is the name of the image where the information is to return.</li>
<li>imagename (required) is the name of the image where the information is to return.</li>
</li>
</li>
<li>loopvar (required) 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. </li>
<li>loopvar (required) 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. </li>
</li>
</li>
</ul>
</ul>
Line 46: Line 46:
<p>Like $LSTPROC, changing any of the loop control information in the $LSTFLD loop variable after the image is initialized is not allowed and might cause the run to snap.</p>
<p>Like $LSTPROC, changing any of the loop control information in the $LSTFLD loop variable after the image is initialized is not allowed and might cause the run to snap.</p>
<b>Locating the ZFIELD image</b>
<b>Locating the ZFIELD image</b>
<p>An image is required by the $Fdef and $LSTFLD functions. The ZFIELD image is provided with the <var class="product">Model&nbsp;204</var> installation. It can give you complete field attribute information; see the discussion on [[$Fdef#$Fdef|$Fdef]]. The size of the name field for the ZFIELD image is 255 bytes. The location of ZFIELD for your site is listed in this table:    </p>
<p>An image is required by the $FDef and $LSTFLD functions. The ZFIELD image is provided with the <var class="product">Model&nbsp;204</var> installation. It can give you complete field attribute information; see the discussion on [[$FDef#$FDef|$FDef]]. The size of the name field for the ZFIELD image is 255 bytes. The location of ZFIELD for your site is listed in this table:    </p>
<table>
<table>
<tr class="head">
<tr class="head">
Line 70: Line 70:
BEGIN
BEGIN
<b></b>*
<b></b>*
<b></b>* include ZFIELD IMAGE as defined for $Fdef     *
<b></b>* include ZFIELD IMAGE as defined for $FDef     *
<b></b>*
<b></b>*
PRINT 'DFIELDS STARTS'
PRINT 'DFIELDS STARTS'

Revision as of 13:39, 1 August 2014

The $LSTFLD function returns field names in alphabetical order and the field description for each field in a file into an image. $LSTFLD requires that you have an image prepared with which Model 204 can create the field description. $LSTFLD works only for files (not groups).

Syntax

The format for the $LSTFLD function is:

%variable = $LSTFLD([FILE] filename [AT location],imagename,loopvar)

where:

  • %variable is the %variable in which the return codes are stored. The return codes are:
  • Setting Meaning
    0 Success
    1 End of field list reached
    2 Requested file not available, or is not open, or is not initialized
    3 VTBL full or sort not available
    4 Error occurred during function processing
  • filename (required) is the name of the file that contains the fields. A file synonym name can also be used. If you do not enter a location, specifying a null argument, Model 204 uses the reference context (at compile time) of the statement which calls the function. When filename=groupname the $LSTFLD function assumes that the name passed is a file name, not a group name.
  • imagename (required) is the name of the image where the information is to return.
  • loopvar (required) 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

Like $LSTPROC, changing any of the loop control information in the $LSTFLD loop variable after the image is initialized is not allowed and might cause the run to snap.

Locating the ZFIELD image

An image is required by the $FDef and $LSTFLD functions. The ZFIELD image is provided with the Model 204 installation. It can give you complete field attribute information; see the discussion on $FDef. The size of the name field for the ZFIELD image is 255 bytes. The location of ZFIELD for your site is listed in this table:

Operating system Storage location of the ZFIELD image
z/OS The 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