2

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?

jguilhermemv
  • 769
  • 3
  • 11
  • 28

2 Answers2

4

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.

JerryTheGreek
  • 160
  • 2
  • 7
  • Thank you for the additional background. One thing to know is that this is *not COBOL* but an Unisys extension, as noted aboce. – Simon Sobisch Dec 09 '19 at 17:55
  • 1
    Just a note: this is not a "common" extension to COBOL74, for example the "VAX-11 COBOL-74 Language Reference Manual" does not reference anything like this. – Simon Sobisch Dec 09 '19 at 18:01
1

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)".

Simon Sobisch
  • 6,263
  • 1
  • 18
  • 38