skip to main content

Procedure Division Statements : SET

SET
General Format
Format 1
SET { index-name-1 } ... TO { arithmetic-expression-1 }
Format 2
SET { index-name-3 } ... {UP  } BY arithmetic-expression-3
Format 3
SET { { mnemonic-name-1 } ... TO {ON } } ...
Format 4
SET { { condition-name } ... TO {TRUE } } ...
Format 5
SET FILE-PREFIX TO File-Prefix
Format 6
SET {CONFIGURATION} { Env-Name TO Env-Value } ...
    {ENVIRONMENT  }
Format 7
Supported when the -cp compiler option is not used
SET Identifier-5 TO { HANDLE OF Identifier-6}
                    { NULL                  }
Supported only under -cp compiler option
SET Identifier-5 TO { ADDRESS OF Identifier-6}
                    { NULL                   }
Format 8
SET Result-Item TO SIZE OF Data-Item
Format 9
Supported when the -cp compiler option is not used
SET HANDLE OF Linkage-Item TO { Pointer              }
Supported only under -cp compiler option
SET ADDRESS OF Linkage-Item TO { Pointer              }
Format 10
SET {INPUT       } WINDOW TO Window-1
    {INPUT-OUTPUT}
    {I-O         }
    {OUTPUT      }
Format 11
Format 12
SET THREAD Thread-id PRIORITY TO Priority
Format 13
SET EXCEPTION {VALUE } { Exc-Value TO {CUT-SELECTION       } } ...
Format 14
SET Result-Item TO { Class:>method ( [parameters] ) }
                     ObjRef:>method ( [parameters] )
                     SELF:>method ( [parameters] )
                     SUPER:>method ( [parameters] )
Syntax rules
Format 1
1.
2.
3.
4.
5.
6.
7.
Format 3
8.
Format 4
9.
10.
Format 5
11.
Format 6
12.
13.
14.
Format 7
15.
16.
17.
 
If identifier-6 references a restricted data-pointer, either identifier-5 shall reference a data-pointer restricted to the same type or data-name-1 shall be a typed item of the type to which identifier-6 is restricted.
Format 8
18.
Format 9
19.
20.
Format 10
21.
Format 11
22.
23.
24.
Format 12
25.
26.
Format 13
27.
28.
VALUE and VALUES are synonymous.
General rules
Formats 1 and 2
1.
Format 1
2.
A.
i.
ii.
iii.
a.
b.
C.
D.
Format 2
3.
A.
B.
Format 3
4.
Format 4
5.
6.
7.
Format 5
8.
9.
 
SET ENVIRONMENT "FILE-PREFIX" TO file-prefix
Format 6
10.
11.
12.
Format 7
13.
14.
15.
Format 8
16.
Format 9
17.
18.
19.
Format 10
20.
21.
22.
Format 11
23.
Format 12
24.
25.
26.
A.
B.
C.
Format 13
A Format 13 SET statement associates the exception value specified in exc-value with an automated action that the Runtime can perform. Any keystroke, menu item, or control that produces the exc-value exception value will automatically cause the associated action to be performed.
The ITEM-HELP is commentary.
The following actions can be used in association with the current control, if it is an entry-field; otherwise, they have no effect.
Format 14
A Format 14 SET statement returns the result of a method invokation in object oriented programming.
Result-Item should be defined according to the result of the method. If the result is a string or a number, then Result-Item can be a standard COBOL data-item with picture PIC X(n) or PIC 9(n). If the result is an instance of an object, then Result-Item should be defined as OBJECT REFERENCE to that object.
SELF means the current class. It can be used in a COBOL class of type OBJECT. In a COBOL class of type FACTORY the class logical name must be used in order to reference the current class.
 IDENTIFICATION DIVISION.
 CLASS-ID. MY_OBJ AS "MyObj".
 IDENTIFICATION DIVISION.
 PROCEDURE DIVISION.
 IDENTIFICATION DIVISION.
 METHOD-ID. TEST_SELF AS "TestSelf".
 PROCEDURE DIVISION.
     SELF:>method1().
 END METHOD.
 IDENTIFICATION DIVISION.
 METHOD-ID. METHOD1 as "method1".
 PROCEDURE DIVISION.
     CONTINUE.
 END METHOD.
 END OBJECT.
 IDENTIFICATION DIVISION.
 CLASS-ID. MY_CLASS AS "MyClass".
 IDENTIFICATION DIVISION.
 PROCEDURE DIVISION.
 IDENTIFICATION DIVISION.
 METHOD-ID. TEST_SELF AS "TestSelf".
 PROCEDURE DIVISION.
     MY_CLASS:>method1().
 END METHOD.
 IDENTIFICATION DIVISION.
 METHOD-ID. METHOD1 as "method1".
 PROCEDURE DIVISION.
     CONTINUE.
 END METHOD.
 END FACTORY.
SUPER refers to the class that the current class is inheriting from, if any.
Setting Result-Item to SELF allows to retrieve the instance of the current class.
Examples
Format 1 and 2 - Set index name to specific value or increase current value
set idx-1 to 2
set idx-1 up by 4
Format 3 - Set a switch on
  switch-0 is my-switch-a
  switch-1 is my-switch-b.
procedure division.
   set my-switch-a to on.
   set my-switch-b to off.
Format 4 - Set conidition name to true/false
working-storage section.
01 customers-eof pic x.
   88 is-eof   value "Y" false "N".
01 applied-discount pic x.
   88 is-discounted value "Y" false "N".
procedure division.
  set is-eof to false.
  set is-discounted to true.
Format 5 - Set the isCOBOL file.prefix runtime property
set file-prefix to "c:/mydir1/data1;c:/mydir2/data2"
Format 6 - Set a couple of isCOBOL runtime properties
set environment "file.prefix" to "c:/mydir1/data1;c:/mydir2/data2"
set environment "array_check" to "1"
Format 7 - Get the pointer to the area of an alphanumeric variable (requires -cp compiler option)
set my-pointer to address of employee-name
Format 8 - Get the size of some items
working-storage section.
77 num-comp   pic s9(7comp-5.
77 str-var    pic x any length.
77 item-size  pic 9(4).
procedure division.
  set item-size to size of num-comp
  *> item-size value will be : 4
  move "hello world" to str-var
  set item-size to size of str-var
  *> item-size value will be : 11 
Format 9 - Set address of linkage item to address of working-storage item
working-storage section.
77 ws-par-1   pic x(10value "no param".
linkage section.
01 par-1  pic x(10).
procedure division using par-1.
   set address of par-1 to address of ws-par-1
   display par-1. *> Displays : no param
Format 10 - Activate different windows to display at them
working-storage section.
77 win-1  usage handle of window.
77 win-2  usage handle of window.
77 win-3  usage handle of window.
procedure division.
   display standard window 
           screen line 5 screen col 5 
   display independent window 
           screen line 150 screen col 500 
   display independent window 
           screen line 350 screen col 700 
   set i-o window win-2
   display "Message to Window 2" at line 10 col 20
   set i-o window win-3
   display "Message to Window 3" at line 10 col 20
   set i-o window win-1
   display "Message to Window 1" at line 10 col 20
   display message "done".
Format 11 - Sets a generic Entry-Field handle to the handle of the first field in the Screen
       working-storage section.
       77  generic-ef handle of entry-field.
       screen section.
       01  screen1.
           03 screen1-ef1 entry-field line 2 col 2.
           03 screen1-ef2 entry-field line 4 col 2.
       procedure division.
           display standard graphical window.
           display screen1.
           set generic-ef to handle of screen1-ef1.
Format 12 - Create a thread with the lowest priority
       working-storage section.
       77  th-1 handle of thread.
       procedure division.
           call thread "procedure1" handle th-1.
           set thread th-1 priority to 1.
Format 13 - Associate the key status value 1001 to the function CUT-SELECTION
        set exception value 1001 to cut-selection.
Format 14 - Invoke methods of a Java Class to get System Information
       configuration section.
       repository.
           class Sys as "java.lang.System".
       working-storage section.
       77  buffer      pic x(50).
       procedure division.
           set buffer to Sys:>getProperty("os.name")
           display "Operating System: " buffer.
           set buffer to Sys:>getProperty("os.arch")
           display "OS Architecture: " buffer.
           set buffer to Sys:>getProperty("java.version")
           display "Java Version: " buffer.

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left