/* REXX: ALIGNTAB -- Align tabs to cols for all lines in CC range */ /* author: David McRitchie, "The REXX Macros Toolbox", 1992/07/26 */ /* There are many ways this macro could be set up. This macro will */ /* attempt to align tabs on column indicated by moving TAB and */ /* remaining tabs and data left by deleting spaces immediately left; */ /* or right by adding spaces immediately left of tab and remaining */ /* tabs and data. Text library without sequence numbers (VB 255) is */ /* recommended; otherwise data may be truncated. */ /* */ /* For each line, each tab will have to be placed. So will be */ /* somewhat CPU intensive. No tabs will be added (or deleted). */ /* lines not up to specs will be labelled .TABaa, and lines with */ /* insufficient tabs will be labelled .ERRaa Process ALL lines */ /* within range unless NX is used. */ /* */ /* e.g. ===> ALIGNTAB 10 20 30 40 50 NX .A .B */ /* The existing tabs (^) will be moved to 10 20 30 40 50 if possible*/ /* */ /* Related macros */ /* REMBLANK - removes blank columns in line range */ /* */ Address "ISREDIT"; "MACRO NOPROCESS (TOKEN)" trace c null = "" labfew=0 If token = "" then TOKEN = "10 20 30 40" token = ' '||translate(token)||' ' NX = Process('NX') INSERT = Process('INSERT') labf='';labl='';left='';right='' parse var token left ' .' labf ' ' right if labf \= '' then do; token = left right parse var token left ' .' labl ' ' right token = left right labf = '.'||labf labl = '.'||labl end else do; labf = '.ZFIRST'; labl = '.ZLAST'; end "PROCESS RANGE C" IF RC = 0 THEN DO LABF = ".ZFRANGE" LABL = ".ZLRANGE" END LABrEW = 1; LABERR = 1 AA = '', || "AAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZ", || "BABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZ", || "CACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCWCXCYCZ", || "DADBDCDDDEDFDGDHDIDJDKDLDMDNDODPDQDRDSDTDUDVDWDXDYDZ", || "EAEBECEDEEEFEGEHEIEJEKELEMENEOEPEQERESETEUEVEWEXEYEZ", || "FAFBFCFDFEFFFGFHFIFJFKFLFMFNFOFPFQ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YCYDYEYFYGYHYIYJYKYLYMYNYOYPYQYRYSYTYUYVYWYXYYYZ", || "ZAZBZCZDZEZFZGZHZIZJZKZLZMZNZOZPZQZRZSZTZUZVZWZXZYZZ" T.=''; Parse VAR TOKEN T.1 T.2 T.3 T.4 T.5 T.6 T.7 T.8 T.9 T.10 , T.11 T.12 T.13 T.14 T.15 T.16 T.17 T.18 T.19 T.20 do i = 1 to 20; if t.i \= '' then t.0 = i; end; "(LINENO) = linenum "labf "(LASTNO) = linenum "labl blanks = substr(' ',1,255) labfewx=0;laberrx=0;labfew=0 Process_CARD: savcard = card; tx=1 "(CARD) = LINE " lineno;tx = 1 "(LAB) = LABEL " lineno If substr(LAB,1,4) = '.FEW' | substr(LAB,1,4) = '.ERR' then "RESET LABEL" LAB LAB If NX = "NX" then do "(VAR075) = XSTATUS " lineno If VAR075 \= "NX" then signal ncard end Do while (TX <= t.0) I = pos('^',card) if i = 0 then do; labfewx = 1 if INSERT = "INSERT" then do if substr(card,t.tx) = '' then do jj = tx to t.0 xcard=substr(card,1,t.jj-1)||'^'||substr(card,t.jj+1) card = xcard end end signal ncard end xcard=substr(card,1,i-1)||x2c('F2')||substr(card,I+1);card=xcard l = t.tx - i if i < t.tx then do L1 = i - 1; xcard=substr(card,1,L1)||substr(blanks,1,L)||substr(card,i) card = xcard end if i > t.tx then do if substr(card,t.tx,i-t.tx)='' then do xcard = substr(card,1,t.tx-1)||substr(card,i) card = xcard end else laberrx = 1 end tx = tx + 1 end ncard: if labfewx = 1 then do; labfewx = 0; labfew = labfew + 2 "label" lineno "= .FEW"||substr(aa,labfew,2) "0" end if laberrx = 1 then do; laberrx = 0; laberr = laberr + 2 "label" lineno "= .ERR"||substr(aa,laberr,2) "0" end card = translate(card,'^',x2c('F2')) /*if card \= savcard then */ "LINE" lineno "= (CARD)" lineno = lineno + 1 if lineno <=lastno then signal PROCESS_CARD /* work in range */ null='' return null exit Process: procedure expose token arg subtoken null = '' i = pos(' '||subtoken||' ',token) if i=0 then return null tokenx = substr(token,1,I) || substr(token,I+2+length(subtoken)) token = tokenx say 'token='token', subtoken='subtoken', tokenx='tokenx return subtoken