Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!dogie.macc.wisc.edu!decwrl!nsc!taux01!cyosta From: cyosta@taux01.UUCP ( Yossie Silverman ) Newsgroups: comp.lang.rexx Subject: Re: Spreadsheets with Rexx support? Message-ID: <2699@taux01.UUCP> Date: 10 Oct 89 07:28:10 GMT References: <8910090133.AA09674@violet.berkeley.edu> Reply-To: cyosta@taux01.UUCP ( Yossie Silverman ) Organization: National Semiconductor (IC) Ltd, Israel Lines: 186 Gee, I wrote a simple one a few weeks ago. I'll include it here, and a sample data file. Have fun. - Yossie Please, don't look to me for help in understanding it, I don't have the time to answer. Yes, I know it isn't efficient, but it does work. It is a RIGHT TO LEFT evaluation spread-sheet, each line is done seperately, cellnames are one dimensional (huh?). Anyway, the code should be pretty clear (I hope). To execute it, XEDIT the data file and type SC. ---- SC XEDIT ---- /**/ 'TOP' $._cols = 0 /* how many data columns we have */ do $._top = 0 by 1 'NEXT'; if rc /= 0 then leave 'EXTRACT /CURLINE' if left(curline.3,1) = '*' then do /* this be a column header */ i = $._cols + 1 parse var curline.3 '*' name.i width.i value.i if left(value.i,1) = '=' then do j = 1 to $._cols do forever k = find(value.i,name.j) if k = 0 then leave value.i = subword(value.i,1,k-1) 'X.'||j subword(value.i,k+1) end end $._cols = i end else leave /* setting top in the process */ end $._top = $._top + 1 $._first = $._top $._left = 1 $._cram = 0 'EXTRACT /LSCREEN' 'SET CTLCHAR ( ESCAPE' 'SET CTLCHAR h PROTECT RED' 'SET CTLCHAR l PROTECT NOHIGH' 'SET CTLCHAR e NOPROTECT HIGH' 'SET CTLCHAR v PROTECT HIGH' 'SET PF5 LEFT'; 'SET PF17 LEFT'; 'SET PF6 RIGHT'; 'SET PF18 RIGHT' 'SET PF4 CRAM'; 'SET PF16 CRAM' do forever call update 'MAKEBUF'; q = queued() 'READ ALL TAG' do i = 1 to queued()-q /* first process all RES tags */ parse pull tag value if tag = 'RES' then call res value else queue tag value end do i = 1 to queued()-q /* now process all the rest */ parse pull tag value select when tag = 'CMD' then call cmd value when tag = 'PFK' then call cmd subword(value,2) otherwise nop end end 'DROPBUF' end res: procedure expose lscreen. $. offsets. arg y x data y = y - 4 + $._first do i = $._right - 1 to $._left by -1 if offsets.i < x then leave end x = $._left + i - 1 'LOCATE :'||y||'EXTRACT /CURLINE' z = '' do i = 1 to x-1 parse var curline.3 l ';' curline.3 z = z||l||';' end parse var curline.3 ';'curline.3 'REPLACE' z||data||';'||curline.3 return cmd: procedure expose $. lscreen. parse arg cmd parms 'EXTRACT /SIZE' select when cmd = 'LEFT' then if $._left > 1 then $._left = $._left - 1 when cmd = 'RIGHT' then if $._right <= $._cols then $._left = $._left + 1 when cmd = 'CRAM' then $._cram = ^ $._cram when abbrev('FORWARD',cmd,2) then do x = $._first + lscreen.1 - 5 if (x + lscreen.1 - 5) <= size.1 then $._first = x else do x = size.1 - (lscreen.1 - 5) + 1 if x < $._top then x = $._top end $._first = x end when abbrev('BACKWARD',cmd,2) then do x = $._first - (lscreen.1 - 5) if x < $._top then x = $._top $._first = x end when cmd = 'QUIT' then do do i = 3 to lscreen.1-2 'SET RESERVED' i 'OFF' end exit end otherwise nop end return update: procedure expose lscreen. $. width. name. value. offsets. if $._cram then do w = 0; extra = 1 title = ''; entry = '' titlesep = ''; entrysep = '' end else do w = 1; extra = 3 title = '|'; entry = '|' titlesep = '(l|'; entrysep = '(l|' end do i = $._left to $._cols offsets.i = w w = w + extra + width.i if w > (lscreen.2-1) then leave title = title||'(h'||left(name.i,width.i)||titlesep if left(value.i,1) = '=' then entry = entry||'(v'||left(' ',width.i)||entrysep else entry = entry||'(e'||left(' ',width.i)||entrysep end $._right = i 'SET RESERVED 3 N' title||'(l' do i = 4 to lscreen.1-2 x = 1; e = entry||'(l' if calc(i-4+$._first) then do j = $._left to $._right-1 y = index(e,' ',x) x = verify(e,' ',,y) e = left(e,y-1)||right(x.j,x-y)||substr(e,x) end 'SET RESERVED' i 'N' e end return calc: procedure expose name. value. $._cols x. arg lineno 'LOCATE :'lineno if rc /= 0 then return 0 'EXTRACT /CURLINE' do i = 1 to $._cols parse var curline.3 x.i ';' curline.3 if x.i = '' then x.i = 0 if left(value.i,1) = '=' then interpret 'x.i' value.i end return 1 ---- SC DATA ---- * P 2 A * SIZE_1X 8 N * RESIZE_1X 8 N * CD'S_5X 8 = ( SIZE_1X + RESIZE_1X * 2 ) * 5 * 43%_SHR 8 = 0.57 * CD'S_5X * MEBES 8 N * 5X 8 = 43%_SHR + MEBES * 1X 8 = 5X / 5 D;3;-0.63;;;0.26;;; D;3;-0.63;;;0.26;;; D;3;-0.63;;;0.26;;; D; 3;-0.63;;;0.26;;; D;3;-0.63;;;0.26;;; D;3;-0.63;;;0.26;;; D;3;-0.63;;;0.26;;; D;3;-0.63;;;0.26;;; -- Yossie Silverman What did the Caspian sea? National Semiconductor Ltd. (Israel) cyosta%taux01@nsc.nsc.COM or RPR1YOS@TECHNION.BITNET NSA LSD FBI KGB PCP CIA MOSAD NUCLEAR MI5 SPY ASSASSINATE SDI -- OOLCAY ITAY