1/* REXX example. */ 2 3/* Some basic constructs. */ 4almost_pi = 0.1415 + 3 5if almost_pi < 3 then 6 say 'huh?' 7else do 8 say 'almost_pi=' almost_pi || " - ok" 9end 10x = '"' || "'" || '''' || """" /* quotes */ 11 12/* A comment 13 * spawning multiple 14 lines. /* / */ 15 16/* Built-in functions. */ 17line = 'line containing some short text' 18say WordPos(line, 'some') 19say Word(line, 4) 20 21/* Labels and procedures. */ 22some_label : 23 24divide: procedure 25 parse arg some other 26 return some / other 27 28call divide(5, 2) 29 30/* Loops */ 31do i = 1 to 5 32 do j = -3 to -9 by -3 33 say i '+' j '=' i + j 34 end j 35end i 36 37do forever 38 leave 39end 40 41/* Print a text file on MVS. */ 42ADDRESS TSO 43"ALLOC F(TEXTFILE) DSN('some.text.dsn') SHR REU" 44"EXECIO * DISKR TEXTFILE ( FINIS STEM LINES." 45"FREE F(TEXTFILE)" 46I = 1 47DO WHILE I <= LINES.0 48 SAY ' LINE ' I ' : ' LINES.I 49 I = I + 1 50END 51