Running Acu Extend 9.1 & 9.2 on Windows.
This is probably an easy question but I could not find the answer in the documentation. Is there a way to get the PROGRAM-ID of the currently running program? I know about C$CALLEDBY, which won't work in this case, as we have a copybook that is used in many programs, and want to log when specific actions are done, and need to know which program is running.
Is there something similar to C$CALLEDBY to give the value of the PROGRAM-ID of the current program?
Thanks
Tony
There is nothing in the ACUCOBOL-GT runtime to give the name of the currently running program. Though I still think C$CALLEDBY is what you want.
If you create a small logging program, WRITELOG (for example), you can call it to write a log message. THAT subprogram can call C$CALLEDBY to figure out who called it, which is the name of the program that wants to write the log message. For example, consider the following programs:
identification division.
program-id. testit.
data division.
working-storage section.
01 log-message pic x(80).
procedure division.
main-pgh.
move "This is a log message" to log-message
call "writelog" using log-message
stop run
.
And then writelog:
identification division.
program-id. writelog.
data division.
working-storage section.
01 my-caller-name pic x(40).
linkage section.
01 log-message pic x(80).
procedure division using log-message.
main-pgh.
call "C$CALLEDBY" using my-caller-name
display message box log-message title my-caller-name
exit program
stop run
.
This small sample shows a message box with a title of testit, and the text "This is a log message". Which I believe is what you want?
There is nothing in the ACUCOBOL-GT runtime to give the name of the currently running program. Though I still think C$CALLEDBY is what you want.
If you create a small logging program, WRITELOG (for example), you can call it to write a log message. THAT subprogram can call C$CALLEDBY to figure out who called it, which is the name of the program that wants to write the log message. For example, consider the following programs:
identification division.
program-id. testit.
data division.
working-storage section.
01 log-message pic x(80).
procedure division.
main-pgh.
move "This is a log message" to log-message
call "writelog" using log-message
stop run
.
And then writelog:
identification division.
program-id. writelog.
data division.
working-storage section.
01 my-caller-name pic x(40).
linkage section.
01 log-message pic x(80).
procedure division using log-message.
main-pgh.
call "C$CALLEDBY" using my-caller-name
display message box log-message title my-caller-name
exit program
stop run
.
This small sample shows a message box with a title of testit, and the text "This is a log message". Which I believe is what you want?
Thanks for the reply - yes, your approach will indeed work, I had not thought of that simple approach!