Print Fields

From BR Wiki
(Redirected from PRINT FIELDS)
Jump to navigation Jump to search

The Print Fields (PR F)statement uses the capabilities of full screen processing to print information at any position on the screen or in a window using a variety of attributes.

1.) MAT grouping is now allowed in all full screen processing statements. This feature allows you to indicate that input or output should alternate between all MAT variables that are specified within parentheses in the I/O list. In the following code fragment, the A$ variable identifies the positions on the screen from which input values should be drawn. Business Rules! will assign the first input value to the first element of B$. However, because the B$ and C matrices are specified within parentheses, it will then assign the second input value to the first element of C. The third value will go to B$, the fourth to C, and so on until both matrices are fully assigned. The last input value will go to X$.

Without MAT grouping, the above line must be coded as follows in order to achieve the same results (this example assumes that B$ and C have each been dimensioned for five elements):

 00020 PRINT FIELDS A$:B$(1),C(1),B$(2),C(2),B$(3),C(3),B$(4),C(4),B$(5),C(5),X$

MAT grouping is a lot easier to code, executes faster, and most importantly, handles much larger arrays than are possible without using MAT grouping, as the resulting compiled line takes up less space in memory. The number of matrices that can be grouped together is 62, which in practical terms is no limit. All matrices in a group must have the same number of elements per matrix, or an error 0106 will result. Only MAT variables may be used in such groupings.

2.) Using an alpha character for field length in INPUT FIELDS or PRINT FIELDS will now produce an error. Previously the character as well as the attributes following it were being ignored. (This may affect your programs). Extraneous characters in attribute specifications will still be ignored.
3.) The FMT specification is now supported. However, because Business Rules does no formatting or Verifying of data that is output to the screen with FMT, FMT is equivalent to the C format spec on screen output.

Comments and Examples

PRINT FIELDS displays data anywhere on the screen except the status line. One field or several fields can be displayed with the PRINT FIELDS statement. PRINT FIELDS, INPUT FIELDS, RINPUT FIELDS, INPUT SELECT and RINPUT SELECT are all used for full screen processing. See the Category:Field Specifications section for information and examples common to all of these statements.

The following example prints a simple title "Enter Information Here:" to the main screen:

00010 PRINT FIELDS "2,28,C 25":"Enter Information Here:"

But usually, more than one line at a time needs to be printed, in which case, the specifications (before the colon) and the data (in quotes above) can be read into arrays and then handled in one print statement.

Continuing this example, to create a simple form on the screen, the PRINT FIELDS lines may look like this (corresponding INPUT FIELDS statements would allow the user to input the information requested, of course), where the array CLIENTFORM$ contains the format specifications, and the array CLIENTWORD$ contains the fields to be printed:

00030     dim Clientform$(6)*20, Clientwords$(6)*20, Answerform$(6)*30, Answers$(6)*30,ordered(3)
00040     data "5,3,C 20","6,3,C 20","7,3,C 20","8,3,C 10","8,36,C 10","9,3,C 10"
00050     read Mat Clientform$
00060     data "First Name: ","Last Name: ","Address: ","City: ","State: ","Zip Code: "
00070     read Mat Clientwords$
00080     data "5,20,C 30","6,20,C 30","7,20,C 30","8,20,C 15","8,43,C 2","9,20,C 7"
00090     read Mat Answerform$
00110     print fields Mat Clientform$: Mat Clientwords$
00120     input fields Mat Answerform$: Mat Answers$


PRINT [#<window number>,] FIELDS {Mat <array name>|<string expression>|"<field spec>[;...]"} : {|Mat <array name>}[,...] [<error condition> <line ref>][,...]

Supplemental Syntax ("field-spec" parameter)

See Field Specs for details on this supplemental syntax, including parameter descriptions.


1.) Output to the full screen (not a window).
2.) Interrupt the program if an error occurs and "ON error" is not active.
3.) Fraction length=0.
4.) Maximum DIM length.
5.) Use current attributes.


The "#wind-num" parameter represents the file number of a window which has already been opened by an OPEN window statement. When this parameter is used, Business Rules! inputs to and outputs from the window as if it were a separate screen: the first row and column of the window are considered row 1 and column 1.

"FIELDS" is a required keyword which signals that data is to be printed to specific fields on the screen. It must be followed by one of three possible parameters, each of which defines the fields to be used for input.

The "MAT string-array" parameter indicates that multiple field definitions are located in the specified string array. The array must contain all the same elements that are identified in the "field-spec" parameter.

The "string expression" parameter may also be used to define the input fields, but its value must also contain all the same elements that are identified in the "field-spec" parameter.

The "field-spec" parameter represents a separate syntax (see Field Specs) that identifies the following for each input field: row number; column number; format type, length and fraction length (if required) of the data to be input; and the monochrome and/or color attributes which are to be used for the field (control attributes are ignored).

See Format Specifications and File I/O for information about the format specifications which may be used with the PRINT FIELDS statement.

After the required colon, at least one "data-item" or "MAT array-name" is required. These two parameters represent the list of variables to be assigned values from the entered data. Multiple variables must be separated by commas.

PRINT FIELDS provides error processing with the optional "error-cond line-ref" parameter. See Error Conditions for more information.

Technical Considerations

1.) Relevant error conditions are: CONV, ERROR, EXIT, HELP, IOERR, and SOFLOW.
2.) Whereas control attributes are acted upon in INPUT FIELDS and RINPUT FIELDS statements, they are ignored if specified in PRINT FIELDS.
3.) When OPTION INVP is in effect, the normal printing of commas and periods is interchanged in PIC, N, NZ, L, G and GZ format specifications to produce European-style numbers.
4.) See Functions for information about CNT, which applies to errors in field definition arrays used in full screen processing.

See Also