/* Optimized with RexxOpt 1.8 */
arg argt;Version='1.51';CFGFile='';if argt='TR' then trace 'all';             else;do;               trace 'b';               if argt~='TC' then CFGFile=argt;               end;em='';call addlib('rexxsupport.library',0,-30);call addlib('rexxarplib.library',0,-30);signal on syntax;nport  = 'NBAR';nporti = 'NBAR.1';cport = nport'CTL';if showlist('p',cport) then call exit(cport);cporti = nporti'CTL';if showlist('p',cporti) then call exit(cporti);jf='01/01/97 31/03/97 01/05/97 08/05/97 19/05/97 14/07/97 15/08/97 01/11/97 11/11/97 25/11/97';t.1.1 = 180;t.1.2 = 270;t.1.3 = 360;t.1.4 = 540;t.2.1 =  45;t.2.2 =  64;t.2.3 =  90;t.2.4 = 128;t.3.1 =  24;t.3.2 =  34;t.3.3 =  48;t.3.4 =  68;t.4.1 =  22.5;t.4.2 =  32;t.4.3 =  45;t.4.4 =  64;wx  = 0;wy  = 0;wix = 0;wiy = 0;zmo = 0;winfo=0;infoc=0;wfront=0;colc  = 3;colnc = 1;cola  = 7;alerte= 0;SMiami= '';logfile = '';Mlogfile = '';ZTarif=1;JDCM='01';CUHT=0.615;Mailer='';Smailer='';AutoMail=0;CNMail ='';GadMail=0;CnxMail=0;Newser='';GadNews=0;CnxNews=0;GTCParg='';TVA=1.206;RT=1;blanks = 2;ychar  = 8;lgmes  = 33;Blkmes = right('',lgmes,' ');nbi = 2;open('input','env:sys/font.prefs','r');w = readln('input');tfg=C2D(substr(w,224,1));tft=C2D(substr(w,388,1));call close 'input';yoff=tft+4;yoffg=yoff+2;smx = 81;smy = ((tft-8)%2);if smy<0 then smy=0;ssx = 12;ssy = yoffg;sux = ssx+23;suy = yoffg;sbx = sux+46;sby = yoffg;sox = sbx+180;soy = yoffg;swx = sox+102;swy = yoffg;sgx = sox+100;sbrx = sbx+12;if cfgfile='' then cfgfile='s:NBAR.cfg';wwmax = screencols('Workbench');ww=sgx;nog=0;noi=0;cl=2;TSN='';w = open('input',cfgfile,'r');if w=1 then;do;  w = readln('input');  w = readln('input');;do while ~eof('input');    w = readln('input');    cl=cl+1;    em='Erreur dans fichier NBAR.cfg en ligne '||cl;    if word(w,1)='Gadget' then;do;       if words(w)<4 then;do;          em='Erreur Dfinition Gadget '||nog+1;          call syntax;          end;          else;do;          nog=nog+1;          GName.nog=word(w,3);          GAction.nog=subword(w,4);          RGAction.nog='run '||GAction.nog;          ww=ww+((length(GName.nog)+2)*8)+14;          if ww>wwmax then;do;             ww=ww-((length(GName.nog)+2)*8)-14;             nog=nog-1;             end;          end;       end;       else;do;          if word(w,1)='MSettings' then;do;             noi=noi+1;             if noi>2 then iterate;             if words(w)<5 | words(w)>6 then;do;                em='Erreur Dfinition MSettings '||noi;                call syntax;                end;             MSIName.noi=word(w,3);             MSIAction.noi=word(w,4);             MSITarif.noi=left(word(w,5),1);             if MSITarif.noi<0 | MSITarif.noi>4 then;do;                em='Manque ou Erreur dfinition paramtre(s) MSettings '||noi||': \';                em=em||'Zone_tarifaire et/ou Non_Config et/ou Fichier_config';                call syntax;                end;             Reduction.noi=substr(word(w,5),2,1);             TSysName.noi=word(w,6);             TSN=TSN||word(w,6);             end;             else;do;             if word(w,1)='GMail'| word(w,1)='GNews' then;do;                if word(w,1)='GMail' & word(w,3)~='' then;do;                   Mailer=word(w,find(w,'Y'));                   if Mailer='' then;do;                      Mailer=word(w,find(w,'T'));                      if Mailer='' then;do;                         em='Df GMail : Manque Type Mailer';                         call syntax;                         end;                      end;                   GMail=Mailer;                   if find(w,'G')~=0 then;do;                      GadMail=1;                      GMail=GMail||' G';                      end;                   if find(w,'CNX')~=0 then;do;                      CnxMail=1;                      GMail=GMail||' CNX';                      end;                   if find(w,'AUTO')~=0 then;do;                      AutoMail=1;                      GMail=GMail||' AUTO';                      end;                   dcm=index(w,'(');                   fcm=index(w,')');                   if dcm+fcm~=0 then;do;                                 CNMail=substr(w,dcm+1,fcm-dcm-1);                                 GMail=GMail||' ('||CNMail||')';                                 end;                                 else if AutoMail then;do;                                      em="Df GMail : Manque def chane recherche arrive courrier";                                      call syntax;                                      end;                   if Mailer='Y' then;do;                      idd=index(w,'"');                      idf=lastpos('"',w);                      if idd=0 | idf=0 then;do;                         em="Df GMail : Manque/Erreur commande lancement Yam";                         call syntax;                         end;                         else;do;                         SMailer=substr(w,idd+1,idf-idd-1);                         if Mailer~='T' then GMail='"'||SMailer||'" '||GMail;                         end;                      end;                   end;                if word(w,1)='GNews' & word(w,3)~='' then;do;                   idd=index(w,'"');                   idf=lastpos('"',w);                   if idd~=0 & idf~=0 then;do;                      PNewser=substr(w,idd+1,idf-idd-1);                      if right(PNewser,1)~='/' then PNewser=PNewser||'/';                      GNews='"'||PNewser||'" ';                      end;                   Newser=word(w,find(w,'T'));                   if find(w,'G')~=0 then;do;                      GadNews=1;                      GNews='G';                      end;                   if find(w,'CNX')~=0 then;do;                      CnxNews=1;                      GNews=GNews||' '||'CNX';                      end;                   if GNews~='' then Newser='T';                   end;                   if GadMail & GadNews then ww=ww+16;                                        else if GadMail | GadNews then ww=ww+26;                end;                else interpret w;             end;          end;    end;  call close 'input';  end;  else;do;  em='\Fichier '||CFGFile||' non trouv\';  call syntax;  end;em='';if noi=0 then;do;   em="Dfinition obligatoire d'un paramtre MSetting";   call syntax;   end;PNum='WX WY WIX WIY ZMo WInfo InfoC WFront ColC ColNC ColA Alerte TAppel JDCM CUHT';Nbp=words(PNum);do i=1 to Nbp;   par=word(PNum,i);   em='Erreur dfinition paramtre '||par;   test='w='||par||'+1';   interpret test;   end;if JDCM>31 then;do;   em="Paramtre JDCM > 31 !";   call syntax;   end;JDCM=right(JDCM,2,'0');if Newser='T' & TSN='' then;do;   em='Manque df SysName dans paramtre(s) MSetting';   call syntax;   end;ww  = ww+2;wh  = yoff+17;if wx+ww>wwmax then wx=wwmax-ww;whmax = screenrows('Workbench');if wy+wh>whmax then wy=whmax-wh;idcmp = 'closewindow+gadgetup+menupick';flags = 'windowclose+windowdrag+windowdepth+active+refreshwindow';wiw = 192;wih = 50;idcmpi = 'closewindow+gadgetup+menupick';flagsi = 'windowdrag+windowdepth+refreshwindow';Dper=JDCM||right(date('e'),6);NDper=Dper;TTCS= 0;TUC = 0;CTHT= 0;NBCOM=0;TMCS= 0;l=0;lo='';wf='';em='Erreur dans fichier log';if LogFile~='' then;do;  w = open('input',logfile,'r');  if w=1 then;do;     w = readln('input');     w = readln('input');     w = readln('input');     w = readln('input');     w = readln('input');     w = readln('input');     if words(w)<2 then;do;     wf = readln('input');        TTC=subword(wf,1,1);        TUC=subword(wf,2,1);        CTHT=subword(wf,3,1);        TTCS=(substr(TTC,1,2)*3600)+(substr(TTC,4,2)*60)+(substr(TTC,7,2));        NBCOM=subword(wf,6,1);        if NBCOM='' then NBCOM=0;        TMC=subword(wf,7,1);        if TMC~='' then TMCS=(substr(TMC,1,2)*3600)+(substr(TMC,4,2)*60)+(substr(TMC,7,2));        wdp = readln('input');        l=0;        end;        else;do;        am=subword(w,1,1);        wdp='01'||right(am,3)||'/'||left(am,2);        TTC=subword(w,2,1);        TUC=subword(w,3,1);        CTHT=subword(w,4,1);        TTCS=(substr(TTC,1,2)*3600)+(substr(TTC,4,2)*60)+(substr(TTC,7,2));        NBCOM=subword(w,7,1);        if NBCOM='' then NBCOM=0;        TMC=subword(w,8,1);        if TMC~='' then TMCS=(substr(TMC,1,2)*3600)+(substr(TMC,4,2)*60)+(substr(TMC,7,2));        lo='   ';        l=1;        w.l=' ';        end;     dper=subword(wdp,1,1);     ndper=JDCM||right(date('e'),6);;do while ~eof('input');        wi= readln('input');        if wi~='' then;do;           l=l+1;           w.l=lo||wi;           end;        end;     call close 'input';     end;  end;em='';Call Finper NDper;NFper=Fper;RNDper=RDper;if RNDPer < date('o') then;do;   NDper=NFper;   call Finper NDper;   NFper=Fper;   RNDper=RDper;   end;RNFper=RFper;Call Finper Dper;wmx = wx;hm  = ychar*5;yw = screenrows('Workbench');if wy+hm>yw then wmy = yw-hm;   else wmy=wy;mol=0;nup=-1;nut='00';stc=0;tup=0;dc=0;Rcnm=0;jour=DATE('w');if find(jf,date('e'))~=0 then jour='Sunday';if zmo>0 then smx=smx+zmo;call openport(nport);address arexx "'call createhost("cport","nport")'";address command 'WAITFORPORT' cport;call openw;address arexx "'call createhost("cporti","nport")'";address command 'WAITFORPORT' cporti;if WInfo=1 then call openwi;noi=0;noin=1;call MSettings;halt:;do forever;signal on halt;call getut;call delay 50;  pkt = getpkt(nport);  if pkt=='00000000'x then iterate;  message = getarg(pkt);  call reply(pkt,0);  action = upper(word(message,1));  select;    when action=='QUIT' then leave;    when action=='MIAMI' then;do;      if showlist('p','MIAMI.1')=0 then       address command RSMiami;       else address 'MIAMI.1' 'SHOW';      end;    when action=='CLOSEWINDOW' then leave;    when action=='ONLINE' then call getonline;    when action=='OFFLINE' then call getoffline;    when left(action,1)='G' then;do;       nog=right(action,1);       address command RGAction.nog;       end;    when action=='MAIL' & ~Rcnm then;do;       if mol=0 then call getonline;       address 'MIAMI.1' 'ISONLINE';       if rc=1 then call Mail;       end;    when action=='NEWS' & ~Rcnm then;do;       if mol=0 then call getonline;       address 'MIAMI.1' 'ISONLINE';       if rc=1 then;do;               if Mailer='T' then NOption='';                             else NOption='NOMAIL';               call news;               end;       end;    when action=='FTG' then call InfoThor;    when action=='BAR' then;do;       if showlist('p','MIAMI.1')=1 then          address 'MIAMI.1' 'SHOW';       end;    when action=='UT' then;do;       if argt~='TC' then;do;             if showlist('p','MIAMI.1')=1 then                address 'MIAMI.1' 'HIDE';             end;             else;do;             if Stc=0 then;do;                stc=1;                call testonline;                end;                else;do;                stc=0;                call testoffline;                end;             end;       end;    when action=='COUTS' then;do;      if InfoC=0 then Infoc=1;                 else InfoC=0;      if WInfo=1 then;do;         call closewindow(cporti,'continue');         call openwi;         end;      end;    when action=='FRONT' then;do;      if WFront=0 then WFront=1;                  else WFront=0;      end;    when left(action,1)='M' then;do;       noin=right(action,1);       call MSettings;       end;    when action=='INFO' then;do;       if WInfo=1 then;do;          call closewindow(cporti,'continue');          WInfo=0;          end;          else;do;          call openwi;          Winfo=1;          end;       end;    when action=='ABOUT' then;do;          tab='';          if InfoC=1 then tab='     ';          text=tab||'---* NBAR '||Version||' *---\'             ||tab||'     A. Petit \'             ||tab||'apetit@infrescom.fr\';          if WInfo=0 then call openwi;          call windowtext(cporti,text);          call delay 200;          if WInfo=0 then call closewindow(cporti,'continue');          end;    when action=='SPOSI' then;do;      if words(message)>2 then;do;        wix = word(message,2);        wiy = word(message,3);        end;      end;    when action=='SPOS' then;do;      if words(message)>2 then;do;        wx = word(message,2);        wy = word(message,3);        end;      w = statef(cfgfile);      if w='' then call delete cfgfile;      call open 'output',cfgfile,'w';      if result then;do;        w = '--------* Configuration NBAR *--------';        call writeln 'output',w;        w = ' ';        call writeln 'output',w;        w = 'WX =' wx;        call writeln 'output',w;        w = 'WY =' wy;        call writeln 'output',w;        w = 'WIX =' wix;        call writeln 'output',w;        w = 'WIY =' wiy;        call writeln 'output',w;        w = ' ';        call writeln 'output',w;        w = 'ZMo    =' zmo;        call writeln 'output',w;        w = 'WInfo  =' winfo;        call writeln 'output',w;        w = 'InfoC  =' infoc;        call writeln 'output',w;        w = 'WFront =' wfront;        call writeln 'output',w;        w = 'ColC   =' colc;        call writeln 'output',w;        w = 'ColNC  =' colnc;        call writeln 'output',w;        w = 'ColA   =' cola;        call writeln 'output',w;        w = 'Alerte =' alerte;        call writeln 'output',w;        w = 'TAppel =' TAppel;        call writeln 'output',w;        w = 'SMiami     =' '"'SMiami'"';        call writeln 'output',w;        w = 'LogFile    =' '"'LogFile'"';        call writeln 'output',w;        w = 'MLogFile   =' '"'mlogfile'"';        call writeln 'output',w;        w = 'JDCM       =' JDCM;        call writeln 'output',w;        w = 'CUHT       =' CUHT;        call writeln 'output',w;        w = ' ';        call writeln 'output',w;;do i=1 to nbi;          w = 'MSettings :' MSIName.i MSIAction.i MSITarif.i||Reduction.i TSysName.i;          call writeln 'output',w;          end;        w = ' ';        call writeln 'output',w;        w = 'GMail :' GMail;        call writeln 'output',w;        w = 'GNews :' GNews;        call writeln 'output',w;        w = ' ';        call writeln 'output',w;;do i=1 to nog;          w = 'Gadget :' GName.i GAction.i;          call writeln 'output',w;          end;        call close 'output';        end;      else;do;        msg = 'Erreur criture\'||cfgfile;        call SMessage;        end;      iterate;      end;      otherwise iterate;  end;end;syntax: signal off syntax;if ACTION~='QUIT' & ACTION~='CLOSEWINDOW' then say 'Erreur' RC 'ligne: ' SIGL;if em~='' then;do;  call postmsg(wmx,wmy,em);  call delay 300;  call postmsg();  em='';  end;if mol=1 then;do;   call getoffline;   call logout;   end;call exit(cport);call exit(cporti);call closeport(nport);if showlist('p','MIAMI.1')=1 then address 'MIAMI.1' 'QUIT';if exists('ram:GetTCP.log') then address command 'delete ram:GetTCP.log quiet';if exists('ram:SGetTCP') then address command 'delete ram:SGetTCP quiet';address command 'delete >nil: '||MLogFile||' quiet';exit;getonline:;t1=time('s');if showlist('p','MIAMI.1')=0 then;do;  address command RSMiami;  address command 'WAITFORPORT' 'MIAMI.1';  end;address 'MIAMI.1' 'ISONLINE';if rc=1 then return;dc=1;if TAppel=0 then;do;   msg="Appel en cours ... ";   call Smessage;   address command 'run rx "address 'MIAMI.1' 'ONLINE'"';   Timeout=time('s')+45;   TDC=0;;do while time('s') < Timeout;     PS=C2B(import('00BFD000'x,1));     CD=SUBSTR(PS,3,1);     if CD=0 then;do;             TDC=time('s')-10;             leave;             end;     end;   tap=time('s')-t1;   if time('s') < Timeout then;do;      msg="Connexion en cours ... ";      call Smessage;      address 'MIAMI.1' 'ONLINE';      end;   end;   else;do;      msg="Connexion en cours ... ";      call Smessage;      TDC=time('s')+TAppel;      address 'MIAMI.1' 'ONLINE';   end;address 'MIAMI.1' 'ISONLINE';if rc~=1 then;do;  dc=0;  msg="Connexion choue !";  call Smessage;  if TAppel=0 then;do;               if TDC=0 then return;               end;              else;do;              if (time('s')-2)<TDC then return;              end;  end;  else return;nu=1;CTime=0;call logout;return;getoffline:;if showlist('p','MIAMI.1')=0 then return;msg="Dconnexion en cours ...";call Smessage;address 'MIAMI.1' 'OFFLINE';return;getut:;if showlist('p','MIAMI.1')=1 then;do;  address 'MIAMI.1' 'ISONLINE';  if rc=1 then;do;    if mol=0 then;do;      mol=1;      call SetAPen(cport,0);      call RectFill(cport,sox-4,soy-1,swx-1,soy+12);      call RemoveGadget(cport,'online');      call addgadget(cport,sox-4,soy,'offline',' OFFLINE ','offline');      call RefreshGadgets(cport);      if dc=0 then TDC=time('s');      col=colc;      call SSpeedMail;      datec=date('o');      if datec >= Rfper | datec >= RNdper then;do;         TTCS=0;         TUC=0;         CTHT=0;         NBCOM=0;         TMCS=0;         end;     end;     else CTime=time('s')-TDC;    end;    else;do;    if mol=1 then;do;      mol=0;      dc=0;      call SetAPen(cport,0);      call RectFill(cport,sox-6,soy-1,swx-1,soy+12);      call RemoveGadget(cport,'offline');      call addgadget(cport,sox,soy,'online',' ONLINE ','online');      call RefreshGadgets(cport);      if noi=0 then msg=blkmes;               else msg=" "||MSIName.noi;      call Smessage;      call logout;      ctime=0;      col=colnc;      end;    end;  end;  else;do;   if stc = 1 then;do;      CTime=time('s')-TDC;      col=colc;      end;      else;do;      ctime=0;      col=colnc;      end;  end;if Reduction='T' then;do;   select;      when Ctime < 300 then RT=1;      when Ctime < 600 then RT=0.9;      when Ctime < 900 then RT=0.8;      otherwise RT=0.7;      end;   end;if Ctime<0 then;do;  TDC=TDC-86400;  CTime=time('s')-TDC;  jour=DATE('w');  if find(jf,date('e'))~=0 then jour='Sunday';  end;tm=time('m');tt=tm%60*100+tm//60;select;  when jour='Sunday' then;do;    select;     when tt <  600 then pa=4;     when tt < 2230 then pa=3;     otherwise pa=4;     end;    end;  when jour='Saturday' then;do;    select;     when tt <  600 then pa=4;     when tt <  800 then pa=3;     when tt < 1230 then pa=1;     when tt < 1330 then pa=2;     when tt < 2230 then pa=3;     otherwise pa=4;     end;    end;  otherwise;do;    select;     when tt <  600 then pa=4;     when tt <  800 then pa=3;     when tt < 1230 then pa=1;     when tt < 1330 then pa=2;     when tt < 1800 then pa=1;     when tt < 2130 then pa=2;     when tt < 2230 then pa=3;     otherwise pa=4;     end;    end;end;tu=t.ZTarif.pa;if Ctime=0 then nu=0;           else nu=(Ctime%tu)+1;if nu~=nup | tu~=tup then;do;  if ZTarif=1 then t=tu/60||"'";              else t=tu||'"';  nut=right(nu,2,'0');  tup=tu;  nup=nu;  call RemoveGadget(cport,'ut');  call RemoveGadget(cport,'bar');  call SetAPen(cport,0);  call RectFill(cport,sux-6,soy-1,sox-4,sby+12);  call addgadget(cport,sux,suy,'ut',nut||' U','ut');  call addgadget(cport,sbx,sby,'bar','0'||'                '||t,'bar');  call RefreshGadgets(cport);  call SetAPen(cport,col);  call RectFill(cport,sbrx+1,soy+1,sbrx+123,sby+8);  call SetAPen(cport,0);  end;if WInfo=1 then;do;   TUCC=TUC+nu;   if InfoC=1 then;do;      call gettime TTCS+CTime;      text='T:' FTime '|' right(TUCC,3,0) 'U | '||left((CTHT*TVA)+(nu*CUTTC*RT),5)||' F\';      text=text||'------------+-------+--------\';      call gettime CTime;      text=text||'C:' FTime '|' right(nu,3,0) 'U | '||left(nu*CUTTC*RT,5,' ')||' F\';      end;      else;do;      call gettime TTCS+CTime;      text='T:' FTime '|' right(TUCC,3,0) 'U\';      text=text||'------------+------\';      call gettime CTime;      text=text||'C:' FTime '|' right(nu,3,0) 'U\';      end;   call windowtext(cporti,text);   if WFront then windowtofront(cporti);   end;tru=(tu-(Ctime//tu)%1);if tru~=tu then;do;   lb= tru/tu*122%1;   call RectFill(cport,sbrx+lb,soy+2,sbrx+122,sby+7);   if tru <= alerte then;do;     call SetAPen(cport,cola);     call RectFill(cport,sbrx+1,soy+1,sbrx+lb+1,sby+8);     call SetAPen(cport,0);     end;   end;if wfront then call windowtofront(cport);return;gettime:;  arg s;  hh = right(s%3600,2,'0');  w = s//3600;  mm = right(w%60,2,'0');  w = w//60;  ss = right(w%1,2,'0');  Ftime = hh':'mm':'ss;  return Ftime;openw:;  call openwindow(cport,wx,wy,ww,wh,idcmp,flags,nport);  call addmenu(cport,left(nport,8));  call additem(cport,'Miami     ','miami','M');  call additem(cport,'Sauve Pos ','spos %f %e','S');  call additem(cport,'A propos  ','about','A');  call additem(cport,'Quitte    ','quit','Q');  call addmenu(cport,'   Prefs     ');  call additem(cport,'   Info Cuts','couts',,'-1');  call additem(cport,'   Auto Front','front',,'-1');  if InfoC=1 then setitem(cport,1,0,,'on');  if WFront=1 then setitem(cport,1,1,,'on');  f.1='10';  f.2='01';  if noi>1 then;do;     call addmenu(cport,'   MIAMI-Settings');;do i=1 to nbi;        MP='MSI'||i;        NItem='   '||MSIname.i;        call additem(cport,NItem,MP,'',f.i);        call setitem(cport,2,0,0,'on');        end;     end;  call addgadget(cport,smx,smy,'mes',blkmes,'');  call addgadget(cport,ssx,ssy,'info','I','Info');  call addgadget(cport,sux,suy,'ut',nut||' U','ut');  call addgadget(cport,sbx,sby,'bar','0'||'                '||t,'bar');  call addgadget(cport,sox,soy,'online',' ONLINE ','online');  if GadMail then;do;     call addgadget(cport,sgx,yoffg,'m','M','MAIL');     if Newser~='' then sgx=sgx+16;                   else sgx=sgx+26;     end;  if GadNews then;do;     call addgadget(cport,sgx,yoffg,'n','N','NEWS');     sgx=sgx+26;     end;;do i=1 to nog;     call addgadget(cport,sgx,yoffg,GName.i,' '||GName.i||' ','G'||i);     sgx=sgx+((length(GName.i)+2)*8)+14;     end;  return;openwi:;  if InfoC=1 then ww=wiw+80;             else ww=wiw;  call openwindow(cporti,wix,wiy,ww,wih,idcmpi,flagsi,nport);  call addmenu(cporti,'NBar-Info');  call additem(cporti,'Save Pos        ','sposi %f %e');  return;SMessage:;msg=left(msg,lgmes);call SetAPen(cport,0);call RectFill(cport,smx+1,smy+1,smx+268,smy+10);call RemoveGadget(cport,'mes');call addgadget(cport,smx,smy,'mes',msg,'');call RefreshGadgets(cport);return;logout:;CTHT=CTHT+(nu*CUHTr*RT);CTTT=CTHT*TVA;if logfile='' then return;TMCS=((TMCS*NBCOM)+CTime)%(NBCOM+1);call gettime TMCS;TMC=FTime;NBCOM=NBCOM+1;TTCS=TTCS+CTime;TUC=TUC+nu;call gettime TTCS;call open 'output',logfile,'w';if result then;do;    call writeln 'output','                         NBar - Fichier log';    call writeln 'output','                         ------------------';    call writeln 'output',' ';    call writeln 'output',' Priode     Temps    Units    Cot HT / TTC    Nb Com     TMC';    call writeln 'output',' ';    if datec >=Rfper | datec >= RNdper then;do;if l=0 then;do;       w.1=wf;       w.2=dper;       l=2;       end;       dpper=dper;       dper=fper;       call Finper dper;       if datec >= RNdper then;do;          dper=ndper;          call Finper dper;          RNDper=RFPer;          end;       w=' '||fper;       call writeln 'output',w;       w='            'FTime'    'right(TUC,3,'0')'    'left(CTHT,6,'0')'  'left(CTTT,6,'0')' F    'right(NBCOM,3,0)'    'TMC;       call writeln 'output',w;       w=' '||dper;       call writeln 'output',w;       if wf='' then l=0;       end;       else;do;       w=' '||fper;       call writeln 'output',w;       w='            'FTime'    'right(TUC,3,'0')'    'left(CTHT,6,'0')'  'left(CTTT,6,'0')' F    'right(NBCOM,3,0)'    'TMC;       call writeln 'output',w;       w=' '||dper;       call writeln 'output',w;       end;;do nl=1 to l;       call writeln 'output',w.nl;       end;    call close 'output';    end;return;MSettings:;if InfoC=0 then;do;   call setitem(cport,2,noin-1,,'off');   call setitem(cport,2,noi-1,,'on');   return;   end;if noin~=noi then;do;   noi=noin;   RSMiami='run '||SMiami;   if MSIAction.noi~="DEF" then RSMiami=RSMiami||' SETTINGS="'||MSIAction.noi||'"';   if showlist('p','MIAMI.1')=1 then;do;      address 'MIAMI.1' 'QUIT';      address command RSMiami;      end;   msg=" "||MSIName.noi;   call Smessage;   ZTarif=MSITarif.noi;   Reduction=Reduction.noi;   if Reduction='P' then CUHTr=left(CUHT*0.85,5);                    else CUHTr=CUHT;   CUTTC=CUHTr*TVA;   SysName=TSysName.noi;   end;return;SSpeedMail:;CSpeed='';NMail=0;if MLogFile~='' then;do;   w = open('input',MLogFile,'r');   if w=~1 then;do;           tm="Fichier "||MlogFile||" non trouv";           call postmsg(wmx,wmy,tm);           call delay 200;           call postmsg();           msg="Connect";           call Smessage;           return;           end;   speeds = '33600 31200 28800 26400 24000 21600 19200 16800 14400 9600 4800 2400 1200';   nbs = words(speeds);;do while ~eof('input');       w = readln('input');;do i=1 to nbs;          sc=subword(speeds,i,1);          ps=index(w,sc);          if ps~=0 then;do;             CSpeed=sc||' bds';             leave;             end;          end;       if CSpeed~='' then nbs=1;       if index(w,CNMail)~=0 then NMail=1;       end;   call close 'input';   end;select; when NMail=0 & CSpeed~='' then msg="Connect | "||CSpeed; when NMail=0 & CSpeed=''then msg="Connect"; when NMail=1 & CSpeed~='' then msg=CSpeed||" | * Courrier reu *"; when NMail=1 & CSpeed='' then msg= "Connect | * Courrier reu *";end;if CSpeed='' then msgcs="Connect";             else msgcs="Connect | "||CSpeed;call Smessage;if Newser='T' & CnxNews then;do;   if Mailer='T'  then call News;              else;do;              NOption='NOMAIL';              call News;              end;   end;   else if Mailer='T' & ((AutoMail & NMail) | CnxMail) then;do;           NOption='NONEWS';           call News;           end;if Mailer='Y' & CnxMail then call Mail;return;Mail:;if Mailer='Y' then;do;   Rcmn=1;   RYam='run '||SMailer;   if showlist('p','YAM')=0 then address command RYam;   address command 'WAITFORPORT' 'YAM';   address 'YAM' 'HIDE';   address 'YAM' 'MAILCHECK';   if rc<1 then;do;           address 'YAM' 'QUIT';           msg=' Pas de Courrier';           call Smessage;           call delay 100;           msg=msgcs;           call Smessage;           end;           else;do;                if rc>1 then msg= "* "||rc||" messages reus *";                        else msg= "* "||rc||" message reu *";                call Smessage;                address 'YAM' 'SHOW' 'SETFOLDER 0';                end;   end;if Mailer='T' then;do;   NOption='NONEWS';   call News;   end;Rcmn=0;return;News:;Rcmn=1;if GTCParg='' then call GArgTCP;RGetTCP=TPath||'bin/GetTCP LOGFILE ram:GetTCP.log '||GTCParg||' '||NOption;msg='Appel serveur ';if NOption='' then msg=msg||'Mail & News ...';              else;do;                if NOption='NONEWS' then msg=msg||'Mail ...';                if NOption='NOMAIL' then msg=msg||'News ...';                end;call Smessage;w = open('output','ram:SGetTCP','w');lo='echo [1m[S[14x';writeln('output',lo);lo='echo [E';writeln('output',lo);lo=RGetTCP;writeln('output',lo);lo='echo [8m';writeln('output',lo);lo='wait 2';writeln('output',lo);lo='run rx "address ''NBAR'' ''FTG''" ';writeln('output',lo);lo='endcli';writeln('output',lo);call close('output');address command 'NewShell con:0/0/350/40/GetTCP-Log/close from ram:SGetTCP';return;InfoThor:;msg='';if NOption='' then;do;   w = open('input','ram:GetTCP.log','r');   if w=1 then;do;          w=readln('input');          w=readln('input');          w=readln('input');          w1=readln('input');          w=readln('input');          if ~eof('input') then;do;             if index(w1,'EMail')~=0 then msg='* Courrier ';                                     else msg='* News ';             w=readln('input');             if ~eof('input') & msg~='* News ' then msg=msg||'& News ';             msg=msg||'reus *';             end;          call close 'input';          end;   end;   else;do;   w = open('input','ram:GetTCP.log','r');   if w=1 then;do;;do while ~eof('input');             w=readln('input');             pmr=find(w,'Received');             if pmr~=0 then;do;                if NOption='NONEWS' then msg='* Courrier';                                    else msg='* News';                msg=msg||' reu ('||word(w,pmr+1)||') *';                leave;                end;             end;          call close 'input';          end;   end;if msg='' then;do;          msg=' Pas de ';          if NOption='NONEWS' then msg=msg||'Courrier';                              else if NOption='NOMAIL' then msg=msg||'News';                                                       else msg=msg||'Courrier / News';          end;call Smessage;NOption='';Rcmn=0;return;GArgTCP:;if ~show('p', 'BBSREAD') then;do;    address command;    "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead";    "WaitForPort BBSREAD";    end;address "BBSREAD";BName='''""'||SysName||'""''';BName=SysName;GETBBSDATA bbsname BName stem BBSDATA;if(rc ~= 0) then;do;    em=BBSREAD.LASTERROR;    call syntax;    end;BType=left(BBSDATA.BBSTYPE,3);if BType~='TCP' then;do;   em="Le systme "||BBSDATA.NAME||" n'est pas de type TCP !";   call syntax;   end;p=length(BBSDATA.BBSPATH);do k=0 to 1;   p=lastpos('/',BBSDATA.BBSPATH,p-1);   end;TPath=left(BBSDATA.BBSPATH,p);TCPF=BBSDATA.BBSPATH||'TCPExtConfig';w = open('input',TCPF,'r');if w=1 then  TCPC = readln('input');call close 'input';GTCParg='';Argk='PUBSCREEN MAILSERVER NEWSSERVER SOCKETS MAXMSGS NNTPPORT PASSWORD ';Argk=Argk||'MAXDAYS USERNAME POPPORT NNTPUSERID NNTPPASSWORD LOGFILE';NArgk=words(Argk);n=1;do while n<NArgk+1;   pos=find(TCPC,word(Argk,n));   if pos~=0 then GTCParg=GTCParg||' '||Word(TCPC,pos)||' '||Word(TCPC,pos+1);   n=n+1;   end;if index(TCPC,'DELETE') >0 then GTCParg=GTCParg||' '||'DELETE';if index(TCPC,'ARCHIVE')>0 then GTCParg=GTCParg||' '||'ARCHIVE';GTCParg=SysName||GTCParg;return;Finper:;arg d;a=right(d,2);m=substr(d,4,2);RDper=a||'/'||m||'/'||left(d,2);if m<12 then;do;   m=m+1;   m=right(m,2,'0');   end;  else;do;    m='01';    a=a+1;    a=right(a,2);    end;Fper=left(d,3)||m||'/'||a;RFper=a||'/'||m||'/'||left(d,2);return;testonline:;Mlogfile = '';call SetAPen(cport,0);call RectFill(cport,sox-4,soy-1,swx-1,soy+12);call RemoveGadget(cport,'online');call addgadget(cport,sox-4,soy,'offline',' OFFLINE ','offline');Stc=1;TDC=time('s');call getut;msg="Connexion en cours ... ";call Smessage;call delay 100;call SSpeedMail;datec=date('o');if datec >= Rfper | datec >= RNdper then;do;   TTCS=0;   TUC=0;   CTHT=0;   NBCOM=0;   TMCS=0;   end;return;testoffline:;call logout;call SetAPen(cport,0);call RectFill(cport,sox-6,soy-1,swx-1,soy+12);call RemoveGadget(cport,'offline');call addgadget(cport,sox,soy,'online',' ONLINE ','online');stc=0;msg="Dconnexion en cours ...";call Smessage;call delay 100;msg=" "||MSIName.noi;call Smessage;call getut;return