Search code examples
cobolgnucobolcobol85

COBOL - Understanding SET MYSELF


In my COBOL program I have the following statement:

SET MYSELF (STATUS) TO -1. 

What this statement does? I don't understand the MYSELF and STATUS words. It seems that the it gives the status parameter the value -1, am I right? What MYSELF means?


Solution

  • MYSELF is a reserved word that enables a compiler-supplied task item to refer to the attributes of its own process. So you are setting STATUS in your own process to -1.

    COBOL ANSI-74 Programming Reference Manual (PDF Link)

    The reserved word MYSELF is a compiler-supplied task item that enables a program to access its own task attributes. Thus, any attribute of a given task can be referenced within that task as ATTRIBUTE attribute-name OF MYSELF.

    For example, CHANGE ATTRIBUTE DECLAREDPRIORITY OF MYSELF TO 90. CHANGE ATTRIBUTE DECLAREDPRIORITY OF ATTRIBUTE PARTNER OF MYSELF TO 65.

    The second example illustrates another task running with a task that you are running. The PARTNER attribute refers to the other task and the example changes the DECLAREDPRIORITY of the other task.