12 Multiple Task Programming
You may run Eloquence from the HP-UX prompt using the following syntax:
eloqcore [-b] program name [outfile] [infile] [&]
If you redirect stdout to file or pipe, Eloquence will automatically run in background mode. Specifying the
-b[ackground]
switch in the command line will put Eloquence in background mode independently of the output device.
If you execute the PRINTER IS STDOUT statement in your program, you can redirect printed output into file or pipe. The BACKGROUND function returns 1 if operating in background mode.
Example:
! SAMPLE.PROG IF BACKGROUND THEN PRINTER IS STDOUT FOR I=1 TO 10 PRINT "THIS IS LINE #";I NEXT I PRINTER IS 8 eloq SAMPLE | lp &NOTE: If run from cron, at or batch, Eloquence will operate in background mode. If output from an Eloquence program is piped to another command (for example, "eloq TEST | lp &", terminal output is automatically suppressed. The -b is thus not necessary, but the PRINTER IS STDOUT is.
The first step in this process is to define a suspend character. The suspend character is used to suspend the execution of a program so that it can be put into background. To define a suspend character, execute the following command sequence:
stty susp susp char
Replace susp char by pressing any key combination. For example, stty susp CTRL Z. The CTRL Z displays as ^Z.
Once a suspend character is defined, start the program in foreground by issuing the command:
eloqcore program name
Replace program name with the name of an Eloquence program. You do not have to specify the extension .PROG.
The next step is to switch the program to HP-UX background processing. To make this switch perform the following steps:
fg [%process number]
The optional %process number is only needed if more than one program is running in background. The process number indicates in which background process the program is running.
1000 ! RE-STORE "FG,TEST" 1010 ! This program is intended to control FG,TEST in 1020 ! background. 1030 ! 1040 ! Run eloqcore process, wait until finished 1050 ! 1060 Info$="'PASS #1'" 1070 COMMAND "!INFO="&Info$&";export INFO;eloqcore BG,TEST 2>&-" 1080 COPY "BG,TEST" 1090 ! 1100 ! Start eloqcore process, run asynchroneously 1110 ! 1120 Info$="'PASS #2'" 1130 COMMAND "!INFO="&Info$&"; export INFO;eloqcore BG,TEST </dev/null >/dev/null 2>&1 &" 1140 END 1000 ! RE-STORE "BG,TEST" 1010 ! This program is intended to run in the background 1020 ! controlled by a foreground eloquence (FG,TEST) 1030 ! 1040 ! Purge file and recreate 1050 ON ERROR GOTO E 1060 PURGE "BG,TEST" 1070 E: OFF ERROR 1080 CREATE "BG,TEST",0 1090 ASSIGN #1 TO "BG,TEST" 1100 ! 1110 ! Put some data into file 1120 PRINT #1;"DATE = "&DATE$ 1130 PRINT #1;"TIME = "&TIME$ 1140 PRINT #1;"PID = "&VAL$(PID) 1150 PRINT #1;"TASK = "&VAL$(TASKID) 1160 PRINT #1;"INFO = "&GETENV$("INFO") 1170 ! 1180 ! Do some work 1190 Start=CLOCK 1200 FOR I=1 TO 10000 1210 NEXT I 1220 Seconds=(CLOCK-Start)/1000 1230 PRINT #1;"USED = "&VAL$(Seconds) 1240 ! 1250 ! Done 1260 ASSIGN * TO #1 1270 END