Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -0,0 +1,6 @@
( LOOP
= out$"Hi again!"
& !LOOP
)
& out$Hi!
& !LOOP

View file

@ -26,3 +26,4 @@ GO TO
statement.
It can also be used to transfer control to any one of an array of
labelled statements. (This form is superseded by SELECT, above.)
[GO TO can also be spelled as GOTO].

View file

@ -1,3 +1,11 @@
exit
exit expression
call routineName /*no arguments passed to routine.*/
call routineName 50 /*one argument (fifty) passed. */
call routineName 50,60 /*two arguments passed. */
call routineName 50, 60 /*(same as above) */
call routineName 50 ,60 /*(same as above) */
call routineName 10*5 , 8**4 - 4 /*(same as above) */
call routineName 50 , , , 70 /*4 args passed, 2nd&3rd omitted.*/
/*omitted args are NOT null. */
call routineName ,,,,,,,,,,,,,,,,800 /*17 args passed, 16 omitted. */
call date /*looks for DATE internally first*/
call 'DATE' /* " " " BIF | externally*/

View file

@ -0,0 +1,22 @@
...
prod=1
a=7 /*or somesuch.*/
b=3 /* likewise. */
op='**' /*or whatever.*/
...
select
when op=='+' then r=a+b /*add. */
when op=='-' then r=a-b /*subtract. */
when op=='' then do; r=a*b; prod=prod*r; end /*multiply.*/
when op=='*' then r=a*b /*multiply. */
when op=='**' then r=a**b /*power (exponentiation) */
when op=='/' & b\=0 then r=a/b /*divide. */
when op=='%' & b\=0 then r=a/b /*interger divide. */
when op=='//' & b\=0 then r=a/b /*modulus (remainder). */
when op=='||' then r=a||b /*concatenation. */
when op=='caw' then r=xyz(a,b) /*call the XYZ subroutine*/
otherwise r='[n/a]' /*signify not applicable.*/
end /*select*/
say 'result for' a op b "=" r

View file

@ -0,0 +1,33 @@
...
signal on error
signal on failure
signal on halt
signal on lostdigits /*newer REXXes.*/
signal on notready
signal on novalue
signal on syntax
signal off error
signal off failure
signal off halt
signal off lostdigits /*newer REXXes.*/
signal off notready
signal off novalue
signal off syntax
...
signal on novalue
...
x=oopsay+1 /* ◄─── this is it.*/
exit
novalue: say
say 'error!'
say 'that reference to oopsay (above) will cause control to get here.'
parse source . . fid .
say; say 'REXX raised a NOVALUE error in program:' fid
say; say 'it occurred on line' sigl
say; say 'the REXX statement is:' /*put it on separate line.*/
say sourceline(sigl)
say; say 'which code:' condition('C') "error"
say; say 'REXX variable:' condition('D')
say; say "Moral: shouldn't do that."

View file

@ -1,3 +1,13 @@
return
return expression
numeric digits 1000 /*prepare for some gihugeic numbers.*/
...
n=4
call factorial n
say n'!=' result
exit
/*──────────────────────────────────FACTORIAL subroutine────────────────*/
factorial: parse arg x
!=1
do j=2 to x
!=!*j
end /*j*/
return !

View file

@ -1,32 +1,3 @@
signal on error
signal on failure
signal on halt
signal on lostdigits
signal on notready
signal on novalue
signal on syntax
exit
signal off error
signal off failure
signal off halt
signal off lostdigits
signal off notready
signal off novalue
signal off syntax
...
signal on novalue
...
x=oopsay+1
...
novalue: say
say '*** error! ***'
say
say 'undefined REXX variable' condition("D")
say
say 'in line' sigl
say
say 'REXX source statement is:'
say sourceline(sigl)
say
exit 13
...
exit expression

View file

@ -1,20 +1,12 @@
do j=1 to 10
say 'j=' j
if j>5 then leave
say 'negative j=' -j
end
say 'end of the DO loop for j.'
numeric digits 1000 /*prepare for some gihugeic numbers.*/
...
ouch=60
sum=0
do k=0 to 100 by 3
say 'k=' k
do m=1 to k
if m=ouch then leave k
sum=sum+m
end
end
say 'sum=' sum
n=4
say n'!=' factorial(n)
exit
/*──────────────────────────────────FACTORIAL subroutine────────────────*/
factorial: parse arg x
!=1
do j=2 to x
!=!*j
end /*j*/
return !

View file

@ -1,22 +1,18 @@
sum=0
do j=1 to 1000
if j//3==0 | j//7==0 then iterate
sum=sum+j
end
do j=1 to 1000
if j//3==0 | j//7==0 then iterate
sum=sum+j
end /*j*/
/*shows sum of 1k numbers except those divisible by 3 or 7.*/
say 'sum='sum
...
numeric digits 5000
prod=0
do k=1 to 2000
do m=1 to k
if m>99 then iterate k
prod=prod*m
end
end
do k=1 to 2000
do m=1 to k
if m>99 then iterate k
prod=prod*m
end /*m*/
end /*k*/
say 'prod=' prod

View file

@ -1,16 +1,18 @@
numeric digits 1000 /*prepare for some gihugeic numbers.*/
...
n=4
call factorial n
say n'!=' result
exit
do j=1 to 10
say 'j=' j
if j>5 then leave
say 'negative j=' (-j)
end /*j*/
say 'end of the DO loop for j.'
factorial: parse arg x
!=1
do j=2 to x
!=!*j
end
return !
ouch=60
sum=0
do k=0 to 100 by 3
say 'k=' k
do m=1 to k
if m=ouch then leave k
sum=sum+m
end /*m*/
end /*k*/
say 'sum=' sum

View file

@ -1,21 +1,32 @@
...
prod=1
a=7 /*or somesuch.*/
b=3 /* likewise. */
op='**' /*or whatever.*/
signal on syntax
...
select
when op=='+' then r=a+b /*add. */
when op=='-' then r=a-b /*subtract. */
when op=='*' then do; r=a*b; prod=prod*r; end /*multiply.*/
when op=='*' then r=a*b /*multiply. */
when op=='/' & b\=0 then r=a/b /*divide. */
when op=='%' & b\=0 then r=a/b /*interger divide. */
when op=='//' & b\=0 then r=a/b /*modulus (remainder). */
when op=='||' then r=a||b /*concatenation. */
when op=='caw' then r=xyz(a,b) /*call the XYZ subroutine*/
otherwise r='[n/a]' /*signify not applicable.*/
end
y=4 - 4
x=66
say x/y /*divide x by y.*/
say "yup, that's a divide by zero, by gum."
exit
say 'result for' a op b "=" r
syntax: say
/* We can now possibly do some repair work , but most people trap */
/* the condition, display where it happened, the REXX sourceline */
/* (the actual REXX statement), which condition was triggered, */
/* display any other pertinent REXX variables, which line in the */
/* REXX program, and then (usually) exit with some kind of error */
/* message and error code indicator. */
/* Note: the "name" of the REXX program isn't quite accurate, */
/* rather, it is the name that was invoked (called by), which may */
/* be different name than the actual program being executed. */
say 'error!'
say 'that division (above) will cause control to get here.'
parse source . . fid .
say; say 'REXX raised a SYNTAX error in program:' fid
say; say 'it occurred on line' sigl
say; say 'the REXX statement is:' /*put it on separate line.*/
say sourceline(sigl)
say; say 'which code:' condition('C') "error"
say; say 'error code:' condition('D')
say; say "Moral: don't do that."
exit 13

View file

@ -0,0 +1,7 @@
Say 'Interrupt this program after a short while'
Call on halt
Do i=1 To 10000000
j=i**2+1
End
halt: Say i j
Return

View file

@ -0,0 +1,3 @@
return
return expression