G: Difference between revisions
Gordon.dye (talk | contribs) No edit summary |
Gordon.dye (talk | contribs) No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
The G (generic) format specification identifies data that may be either data or string. This is a highly versatile format specification, as it can be used with both types of [[FORM]] statements (for internal/external files and for display files), and the full screen processing statements. | The G (generic) format specification identifies data that may be either data or string. This is a highly versatile format specification, as it can be used with both types of [[FORM]] statements (for internal/external files and for display files), and the full screen processing statements. | ||
Conversion errors on G, [[N]], and [[PIC]] formats can now be avoided on output to display files when the CONV=parameter is used in the OPEN DISPLAY statement. Also when CONV=is used, PIC processing will first try removing the commas from the output if doing so will prevent an overflow condition. | Conversion errors on G, [[N]], and [[PIC]] formats can now be avoided on output to display files when the CONV=parameter is used in the OPEN DISPLAY statement. Also when CONV=is used, PIC processing will first try removing the commas from the output if doing so will prevent an overflow condition. See the [[OPEN DISPLAY]] Statement for more information concerning CONV=. | ||
N and G lengths are limited to 127.<br> | N and G lengths are limited to 127.<br> | ||
;Input characteristics: | ;Input characteristics: | ||
The input characteristics of G differ according to whether it is used with string or numeric data. When used with string data, G operates the same as V in that it removes all trailing spaces. G is the same as N when used with numeric data. The field length for a G or N specification must identify the leading minus sign if needed, and a decimal point and decimal places if specified. Fraction length is optional and indicates the number of decimal places to be printed. The value will be rounded to the number of decimal places specified. | The input characteristics of G differ according to whether it is used with string or numeric data. When used with string data, G operates the same as V in that it removes all trailing spaces. G is the same as N when used with numeric data. The field length for a G or N specification must identify the leading minus sign if needed, and a decimal point and decimal places if specified. Fraction length is optional and indicates the number of decimal places to be printed. The value will be rounded to the number of decimal places specified. | ||
;Output characteristics: | ;Output characteristics: | ||
Line 35: | Line 35: | ||
50.50 | 50.50 | ||
Technical Considerations: | |||
:1.) See the [[C]] format specification for an example of the differences between C, [[V]] and G format specifications. | :1.) See the [[C]] format specification for an example of the differences between C, [[V]] and G format specifications. | ||
:2.) See the [[GF]], [[GL]], [[GU]], and [[GZ]] Format Specifications for information on variations of the G specification. | :2.) See the [[GF]], [[GL]], [[GU]], and [[GZ]] Format Specifications for information on variations of the G specification. | ||
:3) As of 4.3, #G can be used to work with numeric values from a string | :3) As of 4.3, '''#G can be used to work with numeric values''' from a string similar to #PIC and #FMT, which indicates that ''string data should be processed numerically'' for display and sorting purposes. This works for [[INPUT FIELDS]] as well as [[GRIDs and LISTs]] and it works for all variants of the G format. | ||
===See Also=== | ===See Also=== |
Latest revision as of 20:31, 4 June 2015
The G (generic) format specification identifies data that may be either data or string. This is a highly versatile format specification, as it can be used with both types of FORM statements (for internal/external files and for display files), and the full screen processing statements.
Conversion errors on G, N, and PIC formats can now be avoided on output to display files when the CONV=parameter is used in the OPEN DISPLAY statement. Also when CONV=is used, PIC processing will first try removing the commas from the output if doing so will prevent an overflow condition. See the OPEN DISPLAY Statement for more information concerning CONV=.
N and G lengths are limited to 127.
- Input characteristics
The input characteristics of G differ according to whether it is used with string or numeric data. When used with string data, G operates the same as V in that it removes all trailing spaces. G is the same as N when used with numeric data. The field length for a G or N specification must identify the leading minus sign if needed, and a decimal point and decimal places if specified. Fraction length is optional and indicates the number of decimal places to be printed. The value will be rounded to the number of decimal places specified.
- Output characteristics
The output characteristics of G differ according to whether it is used with string or numeric data. When used with string data, G formats output in the same way that C and V do. Data is printed on the left side of the output field (leading spaces are retained) and padded with blanks on the right.
- NOTE the following example including the space ahead of the letter A
00010 PRINT USING 20: " ABC","DEF" 00020 FORM G 8,G 3
Output from the above example appears as follows:
ABC DEF
Notice that the first string value is output with one leading space, as was specified in the PRINT statement.
When used for output of numeric data, G is identical to N. Numeric values are right-justified, padded with blanks on the left, and rounded to the specified number of decimal positions.
The following example uses the format specification G 6.2 to format 50.5 and output it to the screen. The total length of the field, including the leading blank and decimal point, is 6:
00010 PRINT USING 20: 50.5 00020 FORM G 6.2
Output from the above example would be as follows (note that there is one leading blank; the output is right justified in the field length specified):
50.50
Technical Considerations:
- 1.) See the C format specification for an example of the differences between C, V and G format specifications.
- 2.) See the GF, GL, GU, and GZ Format Specifications for information on variations of the G specification.
- 3) As of 4.3, #G can be used to work with numeric values from a string similar to #PIC and #FMT, which indicates that string data should be processed numerically for display and sorting purposes. This works for INPUT FIELDS as well as GRIDs and LISTs and it works for all variants of the G format.
See Also
The letter G can also be used as a Control Attribute.
G is also an FMT character identifier, meaning display any character from A to Z, a to z, or 0 to 9, and force it to upppercase if its alphabetic. See FMT Syntax. Lowercase "g" means the same except forced to lowercase.