/* OS/2 REXX: load complete Encyclopedia of Integer Sequences EIS */ signal on novalue name TRAP ; signal on syntax name TRAP signal on failure name TRAP ; signal on halt name TRAP signal on notready name TRAP EIS = 'c:\etc\eis\eis' ; TMP = EIS || '.tmp' YES = arg( 1 ) <> 0 ; NEW = EIS || '.new' GET = -1 ; WWW = 'www.research.att.com' TRY = '~njas/sequences/eisBTfry00000.txt' OFS = lastpos( '00', TRY ) do until GET > 99 if GET < 0 then URL = '~njas/sequences/recent.txt' else URL = overlay( right( GET, 2, 0 ), TRY, OFS ) address CMD '@if exist' NEW 'del' NEW address CMD '@CALL rxgeturl' WWW URL '>' TMP if lines( TMP ) = 0 then do say 'cannot get' URL '(' || rc || '): enter to try again' if YES then pull ; iterate end parse value linein( TMP ) with . rc . if 400 <= rc then leave TOP = 1 do while lines( TMP ) > 0 BUF = linein( TMP ) if TOP then do if strip( BUF ) = '(start)' then TOP = 0 iterate end TOP = ( strip( BUF ) = '(end)' ) if TOP then leave call lineout NEW, BUF end call lineout TMP call lineout NEW if TOP = 0 then do say 'incomplete' URL '(' || rc || '): enter to try again' if YES then pull ; iterate end TOP = EIS || right( GET, 2, 0 ) || '.txt' address CMD '@if exist' TOP 'del' TOP address CMD '@copy' NEW TOP '> /dev/nul' if rc <> 0 then do say 'copy' NEW TOP '(' || rc || '): enter to try again' if YES then pull ; iterate end say 'got' TOP ; GET = GET + 1 end call lineout TMP ; address CMD '@if exist' TMP 'del' TMP call lineout NEW ; address CMD '@if exist' NEW 'del' NEW exit 0 /* see , (c) F. Ellermann */ TRAP: /* select REXX exception handler */ call trace 'O' ; trace N /* don't trace interactive */ parse source TRAP /* source on separate line */ TRAP = x2c( 0D ) || right( '+++', 10 ) TRAP || x2c( 0D0A ) TRAP = TRAP || right( '+++', 10 ) /* = standard trace prefix */ TRAP = TRAP strip( condition( 'c' ) 'trap:' condition( 'd' )) select when wordpos( condition( 'c' ), 'ERROR FAILURE' ) > 0 then do if condition( 'd' ) > '' /* need an additional line */ then TRAP = TRAP || x2c( 0D0A ) || right( '+++', 10 ) TRAP = TRAP '(RC' rc || ')' /* any system error codes */ if condition( 'c' ) = 'FAILURE' then rc = -3 end when wordpos( condition( 'c' ), 'HALT SYNTAX' ) > 0 then do if condition( 'c' ) = 'HALT' then rc = 4 if condition( 'd' ) > '' & condition( 'd' ) <> rc then do if condition( 'd' ) <> errortext( rc ) then do TRAP = TRAP || x2c( 0D0A ) || right( '+++', 10 ) TRAP = TRAP errortext( rc ) end /* future condition( 'd' ) */ end /* may use errortext( rc ) */ else TRAP = TRAP errortext( rc ) rc = -rc /* rc < 0: REXX error code */ end when condition( 'c' ) = 'NOVALUE' then rc = -2 /* dubious */ when condition( 'c' ) = 'NOTREADY' then rc = -1 /* dubious */ otherwise /* force non-zero whole rc */ if datatype( value( 'RC' ), 'W' ) = 0 then rc = 1 if rc = 0 then rc = 1 if condition() = '' then TRAP = TRAP arg( 1 ) end /* direct: TRAP( message ) */ TRAP = TRAP || x2c( 0D0A ) || format( sigl, 6 ) signal on syntax name TRAP.SIGL /* throw syntax error 3... */ if 0 < sigl & sigl <= sourceline() /* if no handle for source */ then TRAP = TRAP '*-*' strip( sourceline( sigl )) else TRAP = TRAP '+++ (source line unavailable)' TRAP.SIGL: /* ...catch syntax error 3 */ if abbrev( right( TRAP, 2 + 6 ), x2c( 0D0A )) then do TRAP = TRAP '+++ (source line unreadable)' ; rc = -rc end select when 0 then do /* in pipes STDERR: output */ parse version TRAP.REXX . . /* REXX/Personal: \dev\con */ signal on syntax name TRAP.FAIL if TRAP.REXX = 'REXXSAA' /* fails if no more handle */ then call lineout 'STDERR' , TRAP else call lineout '\dev\con', TRAP end when 0 then do /* OS/2 PM: RxMessageBox() */ signal on syntax name TRAP.FAIL call RxMessageBox , /* fails if not in PMREXX */ translate( TRAP, ' ', x2c( 0D )), , 'CANCEL', 'WARNING' end /* replace any CR by blank */ otherwise say TRAP ; trace ?L /* interactive Label trace */ end if condition() = 'SIGNAL' then signal TRAP.EXIT TRAP.CALL: return rc /* continue after CALL ON */ TRAP.FAIL: say TRAP ; rc = 0 - rc /* force TRAP error output */ TRAP.EXIT: exit rc /* exit for any SIGNAL ON */