[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

<>

Additional References

Examples

  1. device-name clause:


    CARD-READER IS THE-CARDS
    CONSOLE IS LOCAL-USER
    

    On Tru64 UNIX, this example allows ACCEPT and DISPLAY statements to use THE-CARDS to refer to the environment variable COBOL_CARDREADER and LOCAL-USER to refer to the environment variable COBOL_CONSOLE. <>
    On OpenVMS, this example allows ACCEPT and DISPLAY statements to use THE-CARDS to refer to the logical name COB$CARDREADER and LOCAL-USER to refer to the logical name COB$CONSOLE. <>
  2. Top-of-page-name clause:


    C01 IS STARTING-NEW-FORM
    

    The following WRITE statement causes the line to appear on the first line of a new page:


    WRITE REPORT-REC AFTER STARTING-NEW-FORM.
    
  3. SWITCH clause:


    SWITCH 1 IS FIRST-SWITCH ON IS ONE-ON OFF IS ONE-OFF
    SWITCH-4 ON FOUR-ON
    

    (Procedure Division statements can use the condition-names defined in the SWITCH clause. The SET statement can change the status of a switch.)
    The following results assume that switch 1 is on and switch 4 is off:
    Condition Truth
    Value
    IF FOUR-ON false
    IF ONE-ON true
    IF NOT ONE-OFF true
    IF ONE-ON AND NOT FOUR-ON true
  4. ALPHABET clause:


    ALPHABET EB-CONV IS EBCDIC
    

    If a file's SELECT clause contains a CODE-SET IS EB-CONV clause, this ALPHABET clause causes translation from EBCDIC to the native character set when the program reads data from the file.
  5. User-defined collating sequence:


    ALPHABET ALPH-B IS
        "A" THRU "Z"
        "9" THRU "0"
        " " ALSO "/" ALSO "\"
        ","
    

    This ALPHABET clause defines a collating sequence in which uppercase letters are lower than numeric characters. The space, slash (/), and backslash (\) characters have the same position in the collating sequence. The comma is the next higher character. It is implicitly followed by the rest of the character set.
    The following Procedure Division conditional statements show the effect of this ALPHABET clause when the OBJECT-COMPUTER paragraph contains the PROGRAM COLLATING SEQUENCE IS ALPH-B clause:
    Statements Truth
    Value
    MOVE "A" TO ITEMA.
    MOVE "9" TO ITEMB.
    IF ITEMA < ITEMB


    true
    MOVE " " TO ITEMA.
    MOVE "\" TO ITEMB.
    IF ITEMA = ITEMB AND ITEMB > "Z"


    true
    MOVE "1" TO ITEMA.
    MOVE "9" TO ITEMB.
    IF ITEMA < ITEMB


    false
  6. User-defined collating sequence with numeric literals:


    ALPHABET ALPH-C IS 128 THRU 1
    

    This clause inverts the positions of the ASCII characters.
    The following Procedure Division statements assume that the OBJECT-COMPUTER paragraph contains the SEQUENCE IS ALPH-C clause:
    Statements Truth
    Value
    MOVE "A" TO ITEMA.
    MOVE "B" TO ITEMB.
    IF ITEMA < ITEMB


    false
    MOVE "9" TO ITEMA.
    IF ITEMA < "2"

    true
    MOVE "HELLO" TO ITEMA.
    IF ITEMA > SPACES

    false
  7. SYMBOLIC CHARACTERS clause:


    SYMBOLIC CHARACTERS ESCAPE POUND DOUB-L ARE 28 36 55.
    

    The following DISPLAY statement displays the literal "Enter value" in double width on an ANSI terminal.


    DISPLAY "Enter value" ESCAPE POUND DOUB-L.
    
  8. CURRENCY SIGN clause:
    1. The following example applies to any system, and (if on Alpha or I64) regardless of whether /RESERVED_WORDS=200X is specified when the program is compiled:


      CURRENCY SIGN "G"
         .
         .
         .
      01  ITEMA  PIC X(5).
      01  ITEMB  PIC X(5).
      01  ITEMC  PIC GG,GG9.99.
      01  ITEMD  PIC ZZZ.ZZ9,99.
      01  ITEME  PIC ZZZ,.
      

      The following MOVE statements show the effect of the CURRENCY SIGN clause (the character s represents a space):
      Statement ITEMC
      Result
      MOVE 12.34 TO ITEMC sssG12.34
      MOVE 100 TO ITEMC ssG100.00
      MOVE 1000 TO ITEMC G1,000.00
    2. The following example applies only on Alpha and I64 and only if /RESERVED_WORDS=200X is specified when the program is compiled:


      CURRENCY SIGN IS "G"
      CURRENCY SIGN IS "USD" WITH PICTURE SYMBOL "U"
      CURRENCY SIGN IS "DM" WITH PICTURE SYMBOL "D"
      CURRENCY SIGN IS "M".
         .
         .
         .
      01  ITEMA  PIC GG,GG9.99.
      01  ITEMB  PIC U,UUU,UU9.99.
      01  ITEMC  PIC DD,DD9.99.
      01  ITEMD  PIC MMM,MM9.99.
      
      Statement Result
      MOVE 12.34 TO ITEMA ITEMA = sssG12.34
      MOVE 1000 TO ITEMB ITEMB = USD1,000.00
      MOVE 12.34 TO ITEMC ITEMC = ssDM12.34
      MOVE 1000 TO ITEMD ITEMD = sM1,000.00
  9. DECIMAL-POINT IS COMMA clause:


    01  ITEMA  PIC X(5).
    01  ITEMB  PIC X(5).
    01  ITEMC  PIC GG,GG9.99.
    01  ITEMD  PIC ZZZ.ZZ9,99.
    01  ITEME  PIC ZZZ,.
    

    The following MOVE statements show the effect of the DECIMAL-POINT IS COMMA clause (the character s represents a space):
    Statement ITEMD
    Result
    MOVE 1 TO ITEMD ITEMD = ssssss1,00
    MOVE 1000 TO ITEMD ITEMD = ss1.000,00
    MOVE 1,1 TO ITEMD ITEMD = ssssss1,10
    MOVE 12 TO ITEME ITEME = s12,
  10. CURSOR IS clause (Alpha, I64):


    SPECIAL-NAMES.
        CURSOR IS CURSOR-POSITION.
    
    DATA DIVISION.
    WORKING-STORAGE SECTION.
    
    01  CURSOR-POSITION.
        02  CURSOR-LINE    PIC 99.
        02  CURSOR-COL     PIC 99.
    

    In this example, the cursor's position is defined by data items containing a two-digit line number (CURSOR-LINE) and a two-digit column number (CURSOR-COL).
  11. CRT STATUS IS clause (Alpha, I64):


    SPECIAL-NAMES.
    
        SYMBOLIC CHARACTERS
            FKEY-10-VAL
        ARE 11
    
        CRT STATUS IS CRT-STATUS.
    
    DATA DIVISION.
    WORKING-STORAGE SECTION.
    
    01  CRT-STATUS.
        03 KEY1               PIC 9.
        03 KEY2               PIC X.
           88 FKEY-10         VALUE FKEY-10-VAL.
        03 FILLER             PIC X.
        .
        .
        .
        ACCEPT MENU-SCREEN.
    
        IF KEY1 EQUAL "0"
           PERFORM OPTION_CHOSEN
    
        ELSE IF KEY1 EQUAL "1" AND FKEY-10
           DISPLAY "You pressed the F10 key; exiting..." LINE 22.
    

    The first two characters (KEY1 and KEY2) constitute the code that shows the cause of termination of an ACCEPT operation. (See Table 4-1.) Note that the SPECIAL-NAMES paragraph provides for the capturing of the F10 function key. <>


Previous Next Contents Index