Using: Difference between revisions
(Redirected page to Print Using) |
(→Syntax) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
# | See also [[Print Using]]. | ||
'''USING''' is used with form statements to signify how something is to be read, written, or printed. | |||
Instead of repeating all the form information in the statement, it is kept in a form statement and can be accessed by any line anywhere in the program. For example: | |||
00290 read #1, using RECFORM: Mat Answers$,Shipping$,Mat Ordered eof DONEREADING | |||
00300 RECFORM: form C 30,C 30,C 30,C 15,C 2,C 7,C 1,N 1,N 1,N 1 | |||
00450 write #1, using recform: mat answers$,shipping$,mat ordered | |||
And in a print statement: | |||
03500 print #255, using infoform: "REG", A(62),B(22),B(7),"FICA",B(3),"YTD" | |||
03510 infoform: form pos 18, c 3,x 8,pic(z,zz#.##),x 6,pic(zz#.##),x 8,pic(zz,zz#.##),x 7,c 4,x 25,pic(z,zz#.##),x 12,c 3,skip 1 | |||
===Syntax=== | |||
<[[statement]]> [#{<window number>|<file number>},] USING {<[[line ref]]>|<[[string expression]]>} : [{[[MAT]] <[[array name]]>|<data item>}][,...] [<[[error condition]]> <[[line ref]]>][,...] | |||
[[Image:Using.png|800px]] | |||
===Parameters=== | |||
USING can be used with the following statements: [[Read file|READ]],[[Print using|PRINT]],[[WRITE]],[[REWRITE]], and [[REREAD]]. | |||
The optional "[[file-num]]" or "[[wind-num]]" parameters identify the output location for the printed information and must match the specification used in the [[OPEN]] statement for the same file, device or window. Two exceptions are that [[PRINT 255|PRINT #255]] and [[Parent=none|PRINT #0]] can be used without an explicit OPEN statement. PRINT #255 outputs to the system printer, and PRINT #0 outputs to the screen. | |||
The "USING" keyword specifies the "[[line-ref]]" of a FORM statement or a "[[string expression]]" containing a [[FORM]] statement. USING is responsible for the format of the output or input. | |||
The optional "data-item" and "MAT array name" parameters identify the items to be output. Multiple specifications must be separated by commas. | |||
See [[Error Conditions]] for the optional error condition parameter. | |||
===Defaults=== | |||
:1.) Output to the screen. | |||
:2.) Null data item. | |||
:3.) Interrupt the program if an error occurs and "ON error" is not active. | |||
===Technical Considerations=== | |||
:1.) Relevant error conditions are: [[CONV]], [[EOF]], [[ERROR]], [[EXIT]], [[IOERR]], [[PAGEOFLOW]], and [[SOFLOW]]. | |||
:2.) Standard printer output (PRINT #255) can be redirected using the [[RUN]] command. RUN >file-ref creates a new file or overwrites an existing file with printer output. RUN >>file-ref creates a new file or appends to an existing display file. RUN >CON: sends printer output to the screen; this option can save paper and speed up debugging and program development. | |||
:3.) The position after the USING keyword may contain a string expression (constant or variable) which must begin with the keyword "FORM " followed by a list of format specifications. This method is relatively slow because the string must be compiled on each execution. | |||
:4.) The PAGEOFLOW error condition can be used for page breaks. After executing a PRINT statement, Business Rules checks to see if the line count is greater than or equal to the value specified for PAGEOFLOW in the OPEN statement (the default is 60). If the test indicates it is time for a page break, control is transferred to the PAGEOFLOW line-ref after the statement has printed. A PRINT #file-num: NEWPAGE statement must be specified to reset the PAGEOFLOW counter to zero; otherwise, the next PRINT would also generate a page overflow condition. | |||
:5.) See [[Functions]] and [[Screen I/O]] for information about HEX$, which can be used in PRINT statements to change to special print modes (condensed, line spacing, etc.) and to set the display attributes on the screen. | |||
:See [[BRConfig.sys]] for information about using [[PRINTER]] specifications to create a printer translation interface; PRINT statements using the [[HEX$]] function will probably require some such translation. | |||
:6.) Array elements are output in row order (i.e., all elements for a row are processed before moving to the next row). | |||
:7.) When [[OPTION]] INVP is in effect, the normal printing of commas and periods is interchanged in PIC, N, NZ, G and GZ format specifications to produce European- style numbers. | |||
<noinclude> | |||
[[Category:All Parameters]] | |||
</noinclude> |
Latest revision as of 16:13, 8 May 2014
See also Print Using.
USING is used with form statements to signify how something is to be read, written, or printed.
Instead of repeating all the form information in the statement, it is kept in a form statement and can be accessed by any line anywhere in the program. For example:
00290 read #1, using RECFORM: Mat Answers$,Shipping$,Mat Ordered eof DONEREADING 00300 RECFORM: form C 30,C 30,C 30,C 15,C 2,C 7,C 1,N 1,N 1,N 1 00450 write #1, using recform: mat answers$,shipping$,mat ordered
And in a print statement:
03500 print #255, using infoform: "REG", A(62),B(22),B(7),"FICA",B(3),"YTD" 03510 infoform: form pos 18, c 3,x 8,pic(z,zz#.##),x 6,pic(zz#.##),x 8,pic(zz,zz#.##),x 7,c 4,x 25,pic(z,zz#.##),x 12,c 3,skip 1
Syntax
<statement> [#{<window number>|<file number>},] USING {<line ref>|<string expression>} : [{MAT <array name>|}][,...] [<error condition> <line ref>][,...]
Parameters
USING can be used with the following statements: READ,PRINT,WRITE,REWRITE, and REREAD.
The optional "file-num" or "wind-num" parameters identify the output location for the printed information and must match the specification used in the OPEN statement for the same file, device or window. Two exceptions are that PRINT #255 and PRINT #0 can be used without an explicit OPEN statement. PRINT #255 outputs to the system printer, and PRINT #0 outputs to the screen.
The "USING" keyword specifies the "line-ref" of a FORM statement or a "string expression" containing a FORM statement. USING is responsible for the format of the output or input.
The optional "data-item" and "MAT array name" parameters identify the items to be output. Multiple specifications must be separated by commas.
See Error Conditions for the optional error condition parameter.
Defaults
- 1.) Output to the screen.
- 2.) Null data item.
- 3.) Interrupt the program if an error occurs and "ON error" is not active.
Technical Considerations
- 1.) Relevant error conditions are: CONV, EOF, ERROR, EXIT, IOERR, PAGEOFLOW, and SOFLOW.
- 2.) Standard printer output (PRINT #255) can be redirected using the RUN command. RUN >file-ref creates a new file or overwrites an existing file with printer output. RUN >>file-ref creates a new file or appends to an existing display file. RUN >CON: sends printer output to the screen; this option can save paper and speed up debugging and program development.
- 3.) The position after the USING keyword may contain a string expression (constant or variable) which must begin with the keyword "FORM " followed by a list of format specifications. This method is relatively slow because the string must be compiled on each execution.
- 4.) The PAGEOFLOW error condition can be used for page breaks. After executing a PRINT statement, Business Rules checks to see if the line count is greater than or equal to the value specified for PAGEOFLOW in the OPEN statement (the default is 60). If the test indicates it is time for a page break, control is transferred to the PAGEOFLOW line-ref after the statement has printed. A PRINT #file-num: NEWPAGE statement must be specified to reset the PAGEOFLOW counter to zero; otherwise, the next PRINT would also generate a page overflow condition.
- 5.) See Functions and Screen I/O for information about HEX$, which can be used in PRINT statements to change to special print modes (condensed, line spacing, etc.) and to set the display attributes on the screen.
- See BRConfig.sys for information about using PRINTER specifications to create a printer translation interface; PRINT statements using the HEX$ function will probably require some such translation.
- 6.) Array elements are output in row order (i.e., all elements for a row are processed before moving to the next row).
- 7.) When OPTION INVP is in effect, the normal printing of commas and periods is interchanged in PIC, N, NZ, G and GZ format specifications to produce European- style numbers.