SPECIAL-NAMES Paragraph [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
SPECIAL-NAMES Paragraph
The SPECIAL-NAMES paragraph allows you to relate certain[REV BEG]
COBOL-supplied feature, switch, or device names[REV END] to mnemonic
names. By specifying these mnemonic names in your program, you can
invoke these functions. It allows you to relate the alphabet name
specified in the PROGRAM COLLATING SEQUENCE clause to a particular
collating sequence or character set, and to define other collating
sequences with different alphabet names. The SPECIAL-NAMES paragraph
also allows you to specify symbolic characters and to relate class names
to sets of characters.
Syntax
Parameters
[REV BEG]
feature-name-1 a COBOL reserved word having a specific
meaning. Table 6-1 lists these feature
names and describes their meanings.
switch-name-1 a COBOL reserved word having a specific
meaning. Table 6-1 lists these switch
names and describes their meanings.
device-name-1 a COBOL reserved word having a specific
meaning. Table 6-1 lists these device
names and describes their meanings.[REV END]
mnemonic-name-1 and names you choose to represent[REV BEG]
mnemonic-name-2 feature-name-1, switch-name-1, or
device-name-1[REV END] within your program.
These names can be any valid user-defined COBOL
words.
condition-name-1 and each are any valid user-defined COBOL words.
condition-name-2
alphabet-name-1 either the name (if any) specified in the
PROGRAM COLLATING SEQUENCE clause of the
OBJECT-COMPUTER paragraph, or any valid
user-defined COBOL word.
literal-1 through are each nonnumeric or numeric literals. If
literal-5 any such literal is a numeric literal, it must
be a positive integer from the range 1 to 256.
If any nonnumeric literal is used in a THROUGH
or ALSO phrase, it must be only one character
long. Note that no ASCII character can be
specified more than one time as a literal in
any given ALPHABET clause. Literals 1 through
5 must not be nonnumeric figurative constants.
ANSI COBOL'85 allows literals 1 through 5 to
be figurative constants.
STANDARD-1 and represent the ASCII collating sequence.
STANDARD-2
NATIVE currently defined as representing the ASCII
collating sequence. However, it may be changed
to represent another character set (for
example, the KATAKANA character set).
EBCDIC specifies that the EBCDIC collating sequence is
to be used. Note that this does not enable any
conversion of data. It only allows data to be
(for example) sorted or merged according to the
EBCDIC collating sequence.
EBCDIK
specifies the Japanese version of the EBCDIC
collating sequence.
literal-6 a single character, chosen from a specific set.
This set is shown later in this chapter, when
the CURRENCY SIGN clause is described.
THROUGH and THRU are equivalent and may be used interchangeably.
symbolic- character-1 a name you choose to represent the user-defined
constant within your program. This name can be
any valid user-defined COBOL word.
integer-1 the ordinal position specified by integer-1
must exist in the ASCII character set. If the
IN phrase is specified, the ordinal position
must exist in the character set named by
alphabet-name-2.
alphabet-name-2 the name specified in the ALPHABET clause of
the SPECIAL-NAMES paragraph.
class-name-1 a name you choose to represent a user-defined
class; this name can be any valid user-defined
COBOL word.
Each clause of the SPECIAL-NAMES paragraph is described on the following
pages.
NOTE The SPECIAL-NAMES clause must follow the order shown in the syntax
diagram.
[REV BEG]
Feature-name, Switch-name, or Device-name Clause
[REV END]
[REV
BEG]
In the Feature-name, Switch-name, or Device-name clause,[REV END] you
relate various COBOL functions to mnemonic names used in your program.
You do this by equating the specific function name to the desired
mnemonic name.
Syntax.
Parameters.
[REV BEG]
feature-name-1 a COBOL reserved word having a specific
meaning. Table 6-1 lists these feature
names and describes their meanings.
switch-name-1 a COBOL reserved word having a specific
meaning. Table 6-1 lists these switch
names and describes their meanings.
device-name-1 a COBOL reserved word having a specific
meaning. Table 6-1 lists these device
names and describes their meanings.[REV END]
mnemonic-name-1 and names you choose to represent[REV BEG]
mnemonic-name-2 feature-name-1, switch-name-1, or device-name-1
within[REV END] your program. These names can
be any valid user-defined COBOL words.
condition-name-1 and each are any valid user-defined COBOL words.
condition-name-2
Description.
The feature, switch, and device names and corresponding functions are
listed in Table 6-1 . All names except the software switches (SW0
through SW15) and the CONDITION-CODE feature may be referenced by using
the assigned mnemonic-name in the ACCEPT, DISPLAY, or WRITE statements of
the PROCEDURE DIVISION. The CONDITION-CODE feature is related to the
special MPE intrinsic relation condition. Refer to the description of
relation conditions in Chapter 8 for more information.
Table 6-1. HP COBOL II Feature, Switch, and Device Names
---------------------------------------------------------------------------
| | |
| Feature Name | Function |
| | |
---------------------------------------------------------------------------
| | |
| CONDITION-CODE | Refers to condition codes returned by operating |
| | system intrinsics when they have been called |
| | through the CALL statement. |
| | |
---------------------------------------------------------------------------
| | |
| NO SPACE CONTROL | When included in the ADVANCING clause of the |
| | WRITE statement, this prevents the line printer |
| | from advancing vertically or horizontally. |
| | |
---------------------------------------------------------------------------
| | |
| TOP | When included in the ADVANCING clause of the |
| | WRITE statement, the mnemonic name assigned to |
| | TOP causes the line printer to perform a page |
| | eject. |
| | |
---------------------------------------------------------------------------
| | |
| C01 | Used in the ADVANCING clause of the WRITE |
| through | statement for sequential files. Each directs |
| C16 | the line printer to skip to a particular |
| | channel (1 through 16) on the carriage control |
| | tape. Refer to Chapter 9 for details. |
| | |
---------------------------------------------------------------------------
| | |
| Switch Name | Function |
| | |
---------------------------------------------------------------------------
| | |
| SW0 | Refer to software switches associated with |
| through | condition names. (Software switches are |
| SW15 | described in the next section of this chapter.) |
| | |
---------------------------------------------------------------------------
| | |
| Device Name | Function |
| | |
---------------------------------------------------------------------------
| | |
| SYSIN | Refers to the operating system standard input |
| | device. In an interactive session, this is |
| | your terminal. In a batch job, it is either |
| | the card reader or operator's console. |
| | |
---------------------------------------------------------------------------
| | |
| SYSOUT | Refers to the operating system standard output |
| | device. In an interactive session, this is |
| | your terminal. In a batch job, it is the line |
| | printer[REV BEG] |
| | |
---------------------------------------------------------------------------
| | |
| CONSOLE | Refers to the computer operator's console (not |
| | your terminal).[REV END] |
| | |
---------------------------------------------------------------------------
Software Switches.
The software switches are external switches known to COBOL, the status of
which is available to each object program functioning within the entire
run unit.
Each of the 16 software switches (SW0 through SW15) used in a given
program has at least one condition name associated with it.
A condition name and the SET statement are the means by which you can
reference one of these switches. For example,
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. HPCOMPUTER
OBJECT-COMPUTER. HPCOMPUTER
SPECIAL-NAMES.
SW0 IS SORT-SWITCH ON STATUS IS SORT-ON.
PROCEDURE DIVISION.
:
IF SORT-ON
THEN CALL "SORTER".
:
In the above example, the actual reference to SW0 is done in the IF
statement in the PROCEDURE DIVISION, where SORT-ON is tested in a
condition name condition. (Chapter 8 has information on condition
name conditions.) If SORT-ON is in an "on" condition, the subprogram
SORTER is called. If it is in an "off" condition, the next executable
sentence is executed.
Software switches are always considered to be OFF at the beginning of the
execution of a program unless you turn them on before execution begins.
To turn switches on or off after execution begins, use the SET statement.
Refer to Appendix H , "MPE XL System Dependencies", for information on
setting software switches before execution begins.
Line Printer Features.
The TOP, NO SPACE CONTROL, and C01 through C16 switches are all related
to line printer control. Since there is no way for a COBOL II program to
explicitly check for the condition of a line printer, you cannot use
condition names with these functions. You must, however, specify
mnemonic names for these functions if you intend to reference them later
in your program. For example:
SPECIAL-NAMES.
TOP IS TOP-OF-FORM, C09 IS TO-END-OF-FORM.
:
PROCEDURE DIVISION.
:
WRITE REC-OUT FROM FOOT-NOTE
AFTER ADVANCING TO-END-OF-FORM.
:
WRITE REC-OUT FROM TITLE
AFTER ADVANCING TOP-OF-FORM.
:
CONDITION-CODE Features.
The CONDITION-CODE function allows you to check the condition code
returned by MPE intrinsics. This function is itself a form of
conditional variable, with an integer value. Thus, no condition name can
be associated with it, and a mnemonic name must be used if you wish to
check condition codes returned by intrinsics called from your program.
Refer to the section on relation conditions in Chapter 8 for an
example and more information.
SYSIN, SYSOUT, and CONSOLE Devices.
The SYSIN, SYSOUT, and CONSOLE functions are used in the ACCEPT and
DISPLAY statements of the PROCEDURE DIVISION. Since these names refer to
terminals, line printers, card readers, and the operator's console, you
cannot associate condition names with them. Also, because of the formats
of the ACCEPT and DISPLAY statements, you need not specify mnemonic names
for them in the SPECIAL-NAMES paragraph. You may, however, choose to do
so. Refer to the ACCEPT and DISPLAY statement descriptions in Chapter 9
for more information.
ALPHABET Clause
The ALPHABET clause has three functions:
1. To define a program collating sequence to be used in sort and
merge operations, and nonnumeric comparisons.
2. To define an alphabet name and relate this name to either the
ASCII, EBCDIK, or the EBCDIC collating sequence. This alphabet
name can later be used in the CODE-SET clause of the DATA DIVISION
to specify whether records of a sequential file are written in
ASCII or EBCDIC code.
3. To define an alternate collating sequence separate from the
program collating sequence to be used (optionally) in sort and
merge operations.
Syntax.
The ALPHABET clause has the following format:
Parameters.
alphabet-name-1 either the name (if any) specified in the PROGRAM
COLLATING SEQUENCE clause of the OBJECT-COMPUTER
paragraph, or any valid user-defined COBOL word.
literal-1 through each are alphabetic or numeric literals. If any such
literal-3 literal is a numeric literal, it must be a positive
integer from the range 1 to 256. If any nonnumeric
literal is used in a THROUGH or ALSO phrase, it must
be only one character long. Note that no ASCII
character can be specified more than one time as a
literal in any given ALPHABET clause.
STANDARD-1 and represents the ASCII collating sequence.
STANDARD-2
NATIVE represents the ASCII collating sequence.
EBCDIC specifies that the EBCDIC collating sequence is to be
used. Note that this does not enable conversion of
data. It only allows data to be (for example) sorted
or merged according to the EBCDIC collating sequence.
EBCDIK specifies the Japanese version of the EBCDIC
collating sequence.
THROUGH and THRU equivalent and may be used interchangeably.
To define a program collating sequence, you must relate the alphabet-name
specified in the PROGRAM COLLATING SEQUENCE clause of the OBJECT-COMPUTER
paragraph to either the words NATIVE, STANDARD-1, STANDARD-2, EBCDIC,
EBCDIK, or a list of literals.
STANDARD-1 and STANDARD-2 refer to the ASCII collating sequence, which is
used on all HP computer systems. Therefore, you need not specify
alphabet-name in either the PROGRAM COLLATING SEQUENCE clause or the
SPECIAL-NAMES paragraph if this is your choice for a program collating
sequence.
STANDARD-1, STANDARD-2 and NATIVE Phrases.
To specify the ASCII collating sequence used on HP computer systems,
enter either the STANDARD-1, STANDARD-2, or NATIVE phrase in the ALPHABET
clause. For example,
SPECIAL-NAMES.
ALPHA-NAME IS STANDARD-1.
NOTE Although NATIVE is currently defined as being the ASCII collating
sequence, it may be changed in future releases of HP COBOL II.
Thus, to avoid the possibility of having to change your program in
the future, you should always use the STANDARD-1 or STANDARD-2
phrase, rather than the NATIVE phrase.
EBCDIC and EBCDIK Phrases.
To specify the EBCDIC collating sequence, enter EBCDIC in the ALPHABET
clause:
SPECIAL-NAMES.
ALPHA-NAME IS EBCDIC.
To specify the Japanese version of the EBCDIC collating sequence, use
EBCDIK.
LITERAL Phrase.
The literal phrase allows you to rearrange the ASCII collating sequence
to suit your needs. However, if you specify the literal phrase in an
ALPHABET clause, you may not reference that name in a CODE-SET clause.
Defining Your Own Collating Sequence.
To define your own collating sequence, you must follow the rules listed
below.
1. If you specify a nonnumeric literal, it represents the equivalent
character in the ASCII collating sequence. For instance, the
literal "A" represents an ASCII A.
If the literal consists of several characters, each character is
assigned successive ascending positions in the collating sequence,
beginning with the leftmost character. For example,
ALPHA-NAME IS "0A9B8C7D".
Results in the following collating sequence:
0
A
9
B
8
C
7
D
:
2. If you specify a numeric literal, it represents the ordinal number
of the corresponding character in the ASCII collating sequence.
Therefore, if you specify 66, this represents the 66th character
in the ASCII collating sequence--an uppercase A.
3. The order in which the literals appear in the ALPHABET clause
determines, in ascending sequence, the ordinal numbers of the
corresponding characters in the new collating sequence.
4. Any ASCII characters not explicitly specified in the literal
phrase assume positions in the new collating sequence numerically
higher than any explicitly specified characters. The relative
order of the unspecified characters, with respect to each other,
is the same as in the ASCII collating sequence.
5. If you use the THROUGH phrase, the new collating sequence consists
of contiguous characters from the ASCII character set, beginning
with the value of literal-1 and ending with the value of
literal-2. These characters are assigned successive ascending
positions in the new character set. As an example, the following
ALPHABET clause creates a collating sequence consisting of all
uppercase alphabetic characters (letters) from the ASCII collating
sequence:
ALPHA-NAME IS "A" THROUGH "Z"
With the THROUGH phrase, you can also specify and assign ASCII
characters in descending sequence:
ALPHA-NAME IS "Z" THROUGH "A".
_________________________________________________________________
NOTE If a nonnumeric literal is used in a THROUGH phrase, it must
be only one character long.
_________________________________________________________________
6. If you use the ALSO phrase, the ASCII characters specified by
literal-1 and literal-3 are assigned to the same relative
positions in the new collating sequence. If you use a nonnumeric
literal in an ALSO phrase, it must be only one character long.
7. The character with the highest ordinal position in the new
collating sequence may be referenced by the figurative constant,
HIGH-VALUE. If more than one character shares the highest ordinal
position, the last character specified in the ALPHABET clause is
referenced by HIGH-VALUE.
8. The character with the lowest ordinal position in the new
collating sequence may be referenced by the figurative constant
LOW-VALUE. If more than one character shares the lowest ordinal
position, the first character specified in the ALPHABET clause is
referenced by LOW-VALUE.
[REV BEG]
9. Within the SPECIAL-NAMES paragraph, the figurative constants
HIGH-VALUE and LOW-VALUE are those positions in the native
collating sequence, ASCII. If you redefine HIGH-VALUE or LOW-VALUE
in the SPECIAL-NAMES paragraph, the new values will not take
effect until after the SPECIAL-NAMES paragraph.[REV END]
Example
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
OBJECT-COMPUTER. HP3000
PROGRAM COLLATING SEQUENCE IS ASCII.
SPECIAL-NAMES.
ASCII IS STANDARD-1
IBMCODE IS EBCDIC
SORT-SEQ IS "A" THROUGH "Z"
"a" THROUGH "z".
DATA DIVISION.
FILE SECTION.
FD EBCDICIN
CODE-SET IS IBMCODE.
:
FD EBCDOUT
CODE-SET IS IBMCODE.
:
PROCEDURE DIVISION.
SORT SFILE ON ASCENDING LEFT-CHR
COLLATING SEQUENCE IS SORT-SEQ
USING INFILE
GIVING OUTFILE.
SORT SFILE ON ASCENDING LEFT-CHAR
COLLATING SEQUENCE IS IBMCODE
USING EBCDICIN
OUTPUT PROCEDURE IS SORT-OUT-PARA THROUGH END-OUT.
:
SORT-OUT-PARA.
GET-NEXT-REC.
RETURN SFILE INTO CHK-REC AT END GOTO END-OUT.
IF DATA-FIELD-2 OF CHK-REC IS NOT ALPHABETIC
THEN DISPLAY "ERROR IN SORTED RECORD "
DISPLAY CHK-REC
ELSE MOVE CHK-REC TO EBCDOUT.
GO GET-NEXT-REC.
END-OUT.
In the above example, the program collating sequence is specified as
STANDARD-1. Because this is the default, the PROGRAM COLLATING SEQUENCE
clause and the ASCII IS STANDARD-1 phrase serve only as documentation.
The alphabet-name, IBMCODE is used in two file description entries to
indicate that the records of the files EBCDICIN and EBCDOUT are in EBCDIC
code. Thus, when the records are read in, they are translated to ASCII,
and when they are written out, they are translated back to EBCDIC.
The use of IBMCODE in the second SORT statement causes the ASCII records
of SFILE (obtained from EBCDICIN) to be sorted using the EBCDIC collating
sequence. Since EBCDOUT also names IBMCODE as its code-set, the sorted
records are translated back from ASCII to EBCDIC when they are written to
EBCDOUT. Thus, the result of this sorting operation is an EBCDIC file
sorted with the EBCDIC collating sequence. It is not necessary to
translate the records from EBCDIC to ASCII, unless you want the ability
to display an erroneous record. The results of sorting the records
without using a translation are the same. However, since, in the output
procedure, any erroneous record is displayed, and since it appears as the
ASCII equivalent of EBCDIC characters, the CODE-SET clause is required in
the file description of EBCDICIN to translate the records into ASCII.
In the first SORT statement, the collating sequence is specified as
SORT-SEQ. The result of this is that the records of OUTFILE are arranged
in such a way that all records containing alphabetic characters in their
leftmost positions precede records containing nonalphabetic characters in
corresponding positions. This is different from the standard ASCII
collating sequence, since, in the standard sequence, all numerals and 55
other characters precede the letters of the alphabet name.
SYMBOLIC CHARACTERS Clause
The SYMBOLIC CHARACTERS clause is a feature of the 1985 ANSI COBOL
standard.
A symbolic character is a user-defined word that specifies a user-defined
figurative constant. This feature is useful for unprintable characters.
For example, a symbolic character can be used to produce audible output
from the terminal.
Syntax.
Parameters.
symbolic-character-1 name you choose to represent a user-defined
figurative constant. The same
symbolic-character-1 must appear only once in a
SYMBOLIC CHARACTERS clause.
integer-1 must be a positive integer in the range of 1 to
256.
alphabet-name-2 must be an alphabet name specified in the
ALPHABET clause.
The following rules apply to the SYMBOLIC CHARACTERS clause:
* The relationship between each symbolic-character-1 and the
corresponding integer-1 is by position in the SYMBOLIC CHARACTERS
clause. The first symbolic-character-1 is paired with the first
integer-1, the second symbolic-character-1 is paired with the
second integer-1, and so on.
* There must be a one-to-one correspondence between occurrences of
symbolic-character-1 and integer-1.
* The ordinal position specified by integer-1 must exist in the
ASCII character set. If the IN phrase is specified, integer-1
specifies the ordinal position of the character set named by
alphabet-name-2.
* If the IN phrase is not specified, symbolic-character-1 represents
the character whose ordinal position in the ASCII character set is
specified by integer-1.
* The internal representation of symbolic-character-1 is the
internal representation of the character that is represented in
the ASCII character set.
For example, the following SYMBOLIC CHARACTERS clause declares the words
BELL, CARRIAGE-RETURN, and ESCAPE:
SYMBOLIC CHARACTERS BELL IS 8, CARRIAGE-RETURN IS 14, ESCAPE IS 28.
With the above declaration you can use the following DISPLAY statements.
The first DISPLAY makes a sound on the terminal before displaying the
message. The second displays the message in inverse video on certain
terminals:
DISPLAY BELL " JOB COMPLETED ".
DISPLAY ESCAPE "&dB" "Enter a number: ".
CLASS Clause
The CLASS clause is a feature of the 1985 ANSI COBOL standard.
The CLASS clause is used to create a user-defined class and provides a
means for relating a name to the specified set of characters it lists.
Syntax.
Parameters.
class-name-1 can only be referenced in a class condition. (Refer to
Chapter 8 for more information about class
conditions.)
literal-4 and specify values that define the exclusive set of
literal-5 characters contained in class-name-1.
THROUGH and THRU equivalent.
The following rules apply to the literal specified in the CLASS clause:
* A numeric literal must be an unsigned integer and must have a
value within the range of one through the maximum number of
characters in the ASCII character set (256).
* A nonnumeric literal that is associated with a THROUGH phrase must
be one character in length. If a nonnumeric contains multiple
characters, each character is included in class-name-1.
* If the THROUGH phrase is specified, the contiguous characters in
the ASCII character set beginning with literal-4 and ending with
literal-5, are included in class-name-1. In addition, the
contiguous characters specified by a given THROUGH phrase may
specify the characters of the ASCII character set in either
ascending or descending sequence.
Example.
SPECIAL-NAMES.
CLASS VALID-GRADE IS "A" "B" "C" "D" "F".
:
WORKING-STORAGE.
01 GRADE-LIST.
05 CLASS-GRADES PIC X OCCURS 5 TIMES.
:
IF GRADE-LIST IS NOT VALID-GRADE THEN
PERFORM ERROR-ROUTINE.
CURRENCY SIGN IS Clause
The CURRENCY SIGN IS clause is used to specify a literal whose value is
later referenced in the PICTURE clause of the DATA DIVISION to denote a
currency symbol.
Syntax.
Parameters.
literal-6 a single character, chosen from a specific set. The
literal cannot be any of the following characters:
* The digits 0 through 9.
* The letters A B C D P R S V X Z a b c d p r s v x
z
* A space
_________________________________________________
NOTE ANSI COBOL'85 allows the letter L, but does
not allow lowercase letters.
_________________________________________________
* The special characters:
* (asterisk)
+ (plus sign)
- (minus sign)
, (comma)
. (period or decimal point)
; (semicolon)
( (left parentheses)
) (right parentheses)
" (quotation mark)
/ (slash mark)
= (equal sign)
The literal must not be a figurative constant.
Description.
If the CURRENCY SIGN IS clause is omitted, the dollar sign ($) must be
used as the currency symbol in the PICTURE clause.
Example.
To specify the percent sign (%) as the currency symbol, enter the
following clause:
CURRENCY SIGN IS "%"
DECIMAL POINT IS COMMA Clause
The DECIMAL POINT IS COMMA clause allows you to request the exchange of
the function of the comma and decimal point (or period) in numeric
literals or PICTURE-CLAUSE character strings.
Syntax.
[DECIMAL-POINT IS COMMA].
Description.
This clause has some effect on pictures for edited data items. Refer to
Chapter 7 , under "PICTURE-CLAUSE," for details. This clause also has
an effect on the ACCEPT FREE verb. When entering data for the ACCEPT
FREE verb, use a comma instead of a decimal point.
MPE/iX 5.0 Documentation