HP OpenVMS Systems Documentation | 
	
HP COBOL
 | 
	
| 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.  | 
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
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.
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.
      DIVIDE ITEMA INTO ITEMB. ITEMB = 2.66  | 
      DIVIDE ITEMA INTO ITEMB ROUNDED. ITEMB = 2.67  | 
      DIVIDE ITEMA INTO ITEMB ITEMD = 2 GIVING ITEMD.  | 
      DIVIDE ITEMA INTO ITEMB ITEMD = 3 GIVING ITEMD ROUNDED.  | 
      DIVIDE ITEMA BY ITEMB ITEMD = 0 GIVING ITEMD.  | 
| Previous | Next | Contents | Index |