home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
prgramer
/
rexx
/
rdebug
/
rpp.kex
< prev
next >
Wrap
Text File
|
1993-03-25
|
3KB
|
124 lines
/*H* RPP.KEX 02-10-93 14:07*/
/* test seperately
signal on error
signal on halt
signal on syntax
*/
Parse source sys .
if sys='OS/2' then sys='OS2'
else if sys='PCDOS' then sys='DOS'
if (sys='DOS') + (sys='OS2')>0 then pc?=1
trace o?r
me='rPP'
If arg(1)='?' Then Exit tell(me)
Arg num tab test .
if pc? then c=''
else c='COMMAND'
c 'EXTRACT /FN/LINE/SIZE/FT/LINEND/AUTOSAVE/MSGMODE'
c 'SET AUTOSAVE OFF'
/*c 'SET MSGMODE OFF'*/
c 'MSGLINE ON 3 12 OVERLAY'
c 'SET LINEND OFF'
If line.1=0 Then Do
'+1'
line.1=1; End
If (num='')+(num='*')>0 Then num=size.1-line.1+1
If size.1<line.1+num Then num=size.1-line.1+1
If datatype('0'num,'w') Then Nop
Else Exit msg(me,10,'Invalid number:' num)
If tab='' Then tab=2
/*
Do level=1 Until substr(curline.3,tab*level,tab)<>copies(' ',tab)
c 'EXTRACT /curline'
If words(curline.3)=0 Then '+1'
End
*/
c 'EXTRACT /curline'
Parse Var curline.3 word .
level=pos(word,curline.3)
if level>0 then level=(level)%tab
'-1'
select
When test <> '' Then Call test /* To test: rpp * 2 tttt */
When ftype.1 = 'BAT' Then Call bat_format
When ftype.1 = 'C' Then Call c_format
When ftype.1 = 'H' Then Call c_format
When ftype.1 = 'COBOL' Then Call cobol_format
otherwise Call rexx_format
end
c 'SET AUTOSAVE' autosave.1
':'line.1 c 'SET LINEND' linend.1
Return
REXX_FORMAT:
xend=' END '; xdo=' DO '; xselect=' SELECT ';
swthen=0
Do num Until rc<>0
'+1 COMMAND EXTRACT /CURLINE'
str=translate(curline.3,' ',';/')
Parse Upper Var str wd1 wd2 rest
level=level-(wd1=xend)
If ((right(wd1,1)=':') + (level<1)) >0 Then level=1
string=copies(' ',tab*level-2)''strip(curline.3)
c 'REPLACE' string
If '!'string<>'!'curline.3 Then c 'REFRESH'
level=level-(pos(xend,' 'wd2 rest' ')>0)+(pos(xdo,' 'wd1 wd2 rest' ')>0)
level=level+(wd1=xselect)
If ((right(wd1,1)=':')+ (right(wd2,1)=':'))>0 Then level=1
End;
Return
/*WORDFULL:*/
/* used because wordpos() doesn't work properly*/
/*
trace o?r
arg needle, haystack
needle=' 'strip(needle)' '
i=wordpos(needle,' 'haystack' ')
if i>0 then do
j=pos(needle,' 'haystack' ')
if j=0 then i=0
end
return i
*/
C_FORMAT:
Do num Until rc<>0
'+1 COMMAND EXTRACT /CURLINE'
str=translate(curline.3,' ','09'x)
Parse Upper Var str wd1 wd2 rest
If pos('}',str)>0 & pos('{',str)=0 Then level = level-1
If level<1 Then level=1
string=copies(' ',tab*level-1)''strip(str)
c 'REPLACE' string
If '!'string<>'!'curline.3 Then c 'REFRESH'
If pos('{',str)>0 & pos('}',str)=0 Then level = level+1
End;
Return
BAT_FORMAT:
n=1
trace o?r
if level=0 then level=1
n=num
Do num=1 to num Until rc<>0
'+1' c 'EXTRACT /CURLINE'
str=translate(curline.3,' ','09'x)
Parse Upper Var str wd1 wd2 rest
uppstr=wd1 wd2 rest
If (pos(' IF ',' 'uppstr' ')>0 & pos(' GOTO ',' 'uppstr' ')>0) Then do
if num=n+1 then level=level-1; end
If left(wd1,1)=':' Then level = 1
If level < 1 Then level = 1
string=copies(' ',tab*level-2)''strip(str)
c 'REPLACE' string
If '!'string<>'!'curline.3 Then c 'REFRESH'
If (pos(' IF ',' 'uppstr' ')>0 & pos(' GOTO ',' 'uppstr' ')>0) Then do
if num>=n+1 then level=level+1
n=num; end
If left(wd1,1)=':' Then level = 2
End;
Return