/* dADD util series by Zwinx/RAGE »DaGcEnTRaL 9o²1o +46-31-775-939[0-1]« */
parse arg node;signal on error;signal on syntax;signal on ioerr;options results

nodeid = "AERexxControl"node

version = 1.21

tr=transmit;hk=getchar;pm=prompt;sendstring=sendmessage;ss=sendstring;gu=getuser

address value nodeid

DT_NAME          = 100
RETURNCOMMAND    = 136
BB_MAINLINE      = 131
DT_SLOTNUMBER    = 104
DT_RATIO         = 107
DT_SECSTATUS     = 105
UBYTES           = 117
DBYTES           = 118
UPLOADS          = 110
DOWNLOADS        = 111
BB_MAINLINE      = 131

gu DT_RATIO; RaT = result
gu BB_MAINLINE; File = result
gu UBYTES; ULBY = result
gu DBYTES; DLBY = result
gu UPLOADS; ULS = result
gu DOWNLOADS; DLS = result
gu DT_NAME; USER = result
gu BB_MAINLINE; FILE = result
gu DT_SLOTNUMBER ; SLOT=result
gu DT_SECSTATUS ; SECS=Result

CHOUR=SubStr(Time('n'),1,2)
CMIN=SubStr(Time('n'),4,2)
CSEC=SubStr(Time('n'),7,2)
Mon='JanFebMarAprMayJunJulAugSepOctNovDec'
Dajt = Translate(Date(U),'-','/');Date=SubStr(dajt,4,2)'-'SubStr(Mon,SubStr(dajt,1,2)*3-2,3)'-'SubStr(dajt,7,2)
Month=SubStr(Dajt,1,2);Day=SubStr(Dajt,4,2);Year='19'SubStr(Dajt,7,2)

Nollor='····················'

BAUD='LOCAL'

tr ''
tr '[0mThis is [0m[36md[0mADD [32mVersion [0m'version'. [36mSupport found at:'
tr '[33mDagcentral [0;1m+46-31-775-9390 16k8DS / +46-31-775-9391 28k8V34[0m'
tr ''

address command('DATE >RAM:DADD.tmp')
Open('Dn','RAM:DADD.tmp','R')
TIME=ReadLN('Dn')
Close('Dn')
TIME=Word(TIME,3);TIME=LEFT(TIME,5)

address command('LS -li BBS:NODE'NODE'/WORK >RAM:DADD.tmp')
Open('Fn','RAM:DADD.tmp','R')
do until EOF('Fn')
 Fnam=ReadLN('Fn')
 if Length(Fnam)>42 then do
  Fnam=Right(Fnam,length(Fnam)-42)
  if UPPER(Fnam)~='FILE_ID.DIZ' & exists('BBS:Node'NODE'/Work/'Fnam)then FFnam=Fnam
 end
end
Close('Fn')
Fnam=FFnam

if exists('BBS:Node'NODE'/Work/'Fnam)then do
 ss 'Appending data...'
 Open('Ud','BBS:NODE'NODE'/UDLOG','R')
 Seek('Ud',-1500,'E')
 do until EOF('Ud')
  ln=ReadLN('Ud')
  i=3
  do until i=8
   i=i+1
  if word(ln,i)='(CONNECT' then do
    BAU=word(ln,i+1)
    j=0;BAUD=''
    do until j=length(word(ln,i+1))| substr(word(ln,i+1),j,1)='/'
     j=j+1
     if substr(word(ln,i+1),j,1)~='/' then BAUD=BAUD''substr(word(ln,i+1),j,1)
    end
   end
  end
  if upper(word(ln,11))='CPS,' then do
   CPS=Word(ln,10);EFF=Word(ln,12)
  end
 end
 Close('Ud')
 If length(CPS)<5 then CPS=Left(Nollor,5-length(CPS))''CPS

 If length(EFF)<4 then EFF=Left(Nollor,4-length(EFF))''EFF

 If length(BAUD)>5 then BAUD=left(BAUD,5)
 If length(BAUD)<5 then BAUD=Left(Nollor,5-length(BAUD))''BAUD

 Open('cfg','DOORS:DADD/DADD.cfg')
 apan=ReadLN('cfg')
 Close('cfg')
 apor='';ss=1
 do until ss>length(apan)
  if substr(apan,ss,1)='~' then do
   if upper(substr(apan,ss+1,1))='B' then apor=apor''BAUD
   if upper(substr(apan,ss+1,1))='C' then apor=apor''CPS
   if upper(substr(apan,ss+1,1))='E' then apor=apor''EFF
   if upper(substr(apan,ss+1,1))='N' then apor=apor''NODE
   if upper(substr(apan,ss+1,1))='T' then apor=apor''TIME
   ss=ss+2
  end
  else do
   apor=apor''substr(apan,ss,1)
   ss=ss+1
  end
 end

 Open('Ad','BBS:Node'NODE'/Work/'Fnam,'A')
 WriteLN('Ad',apor)
 Close('Ad')
 tr 'done!'
 tr ''
end
else do
 tr 'File not available...'
 tr ''
end

SHUTDOWN
EXIT
RETURN
 
ERROR:;transmit '';transmit 'An error has occured on line #'sigl'!';transmit 'Please notify the SYSOP!';transmit '';call quit;SYNTAX:;transmit '';transmit 'A syntax error has occured on line #'sigl'!';transmit 'Please notify the SYSOP!';transmit '';call quit;IOERR:;transmit '';transmit 'An io error has occured on line #'sigl'!';transmit 'Please notify the SYSOP!';transmit '';call quit;quit:;SHUTDOWN;exit;RETURN
