HP 3000 Manuals

Character Strings [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

Character Strings 

Character strings may form:

   *   Words.

   *   Literals.

   *   PICTURE character strings.

   *   Comment entries.

Words 

In COBOL, a word is generally the name of some entity such as a function,
paragraph, register, section, data item, constant, or other[REV BEG]
syntactical term used in a format description.  There are four types:[REV
END]

   *   Reserved words.

   *   User-defined words.

   *   System names.[REV BEG]

   *   Function-Names.[REV END]

Each word is limited to a maximum length of 30 characters.  Certain types
of words, such as user-defined words, may be restricted to a shorter
length.

Reserved Words.   

A COBOL reserved word is a word that has a predefined meaning (see
Appendix F  for a complete list) that is always consistent within all
COBOL programs.  Thus, reserved words are always interpreted in the same
way by the compiler.  For instance, the reserved word SECTION always
denotes a COBOL section header.  As a programmer, you may not define your
own reserved words.  You can use the following types of reserved words in
your program:

   *   Keywords.

   *   Optional words.

   *   Special register words.

   *   Figurative constant words.

   *   Special character words.

Keywords.   

A keyword is a reserved word that is required in a statement or clause.
You must enter the keywords where they are used.  In the division header
below, the words PROCEDURE, DIVISION, and USING are keywords.  (In the
format descriptions in this manual, all keywords are denoted by
underlined upper case letters.)  The USING clause is optional, as
indicated by the brackets.  But if you use this clause in your program,
you must include the keyword USING. 

     PROCEDURE DIVISION [USING {data-name-1}...].

Optional Words.   

An optional word is a reserved word that you can include in or omit from
a statement or clause.  It has no effect on program execution and serves
only to make source program listings more readable.  In the following
clause, the words MODE and IS are optional.  (In the format descriptions,
all optional reserved words are denoted by upper case letters that are
not underlined.)

[]
Special Register Words. A special register is a storage area in main memory that contains information primarily used in connection with specific COBOL features. The content of this area is generated automatically by the compiler. In a COBOL program, such an area is referenced by a special register word. Those special register words that are part of ANSI COBOL are indicated in Table 3-1 . Table 3-1. Special Register Words ----------------------------------------------------------------------------- | | | | Word | Contents | | | | ----------------------------------------------------------------------------- | | | | LINAGE-COUNTER | An unsigned number used to keep track of the | | | number of lines written to each page of a printed | | | report. It is generated for each output file | | | whose description in the DATA DIVISION contains a | | | LINAGE clause (which defines the number of lines | | | permitted per page). The register is initialized | | | to zero and then updated each time a line is | | | written with the WRITE statement in the PROCEDURE | | | DIVISION. When this value exceeds the number | | | specified by integer-1 or data-name-1 in the | | | LINAGE clause, the program skips to the next page | | | and resets the register to one. | | | | ----------------------------------------------------------------------------- | | | | DEBUG-ITEM | A data item used in support of the COBOL DEBUG | | | facility. The compiler automatically generates | | | one DEBUG-ITEM register for each program. | | | | ----------------------------------------------------------------------------- Table 3-2 lists the HP COBOL II special register words that are an HP extension to the ANSI COBOL standard. Table 3-2. Extensions to Special Register Words ----------------------------------------------------------------------------- | | | | Word | Contents | | | | ----------------------------------------------------------------------------- | | | | TALLY | A 5-digit unsigned integer typically used to store | | | information produced by the EXAMINE statement in | | | the PROCEDURE DIVISION. (This statement counts the | | | occurrences of a particular character within a | | | data item and optionally replaces all instances of | | | that character with another character.) This | | | register may also be used as a data name for an | | | unsigned numeric value with no decimal positions, | | | for instance, as a subscript. | | | | ----------------------------------------------------------------------------- | | | | CURRENT-DATE | An 8-digit alphanumeric item used only as the | | | sending field in a MOVE or DISPLAY statement in | | | the PROCEDURE DIVISION. These statements send data | | | to another field or to an output device, | | | respectively. This item is always stored in this | | | format: | | | | | | mm/dd/yy | | | | | | Here, mm indicates the month, dd indicates the day | | | of the month, and yy indicates the last two digits | | | of the year. The slash marks are automatically | | | included in the data; you need not insert them. | | | [REV BEG] | | | | | | The date and time are obtained from the software | | | clock. The date and time obtained by the COBOL | | | function CURRENT-DATE are obtained from the | | | hardware clock. See Chapter 10 for more | | | information about the COBOL function | | | CURRENT-DATE.[REV END] | | | | ----------------------------------------------------------------------------- | | | | WHEN-COMPILED | An 18-character alphanumeric item that represents | | | the date and time that the program is compiled. | | | It may be used only in MOVE and DISPLAY statements | | | of the PROCEDURE DIVISION. This field is | | | automatically stored as follows, with slash marks | | | inserted: | | | | | | mm/dd/yy__hh:mm:ss | | | | | | As in the CURRENT-DATE format, mm means current | | | month, dd means day of month, and yy indicates the | | | year. The hh:mm:ss means hours, minutes and | | | seconds, as in TIME-OF-DAY. [REV BEG] | | | | | | The date and time are obtained from the software | | | clock. The date and time obtained by the COBOL | | | function WHEN-COMPILED are obtained from the | | | hardware clock. See Chapter 10 for more | | | information about the COBOL function | | | WHEN-COMPILED.[REV END] | | | | ----------------------------------------------------------------------------- Table 3-2. Extensions to Special Register Words (cont.) -------------------------------------------------------------------------------------- | | | | Word | Contents | | | | -------------------------------------------------------------------------------------- | [REV BEG] | | | | | | RETURN-CODE | A predefined numeric data name in the PROCEDURE | | | DIVISION of a subprogram, RETURN-CODE is used to | | | pass a value back to the calling program. For | | | complete information, see "GIVING Phrase (COBOL | | | Subprograms)" in Chapter 11 .[REV END] | | | | -------------------------------------------------------------------------------------- | | | | TIME-OF-DAY | A six-character numeric item accessed only as the | | | transmitting field of a MOVE or DISPLAY statement | | | in the PROCEDURE DIVISION to access the time of | | | day. This data may be used to determine the clock | | | time required to run a COBOL program; this is done | | | by printing the contents of this register at the | | | beginning and end of the program. Remember | | | however, that clock time in a multiprogramming | | | environment is not necessarily related to the | | | central-processor time used by the program; it | | | varies according to the current mix of active | | | programs. The data is always stored in this | | | format: | | | | | | hhmmss | | | | | | hh indicates the current hour, mm the current | | | minute, and ss the current second, relative to | | | midnight. The data is unedited. However, the | | | statement DISPLAY TIME-OF-DAY results in the | | | edited format: | | | | | | hh:mm:ss | | | | -------------------------------------------------------------------------------------- Figurative Constants. Figurative constants are values that have been used so often that they have been assigned fixed data names within the COBOL language. For example, the figurative constant consisting of a string of zeros is the figurative constant ZERO. The values for figurative constants are generated automatically by the compiler. The figurative constants that you can use are shown in Table 3-3 . Singular and plural forms of these words are identical. Table 3-3. Figurative Constant Words ----------------------------------------------------------------------------- | | | | Word | Constant Value | | | | ----------------------------------------------------------------------------- | | | | ALL literal | The character string denoted by the variable | | | literal. This string may be either a nonnumeric | | | literal (as defined later in this chapter), or | | | another figurative constant (such as ZERO). If a | | | literal is used, it must be enclosed in quotation | | | marks. If a figurative constant is used, the word | | | ALL is redundant. | | | | ----------------------------------------------------------------------------- | | | | HIGH-VALUE | One or more occurrences of the character with the | | HIGH-VALUES | highest possible value in the program collating | | | sequence. The default program collating sequence | | | is the ASCII Collating Sequence. The ASCII | | | equivalent of this character is not used on the HP | | | computers, but this bit configuration is | | | equivalent to the hexadecimal character FF. (all | | | eight bits on) | | | | ----------------------------------------------------------------------------- | | | | LOW-VALUE | One or more occurrences of the character with the | | LOW-VALUES | lowest possible value in the program collating | | | sequence. This is the nonprinting character NULL. | | | The default program collating sequence is the | | | ASCII Collating Sequence. (all eight bits off) | | | | ----------------------------------------------------------------------------- | | | | QUOTE | One or more quotation marks. This constant is | | QUOTES | used to code the quotation mark as a literal in | | | statements such as MOVE QUOTES. However, the word | | | QUOTE or QUOTES cannot be used in place of an | | | explicit quotation mark (") to delimit a | | | nonnumeric literal. Thus, QUOTE ABD QUOTE cannot | | | be substituted for the nonnumeric literal "ABD". | | | | ----------------------------------------------------------------------------- | | | | SPACE | One or more spaces. | | SPACES | | | | | ----------------------------------------------------------------------------- | | | | ZERO | One or more occurrences of the digit zero. | | ZEROS | | | ZEROES | | | | | ----------------------------------------------------------------------------- | | | | [ALL] | User-defined figurative constants which are | | symbolic-character | defined using the SYMBOLIC CHARACTERS clause of | | | the ENVIRONMENT DIVISION. | | | | ----------------------------------------------------------------------------- Figurative constants are not enclosed in quotation marks or apostrophes. The number of characters for a figurative constant is determined by the size of the field to which the constant is moved or with which it is associated, as follows. 1. When the constant is associated with another data item, as in a VALUE clause or when the constant is moved to or compared with another item, the constant assumes the same length as the associated item. The string of characters represented by the constant is repeated, character by character, until the size of the resultant string equals that of the associated data item. Thus, when the constant word group ALL literal is used, the literal specified is repeated until the associated data item is filled with the value of the literal. For example, if FIELD-A is defined as a ten-character item, the statement: MOVE ALL "123" TO FIELD-A produces the following result: 1231231231 2. When the constant is not associated with some other item, as when used in a DISPLAY, STRING, UNSTRING, EXAMINE, or STOP statement, the constant assumes a length of one character or the length of the literal. A figurative constant may be referenced wherever a literal appears in a format description, except that literals restricted to numeric characters only may be replaced by the figurative constant words ZERO, ZEROS, OR ZEROES only. Use of figurative constant words is demonstrated in Table 3-4 with MOVE and STRING statements, which transmit the value of the constants referenced to the storage areas denoted by STORE-n. Table 3-4. Figurative Constants Examples ----------------------------------------------------------------------------- | | | | Example | Comment | | | | ----------------------------------------------------------------------------- | | | | MOVE QUOTES TO | Suppose STORE-1 is an area six character positions | | STORE-1 | long. When this statement is executed, STORE-1 | | | contains: | | | | | | " " " " " " | | | | ----------------------------------------------------------------------------- | | | | MOVE ALL "NEGATIVE" | Suppose STORE-2 is twelve positions long. It | | TO STORE-2 | contains: | | | | | | NEGATIVENEGA | | | | ----------------------------------------------------------------------------- | | | | MOVE SPACES TO | Suppose STORE-3 is nine positions long. It | | STORE-3 | contains all spaces. | | | | ----------------------------------------------------------------------------- | | | | STRING QUOTE "BETA" | Suppose STORE-4 is six positions long. It | | QUOTE DELIMITED BY | contains: | | SIZE INTO STORE-4 | | | | "BETA" | | | | | | Note that quotation marks delimit the literal | | | value BETA in the program. These, however, are | | | not transmitted to STORE-4. Instead, the | | | quotation marks in STORE-4 are supplied by the | | | figurative constant QUOTE. | | | | ----------------------------------------------------------------------------- Special Character Words. A special character word is a reserved word, grouping of reserved words, or character that represents an arithmetic or relational operator. These words are listed in Table 3-5 . Table 3-5. Special Character Words --------------------------------------------------------------------------------- | Arithmetic | Relational | | Operators | Operators | --------------------------------------------------------------------------------- | + | IS [NOT] GREATER THAN | | | IS [NOT] > | | - | IS [NOT] LESS THAN | | | IS [NOT] < | | * | IS [NOT] EQUAL TO | | | IS [NOT] = | | / | IS <> (<> is an HP extension to the ANSI COBOL standard.) | | | IS GREATER THAN OR EQUAL TO | | ** | IS >= | | | IS LESS THAN OR EQUAL TO | | | IS <= | --------------------------------------------------------------------------------- User-Defined Words. A user-defined word is a word that you must supply to satisfy the format of a statement or clause. Such words act as arbitrary variables that name or identify various program items. These words include such elements as program names, section names, paragraph names, and data names. In the PROCEDURE DIVISION header below, data-name-1 is a user-defined word. (In the format descriptions, all user-defined words are denoted by italic lower case letters.) PROCEDURE DIVISION [USING {data-name-1}...]. The following shows a PROCEDURE DIVISION header with the data names ALPHA, BETA, and GAMMA: PROCEDURE DIVISION USING ALPHA, BETA, GAMMA. User-defined data names, procedure names, and section names can contain up to 30 characters. These include letters (A through Z), digits (0 through 9) and the hyphen (-). Except for paragraph names, section names, segment numbers, and level numbers, all user-defined words must contain at least one alphabetic character (letter). However, user-defined words cannot begin or end with a hyphen, include an embedded space, or have the same spelling as any reserved word.
NOTE For more information on internal naming conventions, refer to "System Dependencies" in Appendix H .
In specific formats, the rules covering user-defined words may be more restrictive. Where such rules apply, they are explained in the description of the statement or clause in which the word appears. In ANSI COBOL'85, 15 types of user-defined words are permitted. These are defined in Table 3-6 . Fourteen of these word types are implemented in HP COBOL II. routine-name is not, but it is accepted by the compiler and treated as a comment. Table 3-6. User-Defined Word Types --------------------------------------------------------------------------- | | | | Word Type | Definition | | | | --------------------------------------------------------------------------- | | | | Alphabet-name | Word that identifies (names) a specific character | | | set or collating sequence to be used by the | | | program. Defined in SPECIAL-NAMES paragraph of | | | ENVIRONMENT DIVISION; used in CODE-SET clause of | | | DATA DIVISION and in COLLATING SEQUENCE phrase of | | | SORT and MERGE statements in PROCEDURE DIVISION. | | | Must also be named in the PROGRAM COLLATING | | | SEQUENCE clause of the CONFIGURATION SECTION in the | | | ENVIRONMENT DIVISION in order to specify a | | | collating sequence to be used throughout your | | | program. | | | | --------------------------------------------------------------------------- | | | | Condition-name | Word that identifies a specific value, or subset or | | | range of values, within a complete set of values | | | that a data item may assume. (This data item is | | | called a conditional variable.) It may be defined | | | in the DATA DIVISION, where the condition name is | | | preceded by the level number 88 and followed by a | | | VALUE clause. In the following example, the | | | condition names FIRST-CONST, SECOND-CONST, and | | | THIRD-CONST appear: | | | | | | 02 CONST PICTURE 99. | | | | | | 88 FIRST-CONST VALUE IS 10. | | | | | | 88 SECOND-CONST VALUE IS 20. | | | | | | 88 THIRD-CONST VALUE IS 30. | | | | | | A condition name may also appear in the | | | SPECIAL-NAMES paragraph of the ENVIRONMENT | | | DIVISION, where it is assigned to denote the status | | | of switches or as an abbreviation for specific | | | conditions. | | | | --------------------------------------------------------------------------- | | | | Data-name | Word that identifies a data item. Defined in data | | | description entries in the DATA DIVISION. Cannot be | | | subscripted, indexed, or qualified unless | | | specifically permitted by the format description in | | | which it appears. | | | | --------------------------------------------------------------------------- | | | | File-name | Word that identifies a data file. Defined in a | | | file description entry or a sort-merge file | | | description entry in DATA DIVISION. | | | | --------------------------------------------------------------------------- | | | | Index-name | Word that identifies an index associated with a | | | specific table, and used to select an item from | | | that table. Used in DATA and PROCEDURE DIVISIONs. | | | | --------------------------------------------------------------------------- Table 3-6. User-Defined Word Types (continued) --------------------------------------------------------------------------- | | | | Word Type | Definition | | | | --------------------------------------------------------------------------- | | | | Level-number | Word that indicates the position of a data item in | | | the hierarchical structure of a logical record, or | | | that indicates special properties of a data | | | description entry. Level numbers 1 through 49 | | | indicate the position in a record structure; level | | | numbers 66, 77, and 88 identify special properties. | | | In the example that appears in the condition-name | | | description above, level numbers 02 and 88 are | | | used. In single-digit level numbers, a leading | | | zero may be optionally added. Used in the DATA | | | DIVISION. | | | | --------------------------------------------------------------------------- | | | | Library-name | Word that identifies a COBOL library (containing | | | source text) used as input by the compiler during a | | | particular compilation. Used in all divisions. | | | | --------------------------------------------------------------------------- | | | | Mnemonic-name | Word equated to a name that identifies a special | | | feature of the computer system on which the program | | | is compiled or run. This relationship is | | | established in the SPECIAL-NAMES paragraph of the | | | ENVIRONMENT DIVISION. | | | | --------------------------------------------------------------------------- | | | | Paragraph-name | Word that identifies and begins a paragraph in the | | | PROCEDURE DIVISION. | | | | --------------------------------------------------------------------------- | | | | Program-name | Word that identifies a COBOL language source | | | program. Used in the IDENTIFICATION DIVISION. | | | | --------------------------------------------------------------------------- | | | | Record-name | Word that identifies a logical record in a data | | | file. Used in a record description entry in the | | | DATA DIVISION and WRITE statement in the PROCEDURE | | | DIVISION. | | | | --------------------------------------------------------------------------- | | | | Routine-name | Word that identifies a procedure written in a | | | language other than COBOL. Used in PROCEDURE | | | DIVISION in ANSI COBOL, but HP COBOL II treats it | | | as a comment. | | | | --------------------------------------------------------------------------- | | | | Section-name | Word that identifies and begins a section in the | | | PROCEDURE DIVISION. | | | | --------------------------------------------------------------------------- | | | | Segment-number | Word that classifies sections in the PROCEDURE | | | DIVISION for purposes of program segmentation. | | | Must be one of the numbers zero through 99; leading | | | zeros are optional. | | | | --------------------------------------------------------------------------- | | | | Text-name | Word that identifies text within a source library. | | | Used in all divisions. | | | | --------------------------------------------------------------------------- All user-defined words within the same program, except segment numbers and level numbers, can belong to only one of the following disjoint sets. * Alphabet names. * Condition names, data names, and record names. * File names. * Index names. * Library names. * Mnemonic names. * Paragraph names. * Program names. * Section names. * Text names. For example, if the word TEST-1 is used as a program name, it cannot also be used as a routine name. Furthermore, all such words must be unique within a disjoint set, either because no other user-defined word in the set is spelled and punctuated the same way or because uniqueness is ensured by qualification. In other words, a program cannot include two paragraphs both named PAR-A unless special qualification is made.
NOTE The general term procedure-name is often used to refer to either a section name or a paragraph name in the PROCEDURE DIVISION.
Following are examples of user-defined names: END-OF-SCHOOL-AVERAGE PAGECTR 123B System Names. This is an obsolete feature of the 1985 ANSI COBOL standard. A system name is a word that is used to define the operating environment in which the COBOL program is compiled or run. It permits communication between the program and this environment. There are two types of system names: * Computer name, used to identify the computer on which the program is to be compiled or run. This name appears in the CONFIGURATION SECTION of the ENVIRONMENT DIVISION. * Language name, used to specify the language in which the program is written. This name is used in the ENTER statement of the PROCEDURE DIVISION. In HP COBOL II, all system names are treated as comments. They appear on source program listings but do not affect compilation or execution. Nevertheless, when present, system names can only contain letters (A through Z), digits (0 through 9), or hyphens. The first character of a system name must be alphabetic and the last character in the name cannot be a hyphen. [REV BEG] Function-Names. A function-name is a word that names a function you can call from your COBOL source program. Except for CURRENT-DATE, LENGTH, RANDOM, and WHEN-COMPILED, which are already reserved words, you can use function-names in a different context as user-defined words or system-names. See Chapter 10 , "COBOL Functions," for more information about the COBOL functions.[REV END] Literals A literal is a character string that defines itself, rather than representing some other value. The value of the literal is the character string composing the literal. Literals are always constant values that cannot be changed during program execution. Because literals are self-defining, you do not define them in the DATA DIVISION. Instead, you code them directly into your program. In COBOL, two types of literals are used, numeric and nonnumeric. Numeric Literals. A numeric literal is essentially a number (numeric value) that is specified directly in a program. It is comprised of characters selected from the digits 0 through 9, the plus sign (+), the minus sign (-), and a decimal point (.). As an example, the literal 1 appears in the ADD statement below: ADD 1 TO PAGE-NUMBER. The specific value of the literal is the algebraic quantity represented by the characters that compose the literal. In the format descriptions, literals are indicated by the word literal-n. For example, literal-1 and literal-2. Every numeric literal must contain: * At least one digit. * No more than 18 digits. * No more than one arithmetic sign (+ or -). If a sign is used, it must appear as the leftmost character in the literal. If no sign is used, the literal is treated as a positive value by the compiler. * No more than one decimal point. If a decimal point is used, it may appear anywhere in the literal except as the rightmost character. (Any decimal point used as the rightmost character is interpreted as a period that terminates a sentence.) If no decimal point is used, the literal is treated as an integer.
NOTE If a character string follows the rules for the formation of a numeric literal, but is enclosed in quotation marks, it is treated by the compiler as a nonnumeric literal. (See "Nonnumeric Literals" below.) As such, it cannot be used in arithmetic operations.
Following are examples of numeric literals: 1670037627 3.415 +2 -30.06 Octal Literals. Octal literals are an HP extension to the ANSI COBOL standard. You can use octal literals in your program. Octal literals are always preceded by a percent sign (%). Following are examples of octal literals: %17 %37777777777 %456 [REV BEG]
Tip Try using the SYMBOLIC CHARACTERS clause to define constants instead of using octal literals.

CAUTION For octal literals used in VALUE clauses, it is recommended that you only use nonnumeric items or items with USAGE BINARY. For other types that are used in level 88 values, the octal literal is converted to decimal before it is used. Otherwise, no conversion is done for octal literals. When no conversion is done, the octal literal is right-justified with NULL fill. No conversion is done for octal literals in the PROCEDURE DIVISION except in arithmetic statements. You must make sure the octal literal is a valid value for the particular way you are using it. In IF statements, a nonnumeric compare is performed without conversion of the octal literals. The DISPLAY, EXAMINE, INSPECT, SEARCH ALL, STRING, and UNSTRING statements interpret the octal constants as nonnumeric literals.[REV END]
[REV BEG] Examples. The following program uses octal literals: WORKING-STORAGE SECTION. 01 ITEM-ALPHA PIC XX VALUE %40502. Octal literal is "AB". 01 ITEM-NUMERIC PIC 99 BINARY VALUE %47. Octal literal is 39. 01 ITEM-NUM PIC 99 VALUE %30462. Octal literal is ASCII 12. : DISPLAY %54131. Octal literal is "XY". DISPLAY ITEM-ALPHA. Displays "AB". DISPLAY ITEM-NUMERIC. Displays 39. DISPLAY ITEM-NUM. Displays the value 12. ADD %23 TO ITEM-NUM. Adds octal 23 (decimal 19). DISPLAY ITEM-NUM. Displays the sum, 31. When the above program runs, it displays the following: XY AB 39 12 31 See also the SYMBOLIC CHARACTERS clause in Chapter 6 , "ENVIRONMENT DIVISION."[REV END] Nonnumeric Literals. A nonnumeric literal is a character string containing letters, digits, or special characters that is coded directly into a program. It is formed by entering: * A quotation mark or apostrophe that denotes the beginning of the literal. * The character string that comprises the literal. * A matching quotation mark or apostrophe that delimits the end of the literal. A character string may be from 1 to 255 characters long (an HP extension to the ANSI COBOL standard), and may consist of any of the characters from the ASCII collating sequence. (The ANSI COBOL standard allows a maximum length of 160 characters.) See Appendix D for a list of these characters.
NOTE The delimiting quotation marks or apostrophes are not considered part of the literal. All punctuation marks within a nonnumeric literal are treated as ordinary punctuation marks, not as delimiters or separators.
Single and Double Quotation Marks in Nonnumeric Literals. You can use either quotation marks or apostrophes as delimiters. There is no restriction on which set of delimiters can be used at a given time. This allows you a great amount of freedom in forming nonnumeric literals. For example, to display the following message on your terminal screen: PLEASE ENTER "AGE UNDETERMINED" IF UNSURE You can use the following DISPLAY statement: DISPLAY 'PLEASE ENTER "AGE UNDETERMINED" IF UNSURE' As an example of invalid usage, the character string, 'I DON'T KNOW', is interpreted by the HP COBOL II compiler as being the string, 'I DON', followed by the characters, T KNOW'. In this case, a syntax error would be generated. Since you can use quotation marks and apostrophes throughout your program to delimit nonnumeric literals, the above string could be made valid by using quotation marks: DISPLAY "I DON'T KNOW" Embedded Quotation Marks in Nonnumeric Literals. You can use two consecutive quotation marks, or two consecutive apostrophes, within the characters of a nonnumeric literal to represent a single quotation mark or apostrophe. For example, the DISPLAY statement above could also have been written as follows: DISPLAY 'I DON''T KNOW' The results of executing this statement would be the following message on your terminal screen or line printer: I DON'T KNOW If you use double apostrophes in a nonnumeric literal, and the literal is bounded by quotation marks, then both apostrophes are used as part of the literal. The opposite is also true. For example: DISPLAY "DOUBLE APOSTROPHES, '', ARE PART OF THIS LITERAL" The above statement results in the following: DOUBLE APOSTROPHES, '', ARE PART OF THIS LITERAL Following is another example: DISPLAY 'DOUBLE QUOTES, "", ARE PART OF THIS LITERAL' The above statement results in the following: DOUBLE QUOTES, "", ARE PART OF THIS LITERAL Notice that the figurative constant words QUOTE and QUOTES cannot be used to supply delimiting quotation marks for nonnumeric literals. [REV BEG] For how to continue nonnumeric literals onto a second line, see "Continuation Lines" later in this chapter.[REV END] PICTURE Character Strings The PICTURE character string appears in the PICTURE clause of the DATA DIVISION. This clause describes the characteristics and editing requirements of data that is typically destined for some external output device such as a terminal or line printer. Specifically, the PICTURE clause determines the appearance of the field that is actually output by specifying: * The size of the field. * The class (type) of data that can be written into the field (alphabetic, numeric, or alphanumeric). * The appearance of a numeric sign, if any, in the field. * The position of the decimal point, if any, in the field. * The editing required to insert, suppress, or replace characters in the field. The PICTURE clause supplies currency signs, leading or trailing zeros, commas, plus or minus signs, and other punctuation stated in the PICTURE string. Often, for example, it is used to suppress leading zeros on checks, replacing them with asterisks or spaces. As an example, if the data to be printed was comprised of the digits 8765432123 and you wished to print it as a dollar value with appropriate punctuation, you could specify the following PICTURE character string in the PICTURE clause: $99,999,999.99 In this string, the "9" digits are used as special symbols to specify the character positions that are filled with numeric data. The dollar sign, commas, and decimal point indicate the positions of the punctuation characters. The PICTURE character string is superimposed on the output data so that the following information is printed: $87,654,321.23 Complete details about PICTURE character strings appear in Chapter 7 . Comment Entries This is an obsolete feature of the 1985 ANSI COBOL standard. You should use comment lines instead of comment entries. A comment entry is used in the IDENTIFICATION DIVISION to include comments or remarks in the program. These comments appear on the source program listing but do not affect program compilation or execution. They denote such items as program author, installation name, date written, date compiled, security requirements, and other general remarks. They may include any printable character from the ASCII Character Set. All comment entries are optional. When included, however, they must also conform to the rules for paragraph and sentence structure described in this manual. Comment Lines. A comment line is any line with an asterisk in the continuation indicator area (column 7) of the line. A comment line can appear anywhere in your program following the IDENTIFICATION DIVISION header. It can be made up of any combination of characters from the ASCII collating sequence, with all characters (except the asterisk in column 7) contained in columns 8 through 72 of the line. Additionally, you can use a special form of comment line to cause page ejection prior to printing the comment. This special comment line is the same as the general one described above, except you put a slash character (/) in column 7 instead of an asterisk.


MPE/iX 5.0 Documentation