[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index


DISPLAY SRC-EXAMPLE AT LINE NUMBER 25.
DISPLAY SRC-EXAMPLE AT LINE NUMBER ITEMB.
DISPLAY SRC-EXAMPLE AT LINE NUMBER ITEMB PLUS 0.

The last DISPLAY statement illustrates that use of the PLUS option does not necessarily mean that relative positioning will always occur. When you specify line-id, absolute line positioning always occurs before a PLUS option can execute. In this case, line-id (ITEMB) is specified, and it has a value of 25. Therefore, the line position is outside the screen boundary before the PLUS option executes, and program results are undefined.
  • When there is more than one src-item, each specific src-item is displayed, after application of any phrases specific to that src-item, in order of occurrence in the DISPLAY statement.

    Formats 2 and 3

    1. On OpenVMS, control sequences from SMGTERMS.TXT are used to accomplish cursor positioning, screen erasure, and video attributes. Refer to the Support for Non-HP Terminals chapter of the OpenVMS RTL Screen Management (SMG$) Manual if you wish to customize SMGTERMS.TXT. <>

    All Formats

    1. HP COBOL parses the contents of the data being displayed to determine how they affect the terminal and the cursor position. The parsing of control sequences is performed according to the DEC STD 138-0 Registry of Control Functions for Character Imaging Devices. HP COBOL does not modify the control sequences in any way; if an invalid control sequence is found, HP COBOL does not attempt to correct the sequence.
      Therefore when you display an escape or control sequence, the entire sequence must be displayed in one operation:
      • If you use DISPLAY Format 1, the complete sequence must be contained in one or more src-items within one DISPLAY statement.
      • If you use DISPLAY Format 2, the complete sequence must be contained in one src-item.
      • If you use DISPLAY Format 3, the complete sequence must be contained within one elementary screen item.
    2. A DISPLAY statement used in an ACCEPT [NOT] ON EXCEPTION statement must be terminated (with, for example END-DISPLAY) on Alpha and I64 systems. If you are concerned with the different VAX behavior, refer to the appendix on compatibility in the HP COBOL User Manual.

    Additional References

    Examples

    In the example results, the character "s" represents a space. The examples assume a maximum screen size of 24 lines. They also assume the following Environment and Data Division entries:


    SPECIAL-NAMES.
        LINE-PRINTER IS ERR-REPORTER.
    
    01  ITEMA PIC X(6) VALUE "ITEMS ".
    01  ITEMB PIC X(8) VALUE "VALID".
    01  ITEMC PIC X(5) VALUE "TODAY".
    01  ITEMD PIC 99 VALUE 2.
    01  ITEME PIC X(10) VALUE "MONDAY".
    


                                                        RESULT:
    
    1.  DISPLAY ITEMC.                                  TODAY
    


    2.  DISPLAY ITEMD UPON ERR-REPORTER.                02
    


    3.  DISPLAY ITEMD ITEMA "ARE" ITEMB.                02ITEMSsAREVALIDsss
    


    4.  DISPLAY ITEMD  SPACE ITEMA "AREs" ITEMB.        02sITEMSsAREsVALIDsss
    


    5.  DISPLAY ITEMC "sISs" NO ADVANCING.
        DISPLAY ITEME.
        DISPLAY ITEME.
                                                        TODAYsISsMONDAYssss
                                                        MONDAYssss
    

    The following program uses Hewlett-Packard DISPLAY extensions (Format 2).


    IDENTIFICATION DIVISION.
    PROGRAM-ID. EXAMPLES.
    ENVIRONMENT DIVISION.
    DATA DIVISION.
    WORKING-STORAGE SECTION.
    01 ITEMF        COMP-1.
    01 ITEMG        COMP-2 .
    01 ITEMH        PIC S9(9) COMP VALUE IS 123456789.
    01 ITEMI        PIC S9(9) COMP-3.
    PROCEDURE DIVISION.
    01.
        MOVE 101.000000000 TO  ITEMF.
        MOVE .109999999 TO ITEMG.
        MOVE  123456789 TO ITEMI.
        DISPLAY
            ITEMF   WITH CONVERSION LINE PLUS
            ITEMG   WITH CONVERSION LINE PLUS
            ITEMH   WITH CONVERSION LINE PLUS
            ITEMI   WITH CONVERSION LINE PLUS
            .
            .
            .
    
    

    The HP COBOL User Manual contains additional examples using Hewlett-Packard extensions to the DISPLAY statement. Refer to the chapters that describe screen handling, command line variables, environment variables and logicals.

    6.8.11 DIVIDE

    Function

    The DIVIDE statement divides one or more numeric data items by another and sets the value of the data items equal to the quotient, optionally storing the remainder.


    num

    is a numeric literal or the identifier of an elementary numeric item.

    rsult

    is the identifier of an elementary numeric item or an elementary numeric edited item. However, in Format 1, rsult must be an elementary numeric item. It is the resultant identifier.

    stment

    is an imperative statement executed when a size error condition has occurred.

    stment2

    is an imperative statement executed when no size error condition has occurred.

    remaind

    is the identifier of an elementary numeric item or an elementary numeric edited item.

    General Rules

    Format 1

    1. The value of num is divided into the value of the first rsult. This quotient replaces the current value of the first rsult. The process repeats for each of the other occurrences of rsult.

    Format 2

    1. The value of the first num is divided into the value of the second. This quotient replaces the current value of each rsult.

    Format 3

    1. The value of the first num is divided by the value of the second. This quotient replaces the current value of each rsult.

    Formats 4 and 5

    1. These formats produce a remainder (remaind) from the division operation. The remainder is the result of subtracting the product of the quotient (rsult) and the divisor from the dividend.
      If rsult refers to a numeric edited item, the quotient is an equivalent unedited intermediate field. For example, if you describe rsult with the PICTURE -ZZ.99, the compiler uses an intermediate field with the implicit PICTURE S99V99.
      When the ROUNDED phrase is present, the remainder computation uses an intermediate quotient field that is truncated rather than rounded.
    2. The computation described in rule 4 determines the accuracy of remaind. It includes decimal point alignment and truncation (not rounding) required by the description of remaind.
    3. When the ON SIZE ERROR phrase is present:
      • If the size error occurs on rsult, the contents of both rsult and remaind are unchanged.
      • If the size error occurs on remaind, its contents are unchanged.

    Additional References

    Examples

    The following example shows a run-time message issued for an illegal attempt to divide by zero:


    %COB-E-DIVBY-ZER, divide by zero; execution continues
    

    Each of the examples assume the following data descriptions and initial values. The initial values are listed in the righthand column:

    INITIAL VALUES


         03  ITEMA  PIC 99V99 VALUE 9.                        9.00
         03  ITEMB  PIC 99V99 VALUE 24.                       24.00
         03  ITEMC  PIC 99V99 VALUE 8.                        8.00
         03  ITEMD  PIC 99    VALUE 12.                       12
         03  ITEME  PIC 99V99 VALUE 3.                        3.00
         03  ITEMF  PIC 99    VALUE 47.                       47
         03  ITEMG  PIC 9     VALUE 9.                        9
         03  ITEMH  PIC 9     VALUE 2.                        2
         03  ITEMI  PIC 99    VALUE 4.                        4
    

    In each of the following examples, the righthand column shows the results of the DIVIDE operation.

    1. Without GIVING phrase or rounding: RESULTS


      DIVIDE ITEMA INTO ITEMB.                          ITEMB = 2.66
      
    2. With rounding:


      DIVIDE ITEMA INTO ITEMB ROUNDED.                  ITEMB = 2.67
      
    3. GIVING phrase:


      DIVIDE ITEMA INTO ITEMB                           ITEMD = 2
        GIVING ITEMD.
      
    4. GIVING phrase with rounding:


      DIVIDE ITEMA INTO ITEMB                           ITEMD = 3
        GIVING ITEMD ROUNDED.
      
    5. BY phrase:


      DIVIDE ITEMA BY ITEMB                             ITEMD = 0
        GIVING ITEMD.
      
    6. REMAINDER phrase:


      Previous Next Contents Index