The !PHLOG() subroutine returns the name of the log record for a running phantom process.
CALL !PHLOG(name, userno)
A phantom process normally creates a log record in the $COMO file containing any output that would have gone to the screen if the command had been run in an interactive session. The name of this log record is PHn_date_time where n is the QM user number of the phantom process and date_time is the date/time at which the phantom started in the form ddmmyy_hhmmss.
The !PHLOG() subroutine allows a process to determine the name of the log record within the $COMO file for a phantom so long as the phantom is still active. If the phantom is started using the NO.LOG option of the PHANTOM command or it has terminated, name is returned as a null string.
The PHANTOM command provides a mechanism with which the logging data can be directed to an alternative location. When using this, the name returned by the !PHLOG() subroutine is formed from the logging file name and record name separated by a single space.
Because the !PHLOG() subroutine returns the log name via its first argument, it can be declared as a function as in the example below.
DEFFUN PHLOG(U) CALLING "!PHLOG"
EXECUTE "PHANTOM OVERNIGHT.REPORT" SETTING UNO
DISPLAY "Log is " : PHLOG(UNO)
Note how the SETTING clause of the EXECUTE statement is used to capture the @SYSTEM.RETURN.CODE value from the PHANTOM command. Simply using @SYSTEM.RETURN.CODE as the argument to PHLOG() would not work as this would be the return status of the EXECUTE operation, not the executed command.