Here's an overview of a way to make external functions like this run a little faster if you really need to keep them external.
When your program starts, create a message port that'll be used by the external routines to return their data. Then each external function would open its own message port and wait for a packet. When a message arrives at the external function's message port, run your function and return the data to the main program's message port.
Here's an example. Start TimeStampServer.rexx, then start TimeStampMain.rexx.
You'll get output something like this:
00.01.49.06
00.01.49.08
00.01.49.10
00.01.49.12
00.01.49.12
Hope it helps.
-- Begin file TimeStampMain.rexx --
/* Time Stamp Main */
DO FOR 5
PortHandle = OPENPORT('TIMESERVERREPLYPORT');
ADDRESS 'TIMESERVER' 'GETTIME'
CALL WAITPKT('TIMESERVERREPLYPORT')
Packet = GETPKT('TIMESERVERREPLYPORT')
Output = GETARG(Packet)
CALL REPLY(Packet, 0)
CALL CLOSEPORT('TIMESERVERREPLYPORT')
SAY Output
END
-- End file TimeStamp.rexx --
-- Begin file TimeStampServer.rexx --
/* Time Stamp Server */
PortHandle = OPENPORT('TIMESERVER')
CALL TIME('RESET')
DO UNTIL UPPER(Status) = 'QUIT'
CALL WAITPKT('TIMESERVER')
Packet = GETPKT('TIMESERVER')
IF Packet ~= NULL() THEN
DO
Status = GETARG(Packet)
CALL REPLY(Packet, 0)
IF UPPER(Status) = 'GETTIME' THEN
DO
TimeValue = TIME('ELAPSED')
Seconds = TimeValue // 60
Minutes = (TimeValue % 60)
Hours = Minutes % 60
Minutes = Minutes // 60
TimeValue = RIGHT(Hours, 2, '0') || '.' ||,
RIGHT(Minutes, 2, '0') || '.' ||,
RIGHT(TRUNC(Seconds, 2), 5, '0')
ADDRESS 'TIMESERVERREPLYPORT' TimeValue
END
END
END
CALL CLOSEPORT('TIMESERVER')
-- End file TimeStampServer.rexx --