|
HP COBOL Reference Manual
General Rules (Format 2)
- The USING, FROM, and TO phrases have meaning only when the screen
item's name or a screen name in its hierarchy, is specified in an
ACCEPT or DISPLAY statement.
- When data is to be transferred to the screen from one data item,
possibly edited, and stored in a different data item, both the FROM and
TO phrases must be used in the PICTURE clause of the screen item.
- When data is to be transferred to the screen, possibly modified,
and stored in the same data item (as when reading, modifying, and
rewriting records of a file), the USING phrase must be used in the
PICTURE clause of the screen item.
- identifier-3, identifier-4,
identifier-5, and literal-1 need not be the same
length as the screen item containing the PICTURE clause.
- Transfers between identifier-3, identifier-4,
identifier-5, and literal-1, on the one hand, and the
screen item are made in accordance with the rules of the MOVE
statement. (See the MOVE Statement in Chapter 6.)
- When the FROM phrase is specified:
- On DISPLAY statement execution, data is transferred from
identifier-4 or literal-1, after being edited in
accordance with character-string, and displayed on the screen.
The display begins at the screen position defined either implicitly or
explicitly by the LINE and COLUMN clauses and the starting screen
coordinates specified in the DISPLAY statement.
- The FROM phrase has no meaning in the execution of an ACCEPT
statement.
- When the TO phrase is specified:
- At ACCEPT statement completion, the data entered into the field on
the screen is transferred to identifier-5, after being edited
in accordance with the picture string specified for
identifier-5.
- The TO phrase has no meaning in the execution of a DISPLAY
statement.
- When the USING phrase, or the FROM and TO phrases are specified:
- On DISPLAY statement execution, data is transferred from
identifier-3, identifier-4, or literal-1 as
described in rule 11a above.
- On ACCEPT statement execution, data is transferred from
identifier-3, identifier-4, or literal-1 as
described in rule 11a above. At ACCEPT statement completion, the data
entered into the screen item is transferred to identifier-3 or
identifier-5 as described in rule 12a above.
Editing Rules
- There are two PICTURE clause editing methods: insertion editing and
suppression and replacement editing. Each method has the following
variations:
Editing Method |
Variations in Each Method |
Insertion
|
Simple insertion editing, special insertion editing, fixed insertion
editing, or floating insertion editing
|
Suppression and
Replacement
|
Zero suppression and replacement with spaces, or zero suppression and
replacement with asterisks
|
- The types of editing that a program can perform on an item depend
on the item's category:
Category |
Types of Editing |
Valid Editing Characters |
Alphabetic
|
None
|
None
|
Numeric
|
None
|
None
|
Alphanumeric
|
None
|
None
|
Alphanumeric Edited
|
Simple insertion
|
0, B, and /
|
Numeric Edited
|
All
|
All, subject to Editing Rule 3
|
- Floating insertion editing and editing by zero suppression and
replacement are mutually exclusive. That is, a PICTURE clause can use
one type of editing or the other, but not both.
Furthermore, a
PICTURE clause can use only one type of replacement symbol for zero
suppression. The space (Z) and asterisk (*) symbols cannot appear in
the same PICTURE clause.
Simple Insertion Editing
- A comma (,) space (B), zero (0), and slash (/) are symbols you can
use in simple insertion editing. They indicate an item position to
contain the character they represent. These symbols count toward the
size of the item.
If the comma is the last symbol in
character-string, the PICTURE clause must be the last clause
of the data description entry. In this case, a comma followed by a
period (,.) are the last two characters of the data description entry.
However, if the DECIMAL-POINT IS COMMA clause is in the SPECIAL-NAMES
paragraph, the data description entry ends with two consecutive periods.
Special Insertion Editing
- The period (.) is the only symbol used in special insertion
editing. It represents the item position to contain the actual decimal
point; however, it also represents the decimal point for alignment
purposes. Therefore, the assumed decimal point (V) and the actual
decimal point (.) cannot be used in the same character-string.
The period counts toward the size of the item.
If the period is the
last symbol in character-string, the PICTURE clause must be
the last clause of the data description entry. In this case, the data
description entry ends with two periods. However, if the DECIMAL-POINT
IS COMMA clause is in the SPECIAL-NAMES paragraph, a comma followed by
period (,.) are the last two characters of the data description entry.
Fixed Insertion Editing
- The currency symbol (cs) and the editing sign control symbols (+,
--, CR, and DB) are the symbols used in fixed insertion editing.
character-string can contain only one currency symbol and only
one of the editing sign control symbols as fixed insertion characters.
CR and DB each represent two character positions, which must be the two
rightmost positions. The plus sign (+) and minus sign (-) must be
either the leftmost or rightmost character position that counts toward
the size of the item. The currency symbol (cs) must be the leftmost
character position that counts toward the size of the item; however, a
plus sign (+) or minus sign (-) can precede it. Fixed insertion
editing causes the insertion symbol to occupy the same position in the
edited item as in character-string. Table 5-9 shows that
the results of using editing sign control symbols depend on the item's
value.
Floating Insertion Editing
- The currency symbol (cs), the plus sign (+), and the minus sign
(-) are the symbols used in floating insertion editing. They are
mutually exclusive in character-string. That is, if any
floating insertion symbol appears in character-string, no
other floating insertion symbol can appear.
To indicate floating
insertion editing, you must use a string of at least two floating
insertion symbols. You can include simple insertion symbols either
within the floating string or immediately to the right of the floating
string. These simple insertion symbols are treated as part of the
floating string. That is, they appear in results only when the value of
the item is large enough to include the position occupied by the simple
insertion symbol. You can append the fixed insertion symbols CR or DB
immediately to the right of a floating string. The leftmost symbol
of the floating insertion string represents the leftmost position in
which a floating insertion character can appear. This character
position cannot be filled by a digit. The second floating symbol
from the left represents the leftmost limit of the numeric data the
item can store. Nonzero numeric characters can replace all symbols at
or to the right of this limit. You can use the floating insertion
symbol in only two ways. It can represent the following:
- Any or all leading numeric character positions to the left of the
decimal point
In this case, run-time results show a single
insertion character in the position immediately preceding either the
first nonzero digit in the item or the decimal point, whichever appears
leftmost in the data. For example, an item whose PICTURE is $$$.99 and
whose value is zero appears as $.00.
- All numeric character positions in the PICTURE character-string
In this case, you must specify at least one insertion symbol to the
left of the decimal point. When the item has a nonzero value, run-time
results are the same as when all the insertion symbols are to the left
of the decimal point. However, when the item has a zero value, run-time
results show neither a floating insertion character nor the decimal
point. For example, a item whose PICTURE is $$$.$$ and whose value is
zero appears as spaces. If the floating insertion symbol is a plus
sign (+) or minus sign (-), the actual character inserted depends on
the value of the item. Table 5-10 shows the possible results of
using editing sign control symbols in floating insertion editing.
To avoid truncation, the minimum size of character-string
must be the sum of:
- The number of characters in the sending item
- The number of simple, special, or fixed insertion characters edited
into the receiving item
- One, for the floating insertion character
|