광고
광고
FORMAT
FO
RMAT $NUM#
,width [,output_width] [,type] [,decimal_places]
$CHR#
$DAT#
defines new characteristics for one of the INFO system variables
$CHR#, $DAT#, or $NUM#.
arguments notes
$NUM# variables store numeric values.
$CHR# variables store character values.
$DAT# variables store date values.
,width the internal width of the variable.
[,output_width] the output width of the value of the variable.
[,type] INFO item type. Item types are described in the
DEFINE command reference.
[,decimal_places] only for numeric item types with decimal positions.
n
It is important to format all system variables both before they are used in a form, program, or report and before any corresponding form, program, or report is executed.
System variables must also be formatted correctly before a program is compiled.
n
FORMAT specifications are similar to those for data file items specified with the DEFINE command and follow all rules established for that command. Aspects of concern are described below for each of the system variable types.
n
MODE SET FORMAT allows you to save off the format
320-byte internal variable buffer and reset it to the saved format at a later time, or in another part of a program.
See the MODE command.
INFO Reference Manual Commands 241
FORMAT discussion
The FORMAT command sets formats for the system variables $NUM#, $CHR# and $DAT#. Using FORMAT, you can control the internal width, output width, data type and decimal positions for each system variable.
With the FORMAT command, you define the characteristics of one of the 40 locations that can be formatted in a 320-byte buffer that is internal to INFO.
Each of the 40 locations can be defined at a given time, as a numeric value, formatted as $NUM#; a character value, formatted as $CHR#; or a date value, formatted as
$DAT#.
By default, each system variable occupies an 8-byte portion of the system variable buffer: $NUM1, $CHR1, or
$DAT1 ($xxx1) occupies bytes 1—8; $xxx2 occupies bytes
9—16; $xxx3 occupies bytes 17—24, and so on. Default formats for the system variables are shown below.
Table FORMAT-1 System variable default formats
Item type Input width Output width Type Dec.
positions
$NUM#
$CHR#
$DAT#
8
8
8
16
16
11
F
C
D
2
-
-
NB. If you change the format of any system variable, the variable will occupy the buffer area necessary to accommodate the new format, starting with the first position allocated to that variable. The system variable
$xxx1 starts in position 1, $xxx2 starts in position 9, and so on; therefore the maximum of $CHR1 is 320 byes, that of $CHR2 is 312, etc.
Be careful when you extend the width of a $CHR# or
$NUM# item beyond the default width: the storage for the trailing contiguous system variables is overwritten when you next assign a value to that $CHR# or $NUM# system variable. For example, if you define $CHR4 to be 30 characters long, the space normally reserved for $xxx4—
$xxx7 is used by the $CHR4 variable. You cannot display or calculate using the values in $NUM4, $NUM5, and so on, as INFO interprets information stored in $CHR4 as character information.
242 Commands INFO Reference Manual
$NUM# variable items
$CHR# variable items
$DAT# variable items
FORMAT
$NUM# items are often used for accumulators or other storage areas, where the defined length of a data file item is too small. By varying the type defined for a $NUM# item, you can control its storage capacity, both for integer and decimal positions. All types available for the DEFINE command are available for $NUM# variables.
No $CHR# system variable can be formatted to extend past the last byte of the 320-byte system variable buffer.
$CHR# system variables can store character strings that can be executed as INFO commands using the EXECUTE command.
The width of a $DAT# system variable is always 8 bytes.
If you try to change the width of a $DAT# system variable,
INFO displays an error message. The output width for a
$DAT# item can be up to 11 characters.
Dates are stored internally in the format yyyymmdd.
Months and days less than 10 are stored and displayed with a leading space; to display these with leading zeroes, set the internal variable to $ZDATE to 1.
When a $DAT# system variable is displayed or printed, its output format follows the format specified by the current
DFMT setting. Be aware of the effects of output width changes for $DAT# items. As you shorten the output width of the system variable, characters are dropped from the right-most display positions. See the DFMT command for more information. Table FORMAT-2 below shows the effects of varying width specifications.
Table FORMAT-2 $DATn output displays
Date displayed Output width
11/12/1996
11/12/96
11/12
11
5
2
10
8
INFO Reference Manual Commands 243
FORMAT example see also
ENTER COMMAND >TYPE P.FORMAT
PROGRAM NAME: P.FORMAT
10000 PROGRAM SECTION ONE
10001 FORMAT $CHR1,20
10002 FORMAT $NUM4,5,I
10003 FORMAT $DAT5,8,8
10004 MOVE 'WELCOME TO INFO' TO $CHR1
10005 CALCULATE $NUM4 = 12345
10006 CALCULATE $DAT5 = $TODAY
10007 DISPLAY $CHR1,3X,$NUM4,$DAT5
ENTER COMMAND >RUN P.FORMAT
WELCOME TO INFO 12345 1/ 2/96
An extra 2048 bytes of storage exists for programmers to use called $WORK-BUFFER. It has been redefined as follows:
$WORK-BUFF 128,C occurs 16, indexed by $IDX2
$WORK-CHR 8,C occurs 64, indexed by $IDX2
$WORK-NUM
$WORK-INT
8,N,C occurs 64, indexed by $IDX2
8,I occurs 64, indexed by $IDX2
$WORK-BIN 2,5,B occurs 64, indexed by $IDX2
$WORK-FLOAT 8,15,F occurs 48, indexed by $IDX2
CLEAR is used to clear all internal variables (1-40) to nulls.
DINT is used to display the format and content of all of the system variables.
INTERNAL is used to display the characteristics of a given variable or item.
NAME is used to rename internal variables in order to give them more descriptive names.
REFORMAT is used to reformat all internal variables back to their default formats. Each internal variable's format is reset to a width of eight, output width of sixteen, data type of floating point (F), and two decimal places.
244 Commands INFO Reference Manual
다운로드
광고