TS/MP Pathsend and Server Programming Manual (G06.24+, H06.03+)

Examples
NonStop TS/MP Pathsend and Server Programming Manual132500
B-48
Pathsend Requester Example
?PAGE "GET MY NAME OR PROCESS ID"
!
! The following procedure gets my name or process id so that
! error msg text can be preceded by my process name or cpu,pin.
!
PROC who^am^i;
BEGIN
STR .spid := @my^processid '<<' 1;
! MYPID returns my cpu,pin and is input to GETCRTPID, which returns
! my^processid in this form:
! [0:2] = process name or creation timestamp
! [3].<4:7> = cpu
! [3].<8:15> = pin
CALL GETCRTPID (MYPID, my^processid);
IF spid <> "$"
THEN ! I am not a named process, convert cpu,pin for output
BEGIN
CALL NUMOUT (spid, my^processid[3].<4:7>, 10, 2);
spid[2] := ",";
CALL NUMOUT (spid[3], my^processid[3].<8:15>, 10, 3);
END;
END; ! PROC who^am^i
?PAGE "WRITE TO THE TRACE FILE"
! This procedure prefaces each trace msg with this process's
! process id, and does a waited WRITE to the trace file. The trace
! msg written depends on the function passed in.
PROC write^trace^file (function, record^number) VARIABLE;
INT function; ! what action we are tracing
INT record^number; ! input file record number (optional param)
BEGIN
INT .write^buf[0:79] := [80*[" "]];
STR .swrite^buf := @write^buf '<<' 1;
STR .sp;
STR .spid := @my^processid '<<' 1;
IF NOT $PARAM (function)
THEN ! missing required param
CALL abend^with^my^abend^msg;
IF trace^fnum <= 0
THEN ! user doesn't want to trace
RETURN;