home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
164.lha
/
ARexx
/
Make_Arexx
/
rxmake
< prev
next >
Wrap
Text File
|
1988-04-28
|
5KB
|
234 lines
/* Simple MAKE routine written in ARexx */
address COMMAND
drop Src. Obj.
'list Source:*.c to ram:$$source'
'list Obj:*.o to ram:$$obj'
call open( 'source', 'ram:$$source', 'R' )
call open( 'obj', 'ram:$$obj', 'R' )
call open( 'exec', 'ram:$$comp', 'W' )
call readln( 'source' )
call getdateparms
parmresult = 1
do forever
if eof( 'source' ) then break
instring = readln( 'source' )
call getparm
if parmresult = 0 then iterate
Src. = fname
Src.sd = date
Src.st = time
gomf = 0
call seek( 'obj', 0, 'B' )
do forever
if eof( 'obj' ) then gomf = 1
if gomf then break
instring = readln( 'obj' )
call getparm
if ( compare( Src., fname ) = 0) then break
end
if gomf
then call makecomp
else do
Obj. = fname
Obj.od = date
Obj.ot = time
call chkday( compare( Src.sd, Obj.od ) )
end
end
call close( 'source' )
call close( 'obj' )
call writeln( 'exec', 'execute m:c/rlink Main' )
call close( 'exec' )
echo ''
echo 'Type...'
echo ''
echo ' execute ram:$$comp'
echo ''
echo ' ...to begin the compile and link process.'
exit
getparm:
temp = pos( '.', instring ) - 1
if temp = -1
then parmresult = 0
else do
parmresult = 1
fname = left( instring, temp )
date = subword( instring, 4, 1 )
time = subword( instring, 5, 1 )
end
return(1)
a2d:
arg string
tens = (c2d( substr(string,1,1) ) - 48) * 10
digits = (c2d( substr(string,2,1) ) - 48)
d = tens + digits
return( d )
d2a:
arg d
tens = d % 10 + 48
digits = d // 10 + 48
string = d2c(tens) || d2c(digits)
return(string)
chkday:
arg diff
if diff = 0
then call chkhrs
else call comparedates( Src.sd, Obj.od )
return(1)
chkhrs:
hours = a2d( substr(Src.st,1,2) ) - a2d( substr(Obj.ot,1,2) )
diffmin = a2d( substr(Src.st,4,2) ) - a2d( substr(Obj.ot,4,2) )
diffsec = a2d( substr(Src.st,7,2) ) - a2d( substr(Obj.ot,7,2) )
select
when hours < 0 then echo Src. 'will NOT be compiled...'
when hours > 0 then call makecomp
otherwise call chkmin( diffmin )
end
return(1)
chkmin:
arg mins
select
when mins < 0 then echo Src. 'will NOT be compiled...'
when mins > 0 then call makecomp
otherwise call chksec( diffsec )
end
return(1)
chksec:
arg secs
select
when secs < 0 then echo Src. 'will NOT be compiled...'
when secs > 0 then call makecomp
otherwise call makecomp
end
return(1)
getdateparms:
dayname.1 = 'Sunday'
dayname.2 = 'Monday'
dayname.3 = 'Tuesday'
dayname.4 = 'Wednesday'
dayname.5 = 'Thursday'
dayname.6 = 'Friday'
dayname.7 = 'Saturday'
'date >ram:$$date'
call open( 'datefile','ram:$$date','R' )
instring = readln( 'datefile' )
call close( 'datefile' )
day = subword( instring, 1, 1 )
date = subword( instring, 2, 1 )
todaysnum = dayofweek( day )
dayname.todaysnum.fullnum = date
todaysdate = a2d( date,1,2 )
call setdaydate
return(1)
setdaydate:
arg weekday
x = todaysnum
do i = 1 to 6
if x = 1
then x = 7
else x = x - 1
y = todaysdate - i
if y < 1 then say 'crossed over month!!!'
dayname.x.fullnum = d2a(y) || right(date, 7)
end
return(1)
dayofweek:
arg weekday
select
when weekday = 'SUNDAY' then datenumber = 1
when weekday = 'MONDAY' then datenumber = 2
when weekday = 'TUESDAY' then datenumber = 3
when weekday = 'WEDNESDAY' then datenumber = 4
when weekday = 'THURSDAY' then datenumber = 5
when weekday = 'FRIDAY' then datenumber = 6
when weekday = 'SATURDAY' then datenumber = 7
when weekday = 'TODAY' then datenumber = 8
when weekday = 'YESTERDAY' then datenumber = 9
otherwise datenumber = 0
end
return(datenumber)
comparedates:
arg Srcdate, Objdate
snum = dayofweek(Srcdate)
if snum = 0
then sdate = Src.date
else if snum >= 8
then do
temp = todaysnum - (snum - 8)
sdate = dayname.temp.fullnum
end
else sdate = dayname.snum.fullnum
onum = dayofweek(Objdate)
if snum = 0
then odate = Obj.date
else if snum >= 8
then do
temp = todaysnum - (onum - 8)
odate = dayname.temp.fullnum
end
else odate = dayname.onum.fullnum
call chkyear( sdate, odate )
return(diff)
chkyear:
arg s, o
if compare( right(s,2), right(o,2) )
then
do
temp1 = a2d(right(s,2)
temp2 = a2d(right(o,2)
if ( (temp1 - temp2) >= 1 )
then call makecomp
else echo Src. 'will NOT be compiled...'
end
else if compare( substr(s,4,3), substr(o,4,3) )
then say 'months are different!'
else do
temp1 = a2d(left(s,2))
temp2 = a2d(left(o,2))
if ( (temp1 - temp2) >= 1 )
then call makecomp
else echo Src. 'will NOT be compiled...'
end
return(1)
makecomp:
echo Src. 'will be compiled...'
call writeln( 'exec', 'execute m:c/rcomp ' || Src. )
return(1)