7. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 5/13/2019 2:40:10 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

7.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\MPDU\Code\BCMA-master-20181214\BCMA-master\BCMA BCMA_Startup.pas Wed Nov 21 17:43:20 2018 UTC
2 C:\AraxisMergeCompare\Pri_re\MPDU\MPDU\Code\BCMA-master-20181214\BCMA-master\BCMA BCMA_Startup.pas Tue May 7 12:02:18 2019 UTC

7.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 1396
Changed 1 2
Inserted 0 0
Removed 0 0

7.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

7.4 Active regular expressions

No regular expressions were active.

7.5 Comparison detail

  1   unit BCMA_ Startup;
  2   {
  3   ========== ========== ========== ========== ========== ========== ========== ==========
  4   *       Fi le:  BCMA_ Startup.PA S
  5   *
  6   *       Ap plication:   Bar Code  Medicatio n Administ ration
  7   *       Re vision:      $Revisio n: 33 $  $ Modtime: 5 /08/02 3:5 0p $
  8   *
  9   *       De scription:   This uni t contains   code for  Initializ ing the ap plication.
  10   *
  11   *       No tes:         Most of  this code  was origin ally in un it BCMA_Co mmon.
  12   *
  13   * Command  Line Switc hes:
  14   *
  15   * L=logfil epath wher e logfilep ath is the  directory  where bcm a.log is w ritten.
  16   * (default =C:\TEMP)
  17   * P=n wher e n=portnu mber
  18   * S=string   where st ring=serve r (ip addr ess or DNS )
  19   * T=n  whe re n=RPCTi meOut (sec onds; defa ult = 300) .  Sets RP CTimeLimit  in
  20   * SharedRP CBroker.
  21   * /DEBUG   turns on D ebug Mode;  same as d ebug check box in Opt ions form.
  22   * /DEBUGLO G (availab le only wh en DEBUGLO G_ON is de fined in c ompiler) t urns on
  23   *   detail ed debuglo g output i n bcma.log
  24   * /IHS tur ns on SetI HS which f orces BCMA  to use IH S mode as  though run ning in an  RPMS
  25   * system.
  26   * /K=n whe re n=Keybo ardTimeout Value (sec onds; defa ult = 400)
  27   * /NOCCOW  turns off  CCOW funct ionality.
  28   * /NOLOGFI LE disable s the outp ut of the  bcma.log f ile.
  29   * /USERDEF AULTS reve rts back t o default  form and o ther user  settings.   Suppresse s
  30   * load of  user-setti ng paramet ers.
  31   *
  32   ========== ========== ========== ========== ========== ========== ========== ==========
  33   }
  34  
  35   interface
  36  
  37   uses
  38     SysUtils , Classes,  Windows,  Forms,
  39     VHA_Obje cts, Splas h;
  40  
  41   type
  42   //  TUserT ypes = (ut User, utSt udent, utI nstructor) ;
  43     TUserTyp es = (utUs er, utStud ent, utIns tructor, u tWitness);  // rpk 4/ 25/2012
  44  
  45     THeapSta tus = reco rd
  46       TotalA ddrSpace:  Cardinal;
  47       TotalU ncommitted : Cardinal ;
  48       TotalC ommitted:  Cardinal;
  49       TotalA llocated:  Cardinal;
  50       TotalF ree: Cardi nal;
  51       FreeSm all: Cardi nal;
  52       FreeBi g: Cardina l;
  53       Unused : Cardinal ;
  54       Overhe ad: Cardin al;
  55       HeapEr rorCode: C ardinal;
  56     end;
  57  
  58   const
  59     DEFAULTL OGFILEPATH  = 'C:\TEM P\';
  60     TestBuil d = False;                       // Control s display  of notific ation mess age at sta rtup
  61     UserType Caption: a rray[TUser Types] of  string = ( 'User', 'S tudent',
  62       'Instr uctor', 'W itness');
  63  
  64     // minim um require d patch on  server (P SB*x.x*x f or patches )
  65   //  Requir edPatch =  'PSB*3.0*7 0';
  66   //  Requir edPatch =  'PSB*3.0*8 3';
  67   //  Requir edPatch =  'PSB*3.0*1 06';
  68     Required Patch = 'P SB*3.0*106 ';
  69  
  70   { $IFDEF M OB2}
  71   //  Requir edMOBDLL =  '2.0.0.0' ;            // Requi re new BCM AORDERCOM. DLL;
  72   //  Requir edMOBDLL =  '2.0.16.0 ';           // Requi re new BCM AORDERCOM. DLL;
  73   { $ELSE}
  74   //  Requir edMOBDLL =  '1.1.0.7' ;            //Requir e old BCMA ORDERCOM.D LL;
  75   { $ENDIF}
  76     Required MOB1DLL =  '1.1.0.7';            //Require  old BCMAOR DERCOM.DLL ;
  77     Required MOB2DLL =  '2.0.16.0' ;          //Require  new ORDERC OM.DLL;
  78  
  79     Required Version =  '3.0';
  80     //Requir ed Version  of BCMA,  used for t he version  release
  81   //when no  patch has  been insta lled
  82  
  83   var
  84     BytesAll ocated: lo ngInt;
  85  
  86   {$IFDEF CA S_DDPE_DEB UG}
  87     CAS_PID,
  88       CAS_Ig noreDll,
  89       UserAV : string;
  90     CAS_Show Reader: Bo olean;
  91   {$ENDIF}
  92   {$IFDEF CA S_508_DEBU G}
  93     CAS_508:  string;
  94   {$ENDIF}
  95     Instruct orName,
  96       PortSt ring,
  97       Server String,
  98       Server IP: string ;
  99  
  100     useDebug Mode,
  101       useLog File,
  102   //    NoAu toUpdate,
  103     useDebug Log,
  104       useUse rDefaults,                       // force u se of defa ult user p arameters;  rpk 8/25/ 2009
  105       NoCCOW ,
  106       setIHS : boolean;
  107  
  108     logFileN ame: strin g;
  109     Applicat ionLogFile : TextFile ;
  110     BCMAAULo gFile: Tex tFile;
  111     ErrorLis t: TString List;
  112     nowStrin g: string;
  113  
  114     logCriti calSection : TRtlCrit icalSectio n;
  115  
  116     AppFileV ersion,
  117       AppExe Name: stri ng;
  118  
  119     BCMA_Use r: TBCMA_U ser;
  120     BCMA_Bro ker: TBCMA _Broker;
  121  
  122     UserIsLo ggedOn: bo olean;
  123     RPCTimeO ut: Intege r;
  124  
  125     ShutDown : Boolean;
  126     FirstPas s: Boolean ;
  127     IdleTime : TDateTim e;
  128  
  129   function B CMA_Applic ationInit( OnlineRequ ired: bool ean): bool ean;
  130   (*
  131     Creates  and opens  the Applic ationLogFi le, create s and init ializes
  132     BCMA_Bro ker(TBCMA_ Broker), B CMA_User(T BCMA_User)  and
  133     BCMA_Pat ient(TBCMA _Patient).
  134   *)
  135  
  136   procedure  BCMA_Appli cationQuit ;
  137   (*
  138     Performs  cleanup o perations  for the ap plication.
  139   *)
  140  
  141   procedure  BCMAExcept ionHandler (Sender: T Object; E:  Exception );
  142   (*
  143     This is  the Global  Exception  Handler f or the app lication.
  144   *)
  145  
  146   procedure  writeLogMe ssageProc( Msg: strin g; Ex: exc eption; Ms g2: TStrin gs = nil);
  147   (*
  148     Writes a  message t o the Appl icationLog File.  If  Ex is not  nil, then
  149     Ex.messa ge is writ ten to the  Applicati onLogFile  as well.
  150   *)
  151  
  152   procedure  CloseLogFi le;
  153  
  154   function A llowMultCo pies: Bool ean;
  155  
  156   implementa tion
  157  
  158   uses
  159     Controls , StdCtrls , Dialogs,  FileCtrl,
  160     TRpcb,
  161   //  MFunSt r,
  162     RpcConf1 , InputQry , Instruct or, BCMA_U til, BCMA_ Common,
  163     BCMA_Obj ects, uCCO W;
  164  
  165   procedure  SetKeyboar dTimeoutVa lue(Timeou tVal: stri ng);
  166   var
  167     tmpVal:  string;
  168     tmpIntVa l: Integer ;
  169   begin
  170     {validat e the para meter}
  171     tmpVal : = Trim(Tim eoutVal);
  172     try
  173       tmpInt Val := Str ToInt(tmpV al);
  174       if (tm pIntVal >=  250) and  (tmpIntVal  <= 1500)  then
  175         KeyB oardTimerI nterval :=  tmpIntVal ;
  176     except
  177       Exit;
  178     end;
  179   end;
  180  
  181   procedure  OpenLogFil e;
  182   var
  183     I: Integ er;
  184     ii: inte ger;
  185     LogFileP ath: strin g;
  186     temp_pat h: string;
  187     bres, pa therror: B oolean;
  188     PathList : TStringL ist;
  189   begin
  190     bres :=  False;
  191     patherro r := False ;
  192  
  193     PathList  := TStrin gList.Crea te;
  194     if PathL ist = nil  then
  195       Exit;
  196  
  197     temp_pat h := '';
  198  
  199     ii := Pa ramCount;
  200     while us eLogFile a nd (ii > 0 ) do begin
  201       useLog File := no t (upperCa se(paramSt r(ii)) = ' /NOLOGFILE ');
  202       dec(ii );
  203     end;
  204  
  205     if useLo gFile then  begin
  206       Initia lizeCritic alSection( logCritica lSection);
  207       ErrorL ist := TSt ringList.c reate;
  208       LogFil ePath := ' ';
  209  
  210       for ii  := 1 to P aramCount  do
  211         if u pperCase(p iece(param Str(ii), ' =', 1)) =  'L' then b egin
  212           Lo gFilePath  := piece(p aramStr(ii ), '=', 2) ;
  213           if  LogFilePa th > '' th en
  214              PathList.A dd(Logfile Path);
  215         end;
  216  
  217       LogFil ePath := D EFAULTLOGF ILEPATH;
  218  
  219       PathLi st.Add(Log filePath);
  220  
  221   {$IFDEF TE ST_ON}
  222       LogFil ePath := G etEnvironm entVariabl e('TEMP');
  223       if Log FilePath >  '' then b egin
  224         Path List.Add(L ogfilePath );
  225         temp _path := L ogFilePath ;
  226       end;
  227  
  228       LogFil ePath := G etEnvironm entVariabl e('TMP');
  229       if Log FilePath >  '' then b egin
  230         // c heck for T EMP = TMP;  avoid dup licates
  231         if L ogFilePath  <> temp_p ath then
  232           Pa thList.Add (LogfilePa th);
  233       end;
  234   {$ENDIF}
  235  
  236       for I  := 0 to Pa thList.Cou nt - 1 do  begin
  237         LogF ilePath :=  PathList[ i];
  238         (* M ake sure t he path is  terminate d with a ' \'*)
  239         if L ogFilePath [length(Lo gFilePath) ] <> '\' t hen
  240           Lo gFilePath  := LogFile Path + '\' ;
  241         if n ot Directo ryExists(L ogFilePath ) then beg in
  242           if  not Creat eDir(LogFi lePath) th en begin
  243              if useDebu gLog then             // rpk 5/3 1/2011
  244                DefMessa geDlg('Una ble to cre ate direct ory for '  + LogFileP ath +
  245                  '.', m tError, [m bOK], 0);
  246              Continue;                        // for pat hlist
  247           en d;
  248         end;
  249  
  250         logF ileName :=  LOGFILEPA TH +
  251           Ch angeFileEx t(extractF ileName(ap plication. ExeName),  '.log');
  252         Assi gnFile(App licationLo gFile, log FileName);
  253  
  254         try
  255           if  not FileE xists(logF ileName) t hen begin
  256              Rewrite(Ap plicationL ogFile);
  257              Writeln(Ap plicationL ogFile,
  258                '======= === Log Fi le for Bar  Code Medi cation Adm inistratio n (BCMA) '  +
  259                DateTime ToStr(Now)  + ' ===== =====');
  260           en d
  261           el se
  262              Append(App licationLo gFile);
  263  
  264         exce pt
  265           on  e: EInOut Error do b egin
  266              if e.Error Code > 0 t hen begin
  267                if useDe bugLog the n          // rpk 5/3 1/2011
  268                  DefMes sageDlg('C ould not c reate an a pplication  log file: ' + #13#13  +
  269                    logF ileName +  #13#13 +
  270                    'Err or: ' + In tToStr(e.E rrorCode)  + ' : ' +  e.Message,
  271                    mtEr ror, [mbOK ], 0);
  272  
  273                patherro r := True;
  274              end;
  275              Continue;                        // for pat hlist
  276           en d;
  277         end;
  278         bres  := True;                        // created  directory  / opened  file
  279         brea k;
  280       end;                                    // for pat hlist
  281     end;
  282  
  283     if bres  then begin
  284       if use DebugLog a nd patherr or then    // rpk 5/3 1/2011
  285         DefM essageDlg( 'Applicati on log fil e will be  written he re:' + #13 #13 +
  286           lo gFileName,  mtInforma tion, [mbO K], 0);
  287     end
  288     else beg in
  289       useLog File := Fa lse;
  290       if use DebugLog t hen                   // rpk 5/3 1/2011
  291         DefM essageDlg( 'Could not  create an  applicati on log fil e. No log  file will  be written :',
  292           mt Error, [mb OK], 0);
  293       Delete CriticalSe ction(logC riticalSec tion);
  294       if Err orList <>  nil then
  295         Free AndNil(Err orList);
  296     end;
  297  
  298     PathList .Free;
  299  
  300   end;                                        // OpenLog File
  301  
  302   procedure  CloseLogFi le;
  303   var
  304     totalloc : Cardinal ;
  305     stillall oc: Intege r;
  306   begin
  307     if logFi leName <>  '' then be gin
  308       if use LogFile th en begin
  309         if u seDebugMod e then beg in
  310           to talloc :=  GetHeapSta tus.TotalA llocated;  // rpk 5/1 4/2013
  311           st illalloc : = totalloc  - BytesAl located;
  312           wr iteLogMess ageProc('S till Alloc ated=' +
  313              intToStr(s tillalloc)  + ' Bytes ', nil);
  314         end;
  315  
  316         writ eLogMessag eProc('=== ========== =========  Exiting '  + AppExeNa me +
  317           '  ========== ========== ========',  nil);
  318         Flus h(Applicat ionLogFile );
  319         Clos eFile(Appl icationLog File);
  320  
  321         Erro rList.free ;
  322         Dele teCritical Section(lo gCriticalS ection);
  323         useL ogFile :=  False;                // make su re writelo gmessagepr oc does no t run;  rp k 5/23/201 3
  324       end;
  325  
  326       logFil eName := ' ';                    // prevent  multiple  close log  file actio ns;  rpk 2 /3/2012
  327  
  328     end;
  329   end;                                        // CloseLo gFile
  330  
  331   function g etElectron icSignatur e(UserType : TUserTyp es): strin g;
  332   var
  333     CheckSta te: Boolea n;
  334   begin
  335     result : = inputPro mpt(Applic ation.Titl e, UserTyp eCaption[U serType] +
  336       '''s E lectronic  Signature: ',
  337       '', 0,  True, Tru e, otNone,  CheckStat e, '');
  338   end;
  339  
  340   function B CMA_Applic ationInit( OnlineRequ ired: bool ean): bool ean;
  341   var
  342     ii,
  343       TryCou nt: Intege r;
  344     UserType : TUserTyp es;
  345   begin
  346     result : = False;
  347     useDebug Log := Fal se;                   // rpk 3/9 /2009
  348     setIHS : = False;                         // rpk 6/2 3/2010
  349  
  350     OpenLogF ile;
  351  
  352     with TVe rsionInfo. Create(app lication)  do
  353     try
  354       AppFil eVersion : = FileVers ion;
  355     finally
  356       Free;
  357     end;
  358  
  359     AppExeNa me := Extr actFileNam e(applicat ion.ExeNam e);
  360     AppExeNa me := copy (AppExeNam e, 1, leng th(AppExeN ame) -
  361       length (ExtractFi leExt(AppE xeName)));
  362  
  363     writeLog MessagePro c('', nil) ;
  364     writeLog MessagePro c(copy('== ========== ==========  Starting  ' + AppExe Name + ' '
  365       +
  366       AppFil eVersion +  ' ======= ========== ========== ', 1, 64),  nil);
  367  
  368     BytesAll ocated :=  GetHeapSta tus.TotalA llocated;
  369     if Param Count > 0  then
  370       for ii  := 1 to P aramCount  do         (* Check f or command  line valu es *)
  371       begin
  372         if u pperCase(p iece(param Str(ii), ' =', 1)) =  'P' then
  373           Po rtString : = piece(pa ramStr(ii) , '=', 2);
  374  
  375         if u pperCase(p iece(param Str(ii), ' =', 1)) =  'S' then
  376           Se rverString  := piece( paramStr(i i), '=', 2 );
  377  
  378         if u pperCase(p iece(param Str(ii), ' =', 1)) =  'T' then
  379           RP CTimeOut : = StrToInt (piece(par amStr(ii),  '=', 2));
  380  
  381         if u pperCase(p iece(param Str(ii), ' =', 1)) =  '/K' then  {JK 10/10/ 2008}
  382           Se tKeyboardT imeoutValu e(piece(pa ramStr(ii) , '=', 2)) ;
  383  
  384         useD ebugMode : = useDebug Mode or (u pperCase(p aramStr(ii )) = '/DEB UG');
  385  
  386         // a dded condi tional def ine to rem ove availa bility of  debug log  in product ion; rpk 1 /6/2011
  387   {$IFDEF DE BUGLOG_ON}
  388         useD ebugLog :=  useDebugL og or (upp erCase(par amStr(ii))  = '/DEBUG LOG');
  389   {$ENDIF}
  390  
  391         NoCC OW := NoCC OW or (upp erCase(par amStr(ii))  = '/NOCCO W');
  392  
  393         useU serDefault s := useUs erDefaults  or (upper Case(param Str(ii)) =
  394           '/ USERDEFAUL TS');                 // rpk 8/2 5/2009
  395  
  396         setI HS := setI HS or (upp ercase(par amStr(ii))  = '/IHS') ; // rpk 6 /23/2010
  397  
  398   //      No AutoUpdate  := True;
  399         //No AutoUpdate  := NoAuto Update or  (upperCase (paramStr( ii)) = '/N OAU');
  400   {$IFDEF CA S_DDPE_DEB UG}
  401         if u pperCase(p iece(param Str(ii), ' =', 1)) =  '/AV' then
  402           Us erAV := pi ece(paramS tr(ii), '= ', 2);
  403         if u pperCase(p iece(param Str(ii), ' =', 1)) =  '/CAS_IGNO RE' then
  404           CA S_IgnoreDL L := 'YES' ;
  405         CAS_ ShowReader  := upperC ase(piece( paramStr(i i), '=', 1 )) = '/CAS _READER';
  406         if u pperCase(p iece(param Str(ii), ' =', 1)) =  '/CAS_PID'  then
  407           CA S_PID := p iece(param Str(ii), ' =', 2);
  408   {$ENDIF}
  409       end;
  410  
  411     if useDe bugLog the n begin
  412       Messag eBeep(MB_I CONASTERIS K);
  413       DefMes sageDlg('A ll RPC cal ls are bei ng logged  to a text  file, (BCM A.LOG or B CMAPAR.LOG ), located  in the te mp directo ry.  These  files wil l contain  '
  414         +
  415         'con fidential  patient in formation  and are fo r debuggin g purposes  only.  De lete this  file immed iately!',
  416         mtWa rning, [mb OK], 0);
  417     end;
  418  
  419     // Creat e the Brok er
  420     Applicat ion.Proces sMessages;
  421     BCMA_Bro ker := TBC MA_Broker. Create(App lication);
  422     with BCM A_Broker d o
  423     begin
  424       LogErr orProc :=  writeLogMe ssageProc;
  425       DebugM ode := use DebugMode;
  426       if RPC TimeOut =  0 then
  427         RPCT imeLimit : = 300
  428       else
  429         RPCT imeLimit : = RPCTimeO ut;
  430  
  431       if (Se rverString  = '') or  (PortStrin g = '') th en
  432         if ( getServerI nfo(Server String, Po rtString)  = mrCancel ) then
  433         begi n
  434           Po rtString : = '';
  435           Se rverString  := '';
  436         end;
  437  
  438       if (Se rverString  <> '') an d (PortStr ing <> '')  then
  439       begin
  440         Serv er := Serv erString;
  441         List enerPort : = strToInt (PortStrin g);
  442         Serv erIP := Ge tServerIP( server);
  443   {$IFNDEF M OB2}
  444   ////  DN S      BELLC Remo ve MOB2 de fine and u se shared  broker
  445  
  446   // use rpc  broker in  future wh en orderco m.dll is r eleased an d comment  out AllowS hared; rpk  2/29/2016
  447   // 2FA:       AllowSh ared := Tr ue;               //  turn on Sh ared RPC B roker shar ing for Me d Order Bu tton
  448  
  449   {$ENDIF}
  450         writ eLogMessag eProc('Ser ver: ' + s erverstrin g, nil);
  451         writ eLogMessag eProc('Ser ver IP: '  + ServerIP , nil);
  452         writ eLogMessag eProc('Lis tenerPOrt:  ' + ports tring, nil );
  453         writ eLogMessag eProc('RPC TimeLimit:  ' + IntTo Str(RPCTim eLimit), n il);
  454  
  455         if N OCCOW then                       // rpk 7/2 5/2013
  456           VA CCOW := ni l
  457         else  begin
  458           Sc reen.Curso r := crHou rglass;    // rpk 3/2 5/2013
  459           Fr mSplash.Wr iteStatus( 'Attemptin g communic ation with  CCOW...') ; // rpk 3 /25/2013
  460           VA CCOW := Ne wCCOWConte xtor(Appli cation); / / rpk 3/25 /2013
  461           if  (VACCOW < > nil) the n begin    // rpk 7/2 5/2013
  462              if NoCCOW  then begin            // rpk 3/2 5/2013
  463                VACCOW.C COWEnabled  := False  // rpk 3/2 5/2013
  464              end                              // rpk 3/2 5/2013
  465              else begin                       // rpk 3/2 5/2013
  466                FrmSplas h.WriteSta tus('Commu nicating w ith CCOW V ault...');  // rpk 3/ 25/2013
  467                if VACCO W.JoinCont ext('BCMA# ') then //  rpk 3/25/ 2013
  468                  BCMA_B roker.Cont extor := V ACCOW.Cont extManager  // rpk 3/ 25/2013
  469                else
  470                  BCMA_B roker.Cont extor := n il;
  471                FrmSplas h.WriteSta tus('');   // rpk 3/2 6/2013
  472              end;                             // rpk 3/2 5/2013
  473           en d;                               // if VACC OW <> nil
  474           Sc reen.Curso r := crDef ault;
  475         end;                                  // if NOCC OW
  476  
  477         FrmS plash.Writ eStatus('C onnecting  to Broker  Server...' ); // rpk  3/26/2013
  478         try
  479   {$IFDEF CA S_DDPE_DEB UG}
  480           Ac cessVerify Codes := U serAV;
  481   {$ENDIF}
  482           co nnected :=  True;
  483           Fr mSplash.Wr iteStatus( 'Loading U ser Parame ters...');  // rpk 6/ 9/2009
  484           //  Create Us er Object  and load i t
  485           BC MA_User :=  TBCMA_Use r.Create(B CMA_Broker );
  486           wi th BCMA_Us er do
  487              if LoadDat a then
  488              begin
  489                if Onlin eRequired  and not On Line then
  490                begin
  491                  DefMes sageDlg('T he BCMA ap plication  is not act ive for th is divisio n.',
  492                    mtEr ror, [mbOK ], 0);
  493                  connec ted := Fal se;
  494                end
  495                else
  496                begin
  497                  TryCou nt := 3;
  498                  if isS tudent the n
  499                    User Type := ut Student
  500                  else
  501                    User Type := ut User;
  502  
  503                  if ESi gRequired  then
  504                    whil e TryCount  > 0 do
  505                      if  isValidES ig(getElec tronicSign ature(User Type)) the n
  506                         break
  507                      el se
  508                         dec(TryCou nt);
  509  
  510                  //if t here wasn' t a valid  esig enter ed, bail o ut
  511                  if Try Count = 0  then
  512                  begin
  513                    Conn ected := f alse;
  514                    exit
  515                  end;
  516  
  517                  if Try Count > 0  then
  518                    if i sStudent t hen
  519                    begi n
  520                      //                                        This  a Student !
  521                      Tr yCount :=  3;
  522                      wh ile TryCou nt > 0 do
  523                         with TfrmI nstructor. create(app lication)  do
  524                         begin
  525                           ModalRes ult := Sho wModal;
  526                           if Modal Result = m rOK then
  527                           begin
  528                             Instru ctorName : = '/' + In structorNa me;
  529                             break;
  530                           end
  531                           else if  ModalResul t = mrCanc el then
  532                           begin
  533                             TryCou nt := 0;
  534                             break;
  535                           end
  536                           else
  537                             dec(Tr yCount);
  538                         end;
  539                    end;
  540                  if (Tr yCount = 0 ) and (isR eadOnly =  false) the n
  541                    isRe adOnly :=  True;
  542                  writeL ogMessageP roc(UserTy peCaption[ UserType]  + ' ' + Us erName +
  543                    ' lo gged on!',  nil);
  544                  Result  := True;
  545                end;
  546              end
  547              else
  548                connecte d := False ;
  549         exce pt
  550           on  Ex: EBrok erError do
  551           be gin
  552              DefMessage Dlg('Broke r Error' +  #13 + Bro kerErrorMe ssages(Ex. Code,
  553                Ex.Mnemo nic) +
  554                #13 + Ex .Message,  mtError, [ mbOK], 0);
  555              connected  := false;
  556              exit;
  557           en d;
  558         end;
  559       end
  560       else
  561       begin
  562         writ eLogMessag eProc('No  Server and /or Port F ound.', ni l);
  563         DefM essageDlg( 'No Server  and/or Po rt Found!' , mtError,  [mbOK], 0 );
  564         exit ;
  565       end;
  566     end;
  567   end;                                        // BCMA_Ap plicationI nit
  568  
  569   procedure  BCMA_Appli cationQuit ;
  570   begin
  571   //  BytesA llocated : = GetHeapS tatus.Tota lAllocated ;
  572  
  573     BCMA_Use r.free;
  574   //  CloseL ogFile;  / / NOTE: do n't call c loselogfil e prior to  main form  destroy
  575   end;                                        // BCMA_Ap plicationQ uit
  576  
  577   procedure  BCMAExcept ionHandler (Sender: T Object; E:  Exception );
  578   var
  579     msg: str ing;
  580   begin
  581     Applicat ion.Normal izeTopMost s;
  582     msg := ' BCMA Error :';
  583  
  584     if E is  EWin32Erro r then
  585       with E  as EWin32 Error do
  586         msg  := msg + # 13#10 + Sy sErrorMess age(ErrorC ode);
  587  
  588     if (E is  EOutOfMem ory) or
  589       (E is  EStackOver Flow) then
  590       with G etHeapStat us do
  591       begin
  592         msg  := msg + # 13#10 + 'H eap Status  --';
  593         msg  := msg + # 13#10 + fo rmat('Tota l Addr Spa ce: %d%%',  [TotalAdd rSpace]);
  594         msg  := msg + # 13#10 + fo rmat('Tota l Uncommit ted: %d%%' ,
  595           [T otalUncomm itted]);
  596         msg  := msg + # 13#10 + fo rmat('Tota l Committe d: %d%%',  [TotalComm itted]);
  597         msg  := msg + # 13#10 + fo rmat('Tota l Allocate d: %d%%',  [TotalAllo cated]);
  598         msg  := msg + # 13#10 + fo rmat('Tota l Free: %d %%', [Tota lFree]);
  599         msg  := msg + # 13#10 + fo rmat('Free  Small: %d %%', [Free Small]);
  600         msg  := msg + # 13#10 + fo rmat('Free  Big: %d%% ', [FreeBi g]);
  601         msg  := msg + # 13#10 + fo rmat('Unus ed: %d%%',  [Unused]) ;
  602         msg  := msg + # 13#10 + fo rmat('Over head: %d%% ', [Overhe ad]);
  603         msg  := msg + # 13#10 + fo rmat('Heap  ErrorCode : %d%%', [ HeapErrorC ode]);
  604       end;
  605  
  606     ShowExce ption(E, E xceptAddr) ;
  607     writeLog MessagePro c(msg, E);
  608     Applicat ion.Restor eTopMosts;
  609     Applicat ion.MainFo rm.Close;
  610     applicat ion.termin ate;
  611     abort;
  612     //FrmMai n.Close;
  613   end;                                        // BCMAExc eptionHand ler
  614  
  615   procedure  writeLogMe ssageProc( msg: strin g; ex: exc eption; Ms g2: TStrin gs = nil);
  616   var
  617     ii: inte ger;
  618   begin
  619     if useLo gFile then  begin
  620       try
  621         Ente rCriticalS ection(log CriticalSe ction);
  622  
  623         nowS tring := D ateTimeToS tr(Now);
  624  
  625         if m sg = '' th en
  626           wr iteln(Appl icationLog File, '')
  627         else
  628           wr iteln(Appl icationLog File, nowS tring + '  ' + msg);
  629         Flus h(Applicat ionLogFile );
  630  
  631         if e x <> nil t hen begin
  632           wi th ErrorLi st do begi n
  633              Text := ex .message;
  634              for ii :=  0 to count  - 1 do
  635                writeln( Applicatio nLogFile,  nowString  + ' ..' +  strings[ii ]);
  636           en d;
  637         end;
  638         Flus h(Applicat ionLogFile );
  639  
  640         if M sg2 <> nil  then
  641           fo r ii := 0  to Msg2.Co unt - 1 do
  642              writeln(Ap plicationL ogFile, no wString +  ' ..' + Ms g2[ii]);
  643  
  644         Leav eCriticalS ection(log CriticalSe ction);
  645       except
  646         on e : EInOutEr ror do beg in
  647           ca se e.error Code of
  648              0: ;                             (* Do Noth ing!  All  is OK! *)
  649              2: DefMess ageDlg('Fi le not fou nd:  ' + l ogFileName , mtError,  [mbOK], 0 );
  650              3: DefMess ageDlg('In valid file  name:  '  + logFileN ame, mtErr or, [mbOK] ,
  651                  0);
  652              4: DefMess ageDlg('To o many ope n files:   ' + logFil eName, mtE rror, [mbO K],
  653                  0);
  654              5, 32: Def MessageDlg ('Access d enied:  '  + logFileN ame, mtErr or, [mbOK] ,
  655                  0);
  656              100: DefMe ssageDlg(' End-Of-Fil e:  ' + lo gFileName,  mtError,  [mbOK], 0) ;
  657              101: DefMe ssageDlg(' Disk full:   ' + logF ileName, m tError, [m bOK], 0);
  658              106: DefMe ssageDlg(' Invalid in put:  ' +  logFileNam e, mtError , [mbOK],  0);
  659           el se
  660              DefMessage Dlg('Could  not write  to log fi le:' + #13 #13 +
  661                logFileN ame + #13# 13 + e.Mes sage, mtEr ror, [mbOK ], 0);
  662           en d;
  663  
  664           //  change to  allow pro gram to ru n after lo g file fai lure
  665           Cl oseFile(Ap plicationL ogFile);   // rpk 5/1 3/2011
  666           Le aveCritica lSection(l ogCritical Section);  // rpk 5/1 3/2011
  667           Er rorList.fr ee;                   // rpk 5/1 3/2011
  668           De leteCritic alSection( logCritica lSection);
  669           us eLogFile : = False;              // rpk 5/1 3/2011
  670         end;
  671       end;
  672     end;
  673   end;                                        // writeLo gMessagePr oc
  674  
  675   function A llowMultCo pies: Bool ean;
  676   var
  677     i: integ er;
  678   begin
  679     Result : = false;
  680     if Param Count > 0  then
  681       for i  := 1 to Pa ramCount d o
  682         Resu lt := Resu lt or (upp erCase(par amStr(i))  = '/AMC');
  683  
  684     if Resul t = True t hen
  685       DefMes sageDlg('Y ou are lau nching mul tiple copi es of BCMA  which sho uld be use d '
  686         +
  687         'for  debug pur poses only !', mtWarn ing, [mbOK ], 0);
  688   end;
  689  
  690   initializa tion
  691     Instruct orName :=  '';
  692     PortStri ng := '';
  693     ServerSt ring := '' ;
  694     logFileN ame := '';
  695  
  696     useDebug Mode := Fa lse;
  697     useLogFi le := True ;
  698   end.
  699