COBOL - Understanding SET MYSELF

259 Views Asked by At

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?

2

There are 2 best solutions below

2
On BEST ANSWER

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.

0
On

In a "plain" COBOL program this statement would not be valid. MYSELF would be an entry below an OCCURS (a "table cell") and STATUS would be the index to use (= a numeric variable).

But as the SET statement can only ("standard COBOL") adjust variables of type POINTER or INDEX and both cannot be set to be negative this statement would normally be invalid.

There are some implementations where you can use SET to adjust any numeric variable (where the -1 would be valid if the target is a signed variable), but as @JerryTheGreek pointed out it looks to be NO COBOL but the "Task-Attribute Identifiers (Extension to ANSI X3.23-1974 COBOL)".