/* FED1040: Income Tax calculations -- an incomplete example in REXX "The REXX Macros Toolbox" This is an example not complete and intended only as an example of creating a resemblance to a spreadsheet. One feature not available in a real spreadsheet is that you can see the formulas at the same time as using them. Simplified Spread Sheet, showing ENTRY, Formula, Desc, RESULT David McRitchie, April 15, 1994, Example not a complete pkg. ============================================================= Instructions to use the FED1040 macro: .... 1). Create an empty member name and place 2). Comments are indicated with an asterisk (*) in column 1. The line will not be touched by the FED1040 macro. 3). Entry values beginning in Column 1 are optional in active cards. If present they will be assigned to variable 'V'. 4). Assignment statements are not optional in active cards. Assignments should normally be placed beginning in column 11 so that they line up with other assignment statements. If column 1-11 is blank the assignment statement will be the first word picked up from col 11-59. If column 1-11 is non-blank, there being an entry value, the second word picked up from col 1-59 will be the assignment statement. Assignment statements end with a blank. Example: 1...5...10...15...20...25...30...35...40 ... 60...65...70...75...80 ----+----1----+----2----+----3----+----4 ... -6----+----7----+----8 20000.00 LN5=V INVOICED AMOUNT LN5= 20000.00 333.00 A=LN5+V A= 20333.00 .20 B=V B= .20 7 B=B*V B= 1.40 ============================================================= An example of a table for 1993 can be found in IS03.LIBR.CLIST(FEDT1993), which you can use to make a copy from into your own RACF protected dataset. .............................................................*/ address "ISREDIT";"MACRO" S=time('E') "(memberx) = member " "(dsnx) = dataset " "(ilast) = linenum .zlast" do irow = 1 to ilast; "(line) = line" irow operands = strip(substr(line,1,59)) if substr(line,1,1) = '*' then iterate irow; /*ignore comments*/ if substr(line,1,10) \= '' then do; v = word(operands,1) calc = word(operands,2) chkb = word(operands||" XX",3) end; else do; operands=strip(substr(line,11,49)); calc = word(operands,1) chkb = word(operands||" XX",2) end; if calc = "" then iterate irow; parse var calc assigned '=' drop Test = translate(word(operands,1)) if test = "NOTEV" then do note = "" do inote=2 to words(operands) note=note word(operands,inote)"="value(word(operands,inote)) end "LINE_after" irow "= NOTELINE (NOTE)" iterate irow end if test = ".ZERO" then do do inote=2 to words(operands) var=word(operands,inote) if substr(var,1,1)='.' then do i=0 to 100; zerovar=substr(var,2)||i||"=0" interpret zerovar end else do; zerovar=word(operands,inote)"=0" interpret zerovar end; end iterate irow end if test = "IF" then calc = substr(line,11) else if calc = assigned then do "(CAPS) = CAPS" "CAPS OFF" ZEDSMSG = "Calc invalid" ZEDLMSG = 'STOPPED -- Calculation at line' irow, 'is not an assigment X=formula' "LINE_BEFORE .ZFIRST = NOTELINE (ZEDLMSG)" MOREMSG = 'STOPPED -- due to errors at line' irow, ' Time of error was' time('n') "LINE_BEFORE .ZFIRST = NOTELINE (MOREMSG)" "LINE_AFTER &IROW. = NOTELINE (MOREMSG)" "LINE_AFTER &IROW. = NOTELINE (ZEDLMSG)" ADDRESS "ISPEXEC" "SETMSG MSG(ISRZ000)" "CAPS" CAPS return 4 end; interpret calc if rc \= 0 then say 'line' irow 'failure:' calc if test = "IF" then do; iterate irow end line = substr(line,1,59)||left(assigned||'=',10)||, right(value(assigned),10) "line" irow "= (line)"; if pos('+',chkb)>0 | pos('-',chkb)>0 | pos('/',chkb)>0, pos('*',chkb)>0 then do "(CAPS) = CAPS" "CAPS OFF" ZEDSMSG = "Check Calc" ZEDLMSG = 'Calculation for line' irow, 'may be incomplete, found +,-,/, or * afterwards' "LINE_BEFORE .ZFIRST = NOTELINE (ZEDLMSG)" "LINE_AFTER &IROW. = NOTELINE (ZEDLMSG)" ADDRESS "ISPEXEC" "SETMSG MSG(ISRZ000)" "CAPS" CAPS end; end; "Line_before .zf = NOTELINE ""FED1040:" time('N') TIME('E')"""" /***** May prove useful sometime *************************************/ /* ABC=123;DEF=345;LINE='LINE = ABC DEF;SAY LINE'; */ /* INTERPRET LINE */ /*********************************************************************/