/* * This ARexx script does a demo of LogProc. It may be used as a model for * doing logging from your own scripts. */ options results /* this is needed to get results from the 'show' command */ if ~show('Libraries','rexxsupport.library') then , call addlib('rexxsupport.library',0,-30,0) /* start up LogProc if its not already running */ if showlist('Ports', "LOGPROC")=0 then do address command "run >nil: logproc" do while showlist('Ports', "LOGPROC")=0 say "Waiting for Log proc" call delay 5 /* if you have WaitForPort, you can use: 'waitforport "LOGPROC"' */ end say "LogProc has been launched" end address 'LOGPROC' 'OpenLog big w raw:0/0/600/100/MAIN LOG WINDOW/inactive' address 'LOGPROC' 'OpenLog file f t:test.log' address 'LOGPROC' 'AddLogGroup main big file' address 'LOGPROC' 'Putlog main ---> This is a demo of LogProc.' call delay(50) LF = d2c(10) /* linefeed */ address 'LOGPROC' 'PutLog main' LF '-- We first open some windows.' address 'LOGPROC' 'OpenLog a1 w raw:0/100/200/50/a1/inactive' address 'LOGPROC' 'OpenLog a2 w raw:200/100/200/50/a2/inactive/auto' address 'LOGPROC' 'OpenLog a3 w raw:400/100/200/50/a3/inactive' address 'LOGPROC' 'OpenLog a4 w raw:0/150/200/50/a4/inactive' address 'LOGPROC' 'OpenLog a5 w raw:200/150/200/50/a5/inactive/auto/wait' address 'LOGPROC' 'OpenLog a6 w raw:400/150/200/50/a6/inactive' address 'LOGPROC' 'AddLogGroup all a1 a2 a3 a4 a5 a6' address 'LOGPROC' 'AddLogGroup odd a1 a3 a5 ' address 'LOGPROC' 'AddLogGroup even a2 a4 a6 file' address 'LOGPROC' 'AddLogGroup prime a2 a3 a5' address 'LOGPROC' 'AddLogGroup comp a4 a6' address 'LOGPROC' call delay(75) 'show L' 'putlog main --> We have opened the following logs:' result 'show G' 'putlog main --> We have defined these log groups:' result 'exists G prime' if RC ~= 0 then do 'show L prime' 'putlog main Log group "prime", for example,' , 'contains the following logs:' result end call delay(150) 'putlog main x-x-x windows a2 and a5 were opened with the /AUTO switch...' 'putlog main x-x-x they will open when written to.' call delay(120) "putlog main" LF "=-= Let's write to some of the logs =-=" call delay(50) 'putlog all We are all here' call delay(100) 'putlog prime 2 3 and 5 are primes' 'putlog even 2 4 and 6 are even' 'putlog odd 1 3 and 5 are odd' address 'LOGPROC' 'FlushLog even' address 'LOGPROC' 'RemLogGroup even a6' address 'LOGPROC' 'Putlog even =====> DONE <======' address 'LOGPROC' 'putlog main Will remove windows a4 and a6 in 5 seconds...' call delay(250) 'closelog a6 a4' "putlog Nonexistent There is no harm in logging to non-existent log groups" "putlog main LogProc can also position text in windows..." call delay(120) 'PutLine main @1C @U@RText attributes may be set using the command @BPutLine' /* clear lines 2 - 8 of main (write a single blank) and write to line 3 */ 'putline main @2 @4 @5 @6 @7 @8 @3L @FLeft Justification is supported' 'putline main @3RK Right justification is easy' call delay(120) "putline main @4 @5L ...Let's change the background @c3color@c0 in some windows..." 'putline odd @4K @b3' call delay(100) 'OpenLog a4 w raw:0/150/200/50/Status/inactive' 'OpenLog a6 w raw:400/150/200/50/Status Demo/inactive' 'AddLogGroup stat1 a4' 'AddLogGroup stat a4 a6' addr = 'pete@home' 'PutLine stat &1C &U&BCalling&P&I' addr call delay(50) 'PutLine stat &2C &BDialing' call delay(100) 'PutLine stat 2C Connected' call delay(50) 'PutLine stat1 @3R @B14400@P bps@3,1,10 Knocking' call delay(100) 'PutLine stat1 3,1,10 Answered' call delay(100) 'PutLine stat1 3,1,10 Outbound' call delay(50) 'putline stat1 @4L Sending: @Iimagin.ary' call delay(100) 'PutLine stat1 &4 &3,1,10 Inbound' call delay(50) 'putline stat1 &4L Receiving: &Ino.thing' call delay(100) 'Putline stat1 @4 @3,1,10 Hang up' call delay(100) 'PutLine stat @2C Disconnected @3 ' call delay(100) 'PutLine stat @1C @BWaiting @2 ' call delay(50) "Putline main 9 It's" time()".", "Why not try out a few LogProc commands yourself?" 'PutLine stat @1C @BQuiting' call delay(50) 'closelog a4 a5 a6' 'Putlog all Try it!' options prompt 'Try a logproc command ( to quit) ==> ' do forever parse pull myline if length(myline) = 0 then leave address 'LOGPROC' myline end 'putlog all Bye Bye ...' call delay(50) address 'LOGPROC' 'abort' /* As an alternative to the above 'ABORT' command, which closes all logs and * frees all resources, you could close the logs and log groups individually. * Here is an example of how you might do that, as well as an illustration * of the 'Exists' command: */ /* 'CloseLog big file a1 a2' 'Exists L a3' if RC ~= 0 then do say "Log window a3 still exists... let's close it" 'CloseLog a3' end 'show L' say 'The only existing logs are:' result 'show G' say 'The only existing log groups are:' result */