67. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 5/16/2018 9:34:26 AM 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.

67.1 Files compared

# Location File Last Modified
1 CPRS_Build_4.zip\CPRS_srcPackages\XE3\508\VA 508 JAWS Framework\Source JAWSImplementation.pas Tue May 15 15:02:44 2018 UTC
2 CPRS_Build_4.zip\CPRS_srcPackages\XE3\508\VA 508 JAWS Framework\Source JAWSImplementation.pas Wed May 16 01:34:26 2018 UTC

67.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 4 5290
Changed 3 6
Inserted 0 0
Removed 0 0

67.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

67.4 Active regular expressions

No regular expressions were active.

67.5 Comparison detail

  1   { ******** ********** ********** ********** ********** ********** ********** **********
  2     {
  3     {                                    JAWS  FrameWork
  4     {
  5     { The fr amework ke eps the ja ws scripts  updated a nd acts as  a middle  man to the
  6     { Jaws a pplication .
  7     {
  8     {
  9     {
  10     { Last m odified by : Chris Be ll
  11     { Last m odified: 5 /25/16
  12     { Last M odified De scription:
  13     {   Adde d splash s creen with  version i nformation  as well a s an updat e to the n ew log con trol
  14     {
  15     {
  16     { DONE - oJeremy Me rrill -c50 8 :
  17     Add some thing that  prevents  overwritin g of the s cript file s if anoth er
  18     app is r unning tha t's using  the JAWS D LL }
  19   { DONE -oJ eremy Merr ill -c508  : Add chec k in here  to look at  script ve rsion in J SS file -
  20       DN S      : This app ears to al ready be a dded. Mark ing as don e }
  21   { DONE -oJ eremy Merr ill -c508  :
  22     Replace  registry c ommunicati on with mu ltiple win dows - sav e strings  in the win dow titles
  23     Use Enum erateChild Windows ja ws script  function i n place of  the FindW indow func tion
  24     that's b eing used  right now. - Enumerat eChildWind ows with a  window ha ndle of 0
  25     enumerat es all win dows on th e desktop.   Will hav e to use t he first p art of the  window
  26     title as  an ID, an d the last  part as t he string  values.  W ill need t o check fo r a maximu m
  27     string l enght, pro bably have  to use mu ltiple win dows for l ong text.
  28     Will als o beed to  have a glo bal window  shared by  muiltiple  instances  of the JA WS.SR DLL.  }
  29   { DONE -oJ eremy Merr ill -c508  :
  30     Need to  add versio n checking  to TVA508 Accessibil ityManager  component
  31     and JAWS .DLL.  War ning needs  to displa y just lik e JAWS.DLL  and JAWS.  }
  32   { DONE -oJ eremy Merr ill -c508  :Figure ou t why Delp hi IDE is  loading th e DLL when  JAWS is r unning  -
  33     probably  has somet hing to do  with the  VA508 pack age being  installed  -
  34     need to  test for c sDesigning  some plac e that we' re not tes ting for ( maybe?) }
  35   { DONE -oJ eremy Merr ill -c508  :
  36     Change A PP_DATA so  that "app lication d ata" isn't  used - Wi ndows Vist a
  37       doesn't us e this val ue - get d ata from W indows API  call -  DN S      :
  38     This is  no longer  an issue s ince we do  not call  this funct ion. }
  39  
  40   { DONE -oC hris Bell  -c508 : Ad d log abil ity }
  41   { DONE -oC hris Bell  -c508 : Me rge dispat cher into  DLL to cir cumvent th e UAC warn ing with w indows 7 }
  42   { DONE -oC hris Bell  -c508 : Co rrect issu e with UIP I since Ja ws runs at  a higher  priority a s CPRS. Th is limits  API calls.  }
  43   { DONE -oC hris Bell  -c508 : Mo dify code  to accommo date for u sers lack  of Admin r ights. }
  44   { TODO -oC hris Bell  -c508 : Ma ss code cl eanup. }
  45   { TODO -oC hris Bell  -c508 : Up date jcScr iptMerge c ode }
  46   { ******** ********** ********** ********** ********** ********** ********** **********  }
  47  
  48   unit JAWSI mplementat ion;
  49  
  50   interface
  51  
  52   uses
  53   {$IFDEF VE R180}
  54     Messages ,
  55   {$ELSE}
  56     Winapi.M essages,
  57   {$ENDIF}
  58     SysUtils , Windows,  Classes,  Registry,  StrUtils,  Forms, Dia logs,
  59     ExtCtrls , VAUtils,  DateUtils , PSApi, I niFiles, A ctiveX, SH Folder,
  60     ShellAPI , VA508Acc essibility Const, fVA 508Dispatc herHiddenW indow, U_L ogObject;
  61  
  62   {$I 'VA508 ScreenRead erDLLStand ard.inc'}
  63   Function F indCommand Switch(Swi tchName: s tring; var  ReturnVal ue: string )
  64     : Boolea n; overloa d;
  65   Function F indCommand Switch(Swi tchName: s tring): Bo olean; ove rload;
  66  
  67   exports In itialize,  ShutDown,  RegisterCu stomBehavi or, Compon entData, S peakText,
  68     IsRunnin g, ConfigC hangePendi ng
  69   {$IFDEF VE R180}
  70     ;
  71   {$ELSE}
  72     , FindJa ws;
  73   {$ENDIF}
  74  
  75   implementa tion
  76  
  77   uses fVA50 8HiddenJaw sMainWindo w, FSAPILi b_TLB, Com Obj, tlhel p32, U_Spl ashScreen,
  78     Vcl.Cont rols;
  79  
  80   const
  81  
  82     JAWS_COM _OBJECT_VE RSION = '8 .0.2173';
  83     VA508_RE G_COMPONEN T_CAPTION  = 'Caption ';
  84     VA508_RE G_COMPONEN T_VALUE =  'Value';
  85     VA508_RE G_COMPONEN T_CONTROL_ TYPE = 'Co ntrolType' ;
  86     VA508_RE G_COMPONEN T_STATE =  'State';
  87     VA508_RE G_COMPONEN T_INSTRUCT IONS = 'In structions ';
  88     VA508_RE G_COMPONEN T_ITEM_INS TRUCTIONS  = 'ItemIns tructions' ;
  89     VA508_RE G_COMPONEN T_DATA_STA TUS = 'Dat aStatus';
  90     SLASH =  '\';
  91     JAWS_COM MON_SCRIPT _PATH_TEXT  = 'freedo m scientif ic\jaws\';
  92     JAWS_REG ROOT = 'SO FTWARE\Fre edom Scien tific\JAWS ';
  93     JAWS_SCR IPTDIR = ' SETTINGS\e nu';
  94     JAWS_INS TALL_DIREC TORY_VAR =  'Target';
  95     JAWS_SHA RED_DIR =  'Shared\';
  96     KEY_WOW6 4_64KEY =  $0100;
  97  
  98   type
  99     TCompare Type = (jc Prior, jcI NI, jcLine Items, jcV ersion, jc ScriptMerg e,
  100       jcINIM RG, jcLine ItemsMRG);
  101  
  102     TAddFile s = record
  103       FileNa me: string ;
  104     end;
  105  
  106     TFileInf o = record
  107       FileNa me: string ;
  108       Compar eType: TCo mpareType;
  109       Requir ed: Boolea n;
  110       Compil e: Boolean ;
  111       Exist:  Boolean;
  112       Add_To _Uses: arr ay of TAdd Files;
  113       Depend encies: ar ray of TAd dFiles;
  114     end;
  115  
  116     TFileInf oArray = A rray of TF ileInfo;
  117  
  118   const
  119     JAWS_SCR IPT_NAME =  'VA508JAW S';
  120     JAWS_APP _NAME = 'V A508APP';
  121     JAWS_SCR IPT_VERSIO N = 'VA508 _Script_Ve rsion';
  122     JAWS_FRA MEWORK_USE S = ';VA50 8_FRAMEWOR K_USES';
  123     JAWS_SCR IPT_LIST =  'VA508Scr iptList.IN I';
  124     Compiled ScriptFile Extension  = '.JSB';
  125     ScriptFi leExtensio n = '.JSS' ;
  126     ScriptDo cExtension  = '.JSD';
  127     ConfigFi leExtensio n = '.JCF' ;
  128     KeyMapEx tension =  '.JKM';
  129     Dictiona ryFileExte nsion = '. JDF';
  130     Jaws_Scr ipt_Folder  = 'Jaws S cripts';
  131  
  132     JAWS_VER SION_ERROR  = ERROR_I NTRO +
  133       'The A ccessibili ty Framewo rk can onl y communic ate with J AWS ' +
  134       JAWS_R EQUIRED_VE RSION + CR LF +
  135       'or la ter versio ns.  Pleas e update y our versio n of JAWS  to a minim um of' +
  136       CRLF +  JAWS_REQU IRED_VERSI ON +
  137       ', or  preferably  the most  recent rel ease, to a llow the A ccessibili ty' + CRLF
  138       + 'Fra mework to  communicat e with JAW S.  If you  are getti ng this me ssage' +
  139       CRLF +  'and you  already ha ve a compa tible vers ion of JAW S, please  contact yo ur'
  140       + CRLF  + 'system  administr ator, and  request th at they ru n, with ad ministrato r rights,'
  141       + CRLF  + 'the JA WSUpdate a pplication  located i n the \Pro gram Files \VistA\' +
  142       CRLF +  'Common F iles direc tory. JAWS Update is  not requir ed for JAW S' + CRLF
  143       + 'ver sions ' +  JAWS_COM_O BJECT_VERS ION + ' an d above.'  + CRLF;
  144  
  145     JAWS_FIL E_ERROR =  ERROR_INTR O +
  146       'The J AWS interf ace with t he Accessi bility Fra mework req uires the  ability' +
  147       CRLF +  'to write  files to  the hard d isk, but t he followi ng error i s occurrin g trying t o'
  148       + CRLF  + 'write  to the dis k:' + CRLF  + '%s' +  CRLF +
  149       'Pleas e contact  your syste m administ rator in o rder to en sure that  your ' +
  150       CRLF +  'security  privilege s allow yo u to write  files to  the hard d isk.' +
  151       CRLF +  'If you a re sure yo u have the se privile ges, your  hard disk  may be ful l.  Until'
  152       + CRLF  + 'this p roblem is  resolved,  the Access ibility Fr amework wi ll not be  able to'
  153       + CRLF  + 'commun icate with  JAWS.';
  154  
  155     JAWS_USE R_MISSMATC H_ERROR =  ERROR_INTR O +
  156       'An er ror has be en detecte d in the s tate of JA WS that wi ll not all ow the' +
  157       CRLF +  'Accessib ility Fram ework to c ommunicate  with JAWS  until JAW S is shut'
  158       + CRLF  + 'down a nd restart ed.  Pleas e restart  JAWS at th is time.';
  159  
  160     DLL_VERS ION_ERROR  = ERROR_IN TRO +
  161       'The A ccessibili ty Framewo rk is at v ersion %s,  but the r equired JA WS' + CRLF
  162       + 'sup port files  are only  at version  %s.  The  new suppor t files sh ould have'
  163       + CRLF  + 'been r eleased wi th the lat est versio n of the s oftware yo u are curr ently'
  164       + CRLF  + 'runnin g.  The Ac cessibilit y Framewor k will not  be able t o communic ate'
  165       + CRLF  + 'with J AWS until  these supp ort files  are instal led.  Plea se contact  your'
  166       + CRLF  + 'system  administr ator for a ssistance. ';
  167  
  168     JAWS_AUT O_NOT_RUNN ING = ERRO R_INTRO +
  169       'The A ccessibili ty Framewo rk was una ble to ide ntify a ru nning inst ance of JA WS.'
  170       + ' If  you are r unning JAW S ' + JAWS _REQUIRED_ VERSION +  ' or later  please '
  171       + 'ver ify your s hortcut co ntains the  JAWS exec utable nam e' + CRLF  + CRLF +
  172       'Examp le: /SCREA DER:JAWS A pplication  Name.exe. ' + CRLF +
  173       'If yo u do not h ave access  to update  the %s sh ortcut, pl ease conta ct your lo cal '
  174       + ' su pport/help  personnel .' + CRLF  +
  175       'This  message bo x will aut omatically  close aft er 30 seco nds';
  176  
  177     JAWS_NOT _RUNNING =  ERROR_INT RO +
  178       'The A ccessibili ty Framewo rk was una ble to ide ntify a ru nning inst ance of JA WS.'
  179       + ' Th e Accessib ility Fram ework will  not be ab le to comm unicate' +
  180       'with  JAWS until  the corre ct JAWS ap plication  name is pa ssed into  the shortc ut for %s  .'
  181       + CRLF  + CRLF +  '/SCREADER =:%s is no t running  ' + CRLF +
  182       'If yo u do not h ave access  to update  the %s sh ortcut, pl ease conta ct your lo cal '
  183       + ' su pport/help  personnel .' + CRLF  +
  184       'This  message bo x will aut omatically  close aft er 30 seco nds';
  185  
  186     JAWS_ERR OR_VERSION  = 1;
  187     JAWS_ERR OR_FILE_IO  = 2;
  188     JAWS_ERR OR_USER_PR OBLEM = 3;
  189     DLL_ERRO R_VERSION  = 4;
  190     JAWS_ERR OR_COUNT =  4;
  191     JAWS_REL OAD_DELAY  = 500;
  192     MB_TIMED OUT = 3200 0;
  193  
  194   var
  195     JAWSErro rMessage:  array [1 . . JAWS_ERR OR_COUNT]  of string  = (
  196       JAWS_V ERSION_ERR OR,
  197       JAWS_F ILE_ERROR,
  198       JAWS_U SER_MISSMA TCH_ERROR,
  199       DLL_VE RSION_ERRO R
  200     );
  201  
  202     JAWSErro rsShown: a rray [1 ..  JAWS_ERRO R_COUNT] o f Boolean  = (
  203       FALSE,
  204       FALSE,
  205       FALSE,
  206       FALSE
  207     );
  208  
  209   type
  210     TJAWSSay String = f unction(St ringToSpea k: PChar;  Interrupt:  BOOL)
  211       : BOOL ; stdcall;
  212     TJAWSRun Script = f unction(Sc riptName:  PChar): BO OL; stdcal l;
  213  
  214     TStartup ID = recor d
  215       Handle : HWND;
  216       Instan ceID: Inte ger;
  217       MsgID:  Integer;
  218     end;
  219  
  220     tCompile File = rec ord
  221       FileNa me: String ;
  222       Compil ed: Boolea n;
  223       Compil er: String ;
  224       Depend entFile: A rray of tC ompileFile ;
  225       functi on Compile File(var R tnMsg: Str ing): Bool ean;
  226     end;
  227  
  228     TJawsRec ord = reco rd
  229       Versio n: Double;
  230       Compil er: string ;
  231       Defaul tScriptDir : String;
  232       UserSc riptDir: S tring;
  233       FDicti onaryFileN ame: strin g;
  234       FConfi gFile: str ing;
  235       FKeyMa pFile: str ing;
  236       FKeyMa pINIFile:  TINIFile;
  237       FKeyMa pINIFileMo dified: Bo olean;
  238       FAssig nedKeys: T StringList ;
  239       FConfi gINIFile:  TINIFile;
  240       FConfi gINIFileMo dified: Bo olean;
  241       FDicti onaryFile:  TStringLi st;
  242       FDicti onaryFileM odified: B oolean;
  243     end;
  244  
  245     TJAWSMan ager = cla ss
  246     strict p rivate
  247       FRequi redFilesFo und: Boole an;
  248       FMainF orm: TfrmV A508Hidden JawsMainWi ndow;
  249       FWasSh utdown: Bo olean;
  250       FJAWSF ileError:  string;
  251       FHidde nJaws: TFo rm;
  252      // FRoo tScriptFil eName: str ing;
  253     //  FRoo tScriptApp FileName:  string;
  254       JAWSAP I: IJawsAp i;
  255     private
  256       fCompo nentCallBa ckProc: TC omponentDa taRequestP roc;
  257       fScrip tFilesChan ged: Boole an;
  258       proced ure ShutDo wn;
  259       proced ure MakeFi leWritable (FileName:  string);
  260       proced ure Launch MasterAppl ication;
  261       proced ure KillIN IFiles(Sen der: TObje ct);
  262       proced ure Reload Configurat ion;
  263       proced ure Ensure Window;
  264     public
  265       constr uctor Crea te;
  266       destru ctor Destr oy; overri de;
  267       class  procedure  ShowError( ErrorNumbe r: Integer ); overloa d;
  268       class  procedure  ShowError( ErrorNumbe r: Integer ;
  269         data : array of  const); o verload;
  270       // cla ss functio n GetPathF romJAWS(Pa thID: Inte ger;
  271       // DoL owerCase:  boolean =  TRUE): str ing;
  272       class  function G etJAWSWind ow: HWND;
  273       class  function I sRunning(H ighVersion , LowVersi on: Word):  BOOL;
  274       class  function F indJaws():  HWND;
  275       functi on Initial ize(Compon entCallBac kProc: TCo mponentDat aRequestPr oc): BOOL;
  276       proced ure SendCo mponentDat a(WindowHa ndle: HWND ; DataStat us: LongIn t;
  277         Capt ion, Value , data, Co ntrolType,  State, In structions ,
  278         Item Instructio ns: PChar) ;
  279       proced ure SpeakT ext(Text:  PChar);
  280       proced ure Regist erCustomBe havior(Bef ore, After : string;  Action: In teger);
  281       class  function J AWSVersion OK: Boolea n;
  282       class  function J AWSTalking 2CurrentUs er: Boolea n;
  283       functi on FileErr orExists:  Boolean;
  284       proced ure GetScr iptFiles(v ar info: T FileInfoAr ray);
  285       proper ty Require dFilesFoun d: Boolean  read FReq uiredFiles Found;
  286       proper ty MainFor m: TfrmVA5 08HiddenJa wsMainWind ow read FM ainForm;
  287       proper ty ScriptF ilesChange d: boolean  read fScr iptFilesCh anged;
  288     end;
  289  
  290   function M essageBoxT imeOutW(HW ND: HWND;  lpText: PW ideChar; l pCaption:  PWideChar;
  291     uType: U INT; wLang uageId: Wo rd; dwMill iseconds:  DWORD): In teger; std call;
  292     external  user32 na me 'Messag eBoxTimeou tW';
  293   function M essageBoxT imeOutA(HW ND: HWND;  lpText: PC har; lpCap tion: PCha r;
  294     uType: U INT; wLang uageId: Wo rd; dwMill iseconds:  DWORD): In teger; std call;
  295     external  user32 na me 'Messag eBoxTimeou tA';
  296  
  297   var
  298     // ***** ********** ********** ********** ********** ********** ********** *
  299     // Archi ved Variab le
  300     // ***** ********** ********** ********** ********** ********** ********** *
  301     // DLLMe ssageID: U INT = 0;
  302  
  303     JAWSMana ger: TJAWS Manager =  nil;
  304     JawsReco rd: array  of TJawsRe cord;
  305     ScriptFi les: TFile InfoArray;
  306     JAWSHand le: HWND =  0;
  307     UserSpla sh: tSplas hTaskDialo g;
  308  
  309   {$REGION ' Add export  methods t o this reg ion'}
  310  
  311     // ***** ********** ********** ********** ********** ********** ********** *
  312     // Ensur e the JAWS manager ob ject exist
  313     // ***** ********** ********** ********** ********** ********** ********** *
  314   procedure  EnsureMana ger;
  315   begin
  316     if not a ssigned(JA WSManager)  then
  317       JAWSMa nager := T JAWSManage r.Create;
  318   end;
  319  
  320   // ******* ********** ********** ********** ********** ********** *********
  321   // Checks  to see if  the screen  reader is  currently  running
  322   // ******* ********** ********** ********** ********** ********** *********
  323   function I sRunning(H ighVersion , LowVersi on: Word):  BOOL; std call;
  324   begin
  325     EnsureMa nager; //  need to pr eload the  directorie s
  326     Result : = TJAWSMan ager.IsRun ning(HighV ersion, Lo wVersion);
  327   end;
  328  
  329   function F indJaws():  BOOL; std call;
  330   begin
  331     EnsureMa nager; //  need to pr eload the  directorie s
  332     JAWSHand le := TJAW SManager.F indJaws;
  333     Result : = (JAWSHan dle <> 0);
  334   end;
  335  
  336   // ******* ********** ********** ********** ********** ********** *********
  337   // Execute d after Is Running re turns TRUE , when the  DLL is ac cepted
  338   // as the  screen rea der of cho ice
  339   // ******* ********** ********** ********** ********** ********** *********
  340   function I nitializeS ub(Compone ntCallBack Proc: TCom ponentData RequestPro c): BOOL;
  341   begin
  342     EnsureMa nager;
  343     UserSpla sh.TaskMax Prog := (3  + Length( ScriptFile s)) * Leng th(JawsRec ord) + 1;
  344     Result : = JAWSMana ger.Initia lize(Compo nentCallBa ckProc);
  345   end;
  346  
  347   function I nitialize( ComponentC allBackPro c: TCompon entDataReq uestProc)
  348     : BOOL;  stdcall;
  349   var
  350    VersionNu m: string;
  351    i, ForceN um: Intege r;
  352   begin
  353     //Need t o make thr eaded
  354     userSpla sh := nil;
  355  
  356     //If not  show task  dialog
  357     ForceNum  := -1;
  358     if  Find CommandSwi tch('FORCE UPD') then
  359      ForceNu m := 0
  360     else beg in
  361       for I  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  362       begin
  363         Vers ionNum :=  FloatToStr (JawsRecor d[i].Versi on);
  364         if P os('.', Ve rsionNum)  > 0 then
  365           Ve rsionNum : = Copy(Ver sionNum, 1 , Pos('.',  VersionNu m) - 1);
  366           if  FindComma ndSwitch(' FORCEUPD'  + VersionN um) then
  367           be gin
  368            F orceNum :=  StrToIntD ef(Version Num, 0);
  369            b reak;
  370           en d;
  371       end;
  372     end;
  373  
  374      userSpl ash := tSp lashTaskDi alog.Creat e(Initiali zeSub, Com ponentCall BackProc,  LogInterfa ce.Active,  ForceNum) ;
  375      try
  376       if Log Interface. Active the n
  377        userS plash.LogP ath := Log Interface. LogFile;
  378       userSp lash.Show;
  379       result  := userSp lash.Retur nValue;
  380       if Res ult then
  381       begin
  382         JAWS Manager.En sureWindow ;
  383         JAWS Manager.La unchMaster Applicatio n;
  384         if J AWSManager .ScriptFil esChanged  then
  385         begi n
  386          JAW SManager.M ainForm.Co nfigReload Needed;
  387         end;
  388       end;
  389  
  390      finally
  391      FreeAnd Nil(userSp lash);
  392      end;
  393  
  394   end;
  395  
  396   // ******* ********** ********** ********** ********** ********** *********
  397   // Execute d when the  DLL is un loaded or  screen rea der is no  longer
  398   // needed
  399   // ******* ********** ********** ********** ********** ********** *********
  400   procedure  ShutDown;  stdcall;
  401   begin
  402     if assig ned(JAWSMa nager) the n
  403     begin
  404       JAWSMa nager.Shut Down;
  405       FreeAn dNil(JAWSM anager);
  406     end;
  407   end;
  408  
  409   // ******* ********** ********** ********** ********** ********** *********
  410   // Determi nes if con figuration  changes a re pending
  411   // ******* ********** ********** ********** ********** ********** *********
  412   function C onfigChang ePending:  Boolean; s tdcall;
  413   begin
  414     Result : = FALSE;
  415     if assig ned(JAWSMa nager) and  assigned( JAWSManage r.MainForm ) and
  416       (JAWSM anager.Mai nForm.Conf igChangePe nding) the n
  417       Result  := TRUE;
  418   end;
  419  
  420   // ******* ********** ********** ********** ********** ********** *********
  421   // Returns  Component  Data as r equested b y the scre en reader
  422   // ******* ********** ********** ********** ********** ********** *********
  423   procedure  ComponentD ata(Window Handle: HW ND; DataSt atus: Long Int = DATA _NONE;
  424     Caption:  PChar = n il; Value:  PChar = n il; data:  PChar = ni l;
  425     ControlT ype: PChar  = nil; St ate: PChar  = nil; In structions : PChar =  nil;
  426     ItemInst ructions:  PChar = ni l); stdcal l;
  427   begin
  428     EnsureMa nager;
  429     JAWSMana ger.SendCo mponentDat a(WindowHa ndle, Data Status, Ca ption, Val ue, data,
  430       Contro lType, Sta te, Instru ctions, It emInstruct ions);
  431   end;
  432  
  433   // ******* ********** ********** ********** ********** ********** *********
  434   // Instruc ts the Scr een Reader  to say th e specifie d text
  435   // ******* ********** ********** ********** ********** ********** *********
  436   procedure  SpeakText( Text: PCha r); stdcal l;
  437   begin
  438     EnsureMa nager;
  439     JAWSMana ger.SpeakT ext(Text);
  440   end;
  441  
  442   // ******* ********** ********** ********** ********** ********** *********
  443   // Registe rs any cus tom behavi or
  444   // ******* ********** ********** ********** ********** ********** *********
  445   procedure  RegisterCu stomBehavi or(Behavio rType: Int eger; Befo re, After:  PChar);
  446   begin
  447     EnsureMa nager;
  448     JAWSMana ger.Regist erCustomBe havior(Bef ore, After , Behavior Type);
  449   end;
  450  
  451   {$ENDREGIO N}
  452   {$REGION ' Add TJAWSM anager met hods to th is region' }
  453  
  454   // ******* ********** ********** ********** ********** ********** *********
  455   // Makes a  file writ able
  456   // ******* ********** ********** ********** ********** ********** *********
  457   procedure  TJAWSManag er.MakeFil eWritable( FileName:  string);
  458   const
  459   {$WARNINGS  OFF} // D on't care  about plat form speci fic warnin g
  460     NON_WRIT ABLE_FILE_ ATTRIB = f aReadOnly  or faHidde n;
  461   {$WARNINGS  ON}
  462     WRITABLE _FILE_ATTR IB = faAny File and ( not NON_WR ITABLE_FIL E_ATTRIB);
  463  
  464   var
  465     Attrib:  Integer;
  466   begin
  467   {$WARNINGS  OFF} // D on't care  about plat form speci fic warnin g
  468     Attrib : = FileGetA ttr(FileNa me);
  469   {$WARNINGS  ON}
  470     if (Attr ib and NON _WRITABLE_ FILE_ATTRI B) <> 0 th en
  471     begin
  472       Attrib  := Attrib  and WRITA BLE_FILE_A TTRIB;
  473   {$WARNINGS  OFF} // D on't care  about plat form speci fic warnin g
  474       if Fil eSetAttr(F ileName, A ttrib) <>  0 then
  475   {$WARNINGS  ON}
  476         FJAW SFileError  := 'Could  not chang e read-onl y attribut e of file  "' +
  477           Fi leName + ' "';
  478  
  479     end;
  480   end;
  481  
  482   // ******* ********** ********** ********** ********** ********** *********
  483   // Create  method for  the JawsM anager
  484   // ******* ********** ********** ********** ********** ********** *********
  485   constructo r TJAWSMan ager.Creat e;
  486   const
  487     COMPILER _FILENAME  = 'scompil e.exe';
  488     // JAWS_ APP_NAME =  'VA508APP ';
  489  
  490     function  ContinueT oLoad(Temp SubDir: st ring): Boo lean;
  491     Var
  492       TempUS Dir, TempD SDir, Path ToCheck: S tring;
  493       idx1,  idx2: Inte ger;
  494     begin
  495       // Def ault Scrip t
  496       TempDS Dir := Get SpecialFol derPath(CS IDL_COMMON _APPDATA)  +
  497         JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(TempSub Dir);
  498  
  499       // Use r Script
  500       TempUS Dir := Get SpecialFol derPath(CS IDL_APPDAT A) +
  501         JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(TempSub Dir);
  502  
  503       // Scr ipt Folder
  504       PathTo Check := ' ';
  505       idx1 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, Temp USDir);
  506       idx2 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, Temp DSDir);
  507  
  508       PathTo Check := C opy(TempUS Dir, 1, id x1 - 1) +  Copy(TempD SDir, idx2 , MaxInt);
  509  
  510       Result  := Direct oryExists( PathToChec k);
  511       // Che ck to see  if directo ry exist ( they have  ran jaws)
  512  
  513     end;
  514  
  515   // ******* ********** ********** ********** ********** ********** *********
  516   // Load th e jaws dir ectories v ia regestr ies
  517   // ******* ********** ********** ********** ********** ********** *********
  518     procedur e LoadJaws Directorie s;
  519     var
  520       reg: T Registry;
  521       keys:  TStringLis t;
  522       I: Int eger;
  523       key, D ir, SubDir , Version:  string;
  524     begin
  525       keys : = TStringL ist.Create ;
  526       try
  527         reg  := TRegist ry.Create( KEY_READ o r KEY_WOW6 4_64KEY);
  528         try
  529           re g.RootKey  := HKEY_LO CAL_MACHIN E;
  530           re g.OpenKey( JAWS_REGRO OT, FALSE) ;
  531           re g.GetKeyNa mes(keys);
  532           fo r I := 0 t o keys.Cou nt - 1 do
  533           be gin
  534              Version :=  keys[I];
  535              key := JAW S_REGROOT  + '\' + ke ys[I] + '\ ';
  536              reg.CloseK ey;
  537              SubDir :=  Version +  '\' + JAWS _SCRIPTDIR ;
  538              if reg.Ope nKey(key,  FALSE) the n
  539              begin
  540                Dir := L owerCase(r eg.ReadStr ing(JAWS_I NSTALL_DIR ECTORY_VAR ));
  541                LogInter face.LogTe xt('Jaws F ound', 'Ve rsion: ' +  Version +  #13#10 +
  542                  'Direc tory: ' +  Dir);
  543  
  544  
  545                Dir := A ppendBackS lash(Dir)  + COMPILER _FILENAME;
  546                if FileE xists(Dir)  and Conti nueToLoad( SubDir) th en
  547                begin
  548                  SetLen gth(JawsRe cord, Leng th(JawsRec ord) + 1);
  549                  JawsRe cord[high( JawsRecord )].Version  :=
  550                    StrT ofloatDef( Version, - 1);
  551                  JawsRe cord[high( JawsRecord )].Compile r := Dir;
  552                  Dir :=  GetSpecia lFolderPat h(CSIDL_CO MMON_APPDA TA) +
  553                    JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(SubDir) ;
  554                  JawsRe cord[high( JawsRecord )].Default ScriptDir  := Dir;
  555                  Dir :=  GetSpecia lFolderPat h(CSIDL_AP PDATA) +
  556                    JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(SubDir) ;
  557                  JawsRe cord[high( JawsRecord )].UserScr iptDir :=  Dir;
  558                end;
  559              end;
  560  
  561           en d;
  562         fina lly
  563           re g.free;
  564         end;
  565       finall y
  566         keys .free;
  567       end;
  568     end;
  569  
  570   // ******* ********** ********** ********** ********** ********** *********
  571   // Ensure  all the re quired fil es are pre sent in th e vista fo lder
  572   // ******* ********** ********** ********** ********** ********** *********
  573     procedur e FindJAWS RequiredFi les;
  574     var
  575       path:  string;
  576       I: Int eger;
  577       LogTxt : string;
  578     begin
  579       SetLen gth(path,  MAX_PATH);
  580       SetLen gth(path,  GetModuleF ileName(HI nstance, P Char(path) , Length(p ath)));
  581       path : = ExtractF ilePath(pa th);
  582       path : = AppendBa ckSlash(pa th);
  583       // loo k for the  script fil es in the  same direc tory as th is DLL
  584  
  585       FRequi redFilesFo und := TRU E;
  586  
  587       // Loo k up the f iles
  588       if Len gth(Script Files) = 0  then
  589         GetS criptFiles (ScriptFil es);
  590  
  591       if Len gth(Script Files) > 0  then
  592       begin
  593         LogI nterface.L ogText(' S cripts  ',
  594           'F older:' +  ExtractFil ePath(Scri ptFiles[0] .FileName) )
  595       end
  596       else
  597         LogI nterface.L ogText(' S cripts  ',
  598           '! ! No files  to lookup  !! Please  check the  VA508Scri ptList.INI ');
  599  
  600       // now  ensure th at the req uired file s are ther e
  601       for I  := low(Scr iptFiles)  to high(Sc riptFiles)  do
  602       begin
  603         LogT xt := 'Fil e Name:' +  ExtractFi leName(Scr iptFiles[I ].FileName );
  604         if S criptFiles [I].Requir ed then
  605         begi n
  606           Lo gTxt := Lo gTxt + #13 #10 + 'Req uired: YES ';
  607           if  not Scrip tFiles[I]. Exist then
  608           be gin
  609              FRequiredF ilesFound  := FALSE;
  610              LogTxt :=  LogTxt + # 13#10 + 'F ile Found:  NO';
  611              // break;
  612           en d
  613           el se
  614              LogTxt :=  LogTxt + # 13#10 + 'F ile Found:  YES';
  615         end
  616         else
  617         begi n
  618           Lo gTxt := Lo gTxt + #13 #10 + 'Req uired: NO' ;
  619           if  not Scrip tFiles[I]. Exist then
  620              LogTxt :=  LogTxt + # 13#10 + 'F ile Found:  NO'
  621           el se
  622              LogTxt :=  LogTxt + # 13#10 + 'F ile Found:  YES';
  623  
  624         end;
  625  
  626         LogI nterface.L ogText(Int ToStr(I +  1) + '/' +  IntToStr( Length(Scr iptFiles)
  627           -  1), LogTxt );
  628       end;
  629     end;
  630  
  631   begin
  632     SetLengt h(JawsReco rd, 0);
  633     LoadJaws Directorie s;
  634     if Lengt h(JawsReco rd) > 0 th en
  635       FindJA WSRequired Files;
  636     if not F RequiredFi lesFound t hen
  637       ShowEr ror(JAWS_E RROR_FILE_ IO, ['Requ ired files  missing'] )
  638   end;
  639  
  640   // ******* ********** ********** ********** ********** ********** *********
  641   // Destroy  method fo r the Jaws Manager
  642   // ******* ********** ********** ********** ********** ********** *********
  643   destructor  TJAWSMana ger.Destro y;
  644   begin
  645     SetLengt h(JawsReco rd, 0);
  646     ShutDown ;
  647     inherite d;
  648   end;
  649  
  650   // ******* ********** ********** ********** ********** ********** *********
  651   // Returns  if an err or has bee n captured
  652   // ******* ********** ********** ********** ********** ********** *********
  653   function T JAWSManage r.FileErro rExists: B oolean;
  654   begin
  655     Result : = (FJAWSFi leError <>  '');
  656   end;
  657  
  658   // ******* ********** ********** ********** ********** ********** *********
  659   // Fills o ut the fil e array wi th sciprts  to be mov ed over
  660   // ******* ********** ********** ********** ********** ********** *********
  661   procedure  TJAWSManag er.GetScri ptFiles(va r info: TF ileInfoArr ay);
  662   var
  663     ScriptsF ile: TINIF ile;
  664     path, Sc riptsFileN ame, TmpSt r: string;
  665     Scripts:  TStringLi st;
  666     I, X, Y:  Integer;
  667  
  668     function  FindScrip tFileLocat ion(aBaseP ath, aFile Name: stri ng): Strin g;
  669     var
  670       Script Dir: Strin g;
  671     begin
  672       aBaseP ath := App endBackSla sh(aBasePa th);
  673       Script Dir := Jaw s_Script_F older;
  674       Script Dir := App endBackSla sh(ScriptD ir);
  675       if Fil eExists(aB asePath +  ScriptDir  + aFileNam e) then
  676         Resu lt := aBas ePath + Sc riptDir
  677       else i f FileExis ts(aBasePa th + aFile Name) then
  678         Resu lt := aBas ePath
  679       else
  680         Resu lt := '';
  681     end;
  682  
  683     function  LoadInfoR ec(aPatchD ir, aFileN ame, Value : String):  TFileInfo ;
  684     var
  685       TmpCom pare: stri ng;
  686       FoundP ath: Strin g;
  687       TmpStr Lst: TStri ngList;
  688       I: Int eger;
  689     begin
  690       SetLen gth(Result .Add_To_Us es, 0);
  691       FoundP ath := Fin dScriptFil eLocation( aPatchDir,  aFileName );
  692       if Fou ndPath <>  '' then
  693       begin
  694         Resu lt.FileNam e := Appen dBackSlash (FoundPath ) + aFileN ame;
  695         Resu lt.Exist : = FileExis ts(Result. FileName);
  696       end
  697       else
  698       begin
  699         Resu lt.FileNam e := aFile Name;
  700         Resu lt.Exist : = FALSE;
  701       end;
  702  
  703       TmpCom pare := Pi ece(Value,  '|', 1);
  704       if Upp erCase(Tmp Compare) =  'JCPRIOR'  then
  705         Resu lt.Compare Type := jc Prior
  706       else i f UpperCas e(TmpCompa re) = 'JCI NI' then
  707         Resu lt.Compare Type := jc INI
  708       else i f UpperCas e(TmpCompa re) = 'JCL INEITEMS'  then
  709         Resu lt.Compare Type := jc LineItems
  710       else i f UpperCas e(TmpCompa re) = 'JCV ERSION' th en
  711         Resu lt.Compare Type := jc Version
  712       else i f UpperCas e(TmpCompa re) = 'JCS CRIPTMERGE ' then
  713         Resu lt.Compare Type := jc ScriptMerg e
  714       else i f UpperCas e(TmpCompa re) = 'JCI NIMRG' the n
  715         Resu lt.Compare Type := jc INIMRG
  716       else i f UpperCas e(TmpCompa re) = 'JCL INEITEMSMR G' then
  717         Resu lt.Compare Type := jc LineItemsM RG;
  718  
  719       TmpCom pare := Pi ece(Value,  '|', 2);
  720       if Upp erCase(Tmp Compare) =  'TRUE' th en
  721         Resu lt.Require d := TRUE
  722       else i f UpperCas e(TmpCompa re) = 'FAL SE' then
  723         Resu lt.Require d := FALSE ;
  724  
  725       TmpCom pare := Pi ece(Value,  '|', 3);
  726       if Upp erCase(Tmp Compare) =  'TRUE' th en
  727         Resu lt.Compile  := TRUE
  728       else i f UpperCas e(TmpCompa re) = 'FAL SE' then
  729         Resu lt.Compile  := FALSE;
  730  
  731       TmpCom pare := Pi ece(Value,  '|', 4);
  732       if Tri m(TmpCompa re) <> ''  then
  733       begin
  734         TmpC ompare :=  Piece(TmpC ompare, '[ ', 2);
  735         TmpC ompare :=  Piece(TmpC ompare, '] ', 1);
  736         TmpS trLst := T StringList .Create;
  737         try
  738           Tm pStrLst.Te xt := TmpC ompare;
  739           fo r I := 0 t o TmpStrLs t.Count -  1 do
  740           be gin
  741              SetLength( Result.Add _To_Uses,  Length(Res ult.Add_To _Uses) + 1 );
  742              Result.Add _To_Uses[H igh(Result .Add_To_Us es)].FileN ame :=
  743                TmpStrLs t.Strings[ I];
  744           en d;
  745         fina lly
  746           Tm pStrLst.fr ee;
  747         end;
  748       end;
  749  
  750     end;
  751  
  752     function  LoadOverW rites(Sect ionName: S tring): Bo olean;
  753     var
  754       I, X:  Integer;
  755       FileNa me, extNam e: String;
  756     begin
  757       if Scr iptsFile.S ectionExis ts(Section Name) then
  758       begin
  759         Resu lt := TRUE ;
  760         Scri ptsFile.Re adSectionV alues(Sect ionName, S cripts);
  761         for  I := 0 to  Scripts.Co unt - 1 do
  762         begi n
  763           //  if script  is named  after the  app then r eplace
  764           Fi leName :=  Piece(Extr actFileNam e(Scripts. Names[I]),  '.', 1);
  765           ex tName := P iece(Extra ctFileName (Scripts.N ames[I]),  '.', 2);
  766           //  Section n ame should  be the ap plications  name
  767           if  UpperCase (FileName)  = UpperCa se(Section Name) then
  768           be gin
  769              if Pos('MR G', UpperC ase(Piece( Scripts.Va lues[Scrip ts.Names[I ]], '|',
  770                1))) = 0  then
  771              begin
  772                for X :=  Low(info)  to High(i nfo) do
  773                begin
  774                  if (Up perCase(Pi ece(Extrac tFileName( info[X].Fi leName), ' .', 1))
  775                    = Up perCase(JA WS_APP_NAM E)) and
  776                    (Upp erCase(Pie ce(Extract FileName(i nfo[X].Fil eName), '. ', 2))
  777                    = Up perCase(ex tName)) th en
  778                  begin
  779                    // o verwrite i ts corrisp onding va5 08app file
  780                    info [X] := Loa dInfoRec(p ath, Scrip ts.Names[I ],
  781                      Sc ripts.Valu es[Scripts .Names[I]] );
  782                    brea k;
  783                  end;
  784                end;
  785              end
  786              else
  787              begin
  788                SetLengt h(info, Le ngth(info)  + 1);
  789                info[Hig h(info)] : = LoadInfo Rec(path,  Scripts.Na mes[I],
  790                  Script s.Values[S cripts.Nam es[I]]);
  791              end;
  792           en d
  793           el se
  794           be gin
  795              SetLength( info, Leng th(info) +  1);
  796              info[High( info)] :=  LoadInfoRe c(path, Sc ripts.Name s[I],
  797                Scripts. Values[Scr ipts.Names [I]]);
  798           en d;
  799         end;
  800       end
  801       else
  802         Resu lt := FALS E;
  803     end;
  804  
  805   begin
  806     SetLengt h(path, MA X_PATH);
  807     SetLengt h(path, Ge tModuleFil eName(HIns tance, PCh ar(path),  Length(pat h)));
  808     path :=  ExtractFil ePath(path );
  809     path :=  AppendBack Slash(path );
  810     ScriptsF ileName :=  FindScrip tFileLocat ion(path,  JAWS_SCRIP T_LIST);
  811     if Scrip tsFileName  <> '' the n
  812     begin
  813       Script sFileName  := AppendB ackSlash(S criptsFile Name) + JA WS_SCRIPT_ LIST;
  814       if Fil eExists(Sc riptsFileN ame) then
  815       begin
  816         Scri ptsFile :=  TINIFile. Create(Scr iptsFileNa me);
  817         Scri pts := TSt ringList.C reate;
  818         try
  819           Se tLength(in fo, 0);
  820           Sc riptsFile. ReadSectio nValues('S CRIPTS', S cripts);
  821           fo r I := 0 t o Scripts. Count - 1  do
  822           be gin
  823              SetLength( info, Leng th(info) +  1);
  824              info[High( info)] :=  LoadInfoRe c(path, Sc ripts.Name s[I],
  825                Scripts. Values[Scr ipts.Names [I]]);
  826           en d;
  827  
  828           //  Now check  for custo m overwrit es
  829           //  first loo k for gene ral App
  830           Tm pStr := Pi ece(Extrac tFileName( ParamStr(0 )), '.', 1 );
  831           Lo adOverWrit es(TmpStr) ;
  832  
  833           //  second lo ok for a s pecific ve rsion
  834           Tm pStr := Tm pStr + '|'  + FileVer sionValue( ParamStr(0 ),
  835              FILE_VER_F ILEVERSION );
  836           Lo adOverWrit es(TmpStr) ;
  837  
  838         fina lly
  839           Sc riptsFile. free;
  840         end;
  841       end;
  842     end;
  843  
  844     // Now u pdate the  dependenci es
  845     for I :=  Low(info)  to High(i nfo) do
  846     begin
  847       if Len gth(info[I ].Add_To_U ses) > 0 t hen
  848       begin
  849         for  X := Low(i nfo[I].Add _To_Uses)  to High(in fo[I].Add_ To_Uses) d o
  850         begi n
  851           fo r Y := Low (info) to  High(info)  do
  852           be gin
  853              if UpperCa se(Extract FileName(i nfo[Y].Fil eName))
  854                = UpperC ase(info[I ].Add_To_U ses[X].Fil eName) the n
  855              begin
  856                SetLengt h(info[Y]. Dependenci es, Length (info[Y].D ependencie s) + 1);
  857                info[Y]. Dependenci es[High(in fo[Y].Depe ndencies)] .FileName  := Extract FileName(i nfo[I].Fil eName);
  858                break;
  859              end;
  860           en d;
  861         end;
  862         SetL ength(info [I].Add_To _Uses, 0);
  863       end;
  864     end;
  865  
  866   end;
  867  
  868   // ******* ********** ********** ********** ********** ********** *********
  869   // Return  the handle  of the Ja ws applica tion
  870   // ******* ********** ********** ********** ********** ********** *********
  871   class func tion TJAWS Manager.Ge tJAWSWindo w: HWND;
  872   const
  873     VISIBLE_ WINDOW_CLA SS: PChar  = 'JFWUI2' ;
  874     VISIBLE_ WINDOW_TIT LE: PChar  = 'JAWS';
  875     VISIBLE_ WINDOW_TIT LE2: PChar  = 'Remote  JAWS';
  876   begin
  877     if JAWSH andle = 0  then
  878     begin
  879       JAWSHa ndle := Fi ndWindow(V ISIBLE_WIN DOW_CLASS,  VISIBLE_W INDOW_TITL E);
  880       if JAW SHandle =  0 then
  881         JAWS Handle :=  FindWindow (VISIBLE_W INDOW_CLAS S, VISIBLE _WINDOW_TI TLE2);
  882       if JAW SHandle =  0 then
  883         JAWS Handle :=  FindJaws() ;
  884     end;
  885  
  886     Result : = JAWSHand le;
  887   end;
  888  
  889   // ******* ********** ********** ********** ********** ********** *********
  890   // Return  the handle  of an app lication
  891   // ******* ********** ********** ********** ********** ********** *********
  892   function F indHandle( exeFileNam e: string) : HWND;
  893   type
  894     TEInfo =  record
  895       PID: D WORD;
  896       HWND:  THandle;
  897     end;
  898  
  899     function  CallBack( Wnd: DWORD ; var EI:  TEInfo): B OOL; stdca ll;
  900     var
  901       PID: D WORD;
  902     begin
  903       GetWin dowThreadP rocessID(W nd, @PID); ;
  904       Result  := (PID < > EI.PID)  and (GetPa rent(Wnd)  <> 0);
  905       // Res ult := (PI D <> EI.PI D) or (not  IsWindowV isible(Wnd )) or
  906       // (no t IsWindow Enabled(Wn d));
  907       if not  Result th en
  908         EI.H WND := Wnd ;
  909     end;
  910  
  911   var
  912     Continue Loop: BOOL ;
  913     FSnapsho tHandle: T Handle;
  914     FProcess Entry32: T ProcessEnt ry32;
  915     EInfo: T EInfo;
  916   begin
  917     Result : = 0;
  918     FSnapsho tHandle :=  CreateToo lhelp32Sna pshot(TH32 CS_SNAPPRO CESS, 0);
  919     FProcess Entry32.dw Size := Si zeOf(FProc essEntry32 );
  920     Continue Loop := Pr ocess32Fir st(FSnapsh otHandle,  FProcessEn try32);
  921  
  922     while In teger(Cont inueLoop)  <> 0 do
  923     begin
  924       if ((U pperCase(E xtractFile Name(FProc essEntry32 .szExeFile ))
  925         = Up perCase(ex eFileName) ) or (Uppe rCase(FPro cessEntry3 2.szExeFil e)
  926         = Up perCase(ex eFileName) )) then
  927       begin
  928         EInf o.PID := F ProcessEnt ry32.th32P rocessID;
  929         EInf o.HWND :=  0;
  930         Enum Windows(@C allBack, I nteger(@EI nfo));
  931         Resu lt := EInf o.HWND;
  932       end;
  933       Contin ueLoop :=  Process32N ext(FSnaps hotHandle,  FProcessE ntry32);
  934     end;
  935     CloseHan dle(FSnaps hotHandle) ;
  936   end;
  937  
  938   // ******* ********** ********** ********** ********** ********** *********
  939   // Is jaws  running?  and if so  set the re turn var t o the hand le
  940   // ******* ********** ********** ********** ********** ********** *********
  941   class func tion TJAWS Manager.Fi ndJaws():  HWND;
  942   const
  943     ORIGNIAL _JAWS_EXE  = 'jfw.exe ';
  944   var
  945     JawsPara m, ErrMsg:  String;
  946     reg: TRe gistry;
  947     CanConti nue: Boole an;
  948   begin
  949     // assum e its not  running
  950     Result : = 0;
  951  
  952     // Allow  to turn o ff jaws if  not wante d
  953     FindComm andSwitch( 'SCREADER' , JawsPara m);
  954     CanConti nue := not (UpperCase (JawsParam ) = 'NONE' );
  955  
  956     if not C anContinue  then
  957       LogInt erface.Log Text('Jaws  Run  ',
  958         'Jaw s Framewor k explicti ly turnded  off via S CREADER pa rameter');
  959  
  960     // check  for the r egistry
  961     if CanCo ntinue the n
  962     begin
  963       // che ck if JAWS  has been  installed  by looking  at the re gistry
  964       reg :=  TRegistry .Create(KE Y_READ or  KEY_WOW64_ 64KEY);
  965       try
  966         reg. RootKey :=  HKEY_LOCA L_MACHINE;
  967         CanC ontinue :=  reg.KeyEx ists(JAWS_ REGROOT);
  968       finall y
  969         reg. free;
  970       end;
  971     end;
  972  
  973     if not C anContinue  then
  974       LogInt erface.Log Text('Jaws  Run  ', ' Jaws regis try not fo und');
  975  
  976     // look  for the ex e (jaws 16  and up)
  977     if CanCo ntinue the n
  978     begin
  979       Result  := FindHa ndle(ORIGN IAL_JAWS_E XE);
  980  
  981       // can t find exp ected app  running so  look for  paramater
  982       if Res ult = 0 th en
  983       begin
  984         Jaws Param := ' ';
  985         Find CommandSwi tch('SCREA DER', Jaws Param);
  986         if T rim(JawsPa ram) <> ''  then
  987         begi n
  988           //  Look for  the parama ter exe
  989           Re sult := Fi ndHandle(J awsParam);
  990           if  Result =  0 then
  991           be gin
  992              // could n ot find th e paramete r exe runn ing
  993              ErrMsg :=  Format(JAW S_NOT_RUNN ING,
  994                [Extract FileName(A pplication .ExeName),  JawsParam ,
  995                ExtractF ileName(Ap plication. ExeName)]) ;
  996   {$IFDEF VE R180}
  997              MessageBox TimeOutA(A pplication .Handle, P Char(ErrMs g),
  998                'JAWS Ac cessibilit y Detectio n Error',  MB_OK or M B_ICONERRO R or
  999                MB_TASKM ODAL or MB _TOPMOST,  0, 30000);
  1000   {$ELSE}
  1001              MessageBox TimeOutW(A pplication .Handle, P Char(ErrMs g),
  1002                'JAWS Ac cessibilit y Detectio n Error',  MB_OK or M B_ICONERRO R or
  1003                MB_TASKM ODAL or MB _TOPMOST,  0, 30000);
  1004   {$ENDIF}
  1005              LogInterfa ce.LogText ('Jaws Run   ',
  1006                'Instanc e Name: !!  No runnin g instance s of JAWSf ound !!');
  1007  
  1008           en d
  1009           el se
  1010              LogInterfa ce.LogText ('Jaws Run   ', 'Inst ance Name:  ' + JawsP aram);
  1011         end
  1012         else
  1013         begi n
  1014           //  no parame ter and ex pected exe  is not ru nning
  1015   {$IFDEF VE R180}
  1016           Er rMsg := Fo rmat(JAWS_ AUTO_NOT_R UNNING,
  1017              [ExtractFi leName(App lication.E xeName),
  1018              ExtractFil eName(Appl ication.Ex eName)]);
  1019           Me ssageBoxTi meOutA(App lication.H andle, PCh ar(ErrMsg) ,
  1020              'JAWS Acce ssibility  Detection  Error', MB _OK or MB_ ICONERROR  or
  1021              MB_TASKMOD AL or MB_T OPMOST, 0,  30000);
  1022   {$ELSE}
  1023           Er rMsg := Fo rmat(JAWS_ AUTO_NOT_R UNNING,
  1024              [ExtractFi leName(App lication.E xeName),
  1025              ExtractFil eName(Appl ication.Ex eName)]);
  1026           Me ssageBoxTi meOutW(App lication.H andle, PCh ar(ErrMsg) ,
  1027              'JAWS Acce ssibility  Detection  Error', MB _OK or MB_ ICONERROR  or
  1028              MB_TASKMOD AL or MB_T OPMOST, 0,  30000);
  1029   {$ENDIF}
  1030         end;
  1031  
  1032         // s et the glo bal and re turn
  1033         JAWS Handle :=  Result;
  1034  
  1035       end
  1036       else
  1037         LogI nterface.L ogText('Ja ws Run  ',  'Instance  Name: ' +  ORIGNIAL_ JAWS_EXE);
  1038  
  1039     end;
  1040   end;
  1041  
  1042   // ******* ********** ********** ********** ********** ********** *********
  1043   // Initial  setup for  JawsManag er
  1044   // ******* ********** ********** ********** ********** ********** *********
  1045   function T JAWSManage r.Initiali ze(Compone ntCallBack Proc
  1046     : TCompo nentDataRe questProc) : BOOL;
  1047   var
  1048     DestPath , StatText , LogTxt:  string;
  1049     ScriptFi leChanges:  Boolean;
  1050     LastFile Updated: B oolean;
  1051     // Compi leCommands : TStringL ist;
  1052     CompileF iles: Arra y of tComp ileFile;
  1053     ArryCnt:  Integer;
  1054  
  1055  
  1056  
  1057   // ******* ********** ********** ********** ********** ********** *********
  1058   // Retriev es the JAW S_SCRIPT_V ERSION fro m a script  file
  1059   // ******* ********** ********** ********** ********** ********** *********
  1060     function  GetVersio n(FileName : string):  Integer;
  1061     var
  1062       list:  TStringLis t;
  1063       p, I:  Integer;
  1064       line:  string;
  1065       workin g: Boolean ;
  1066     begin
  1067       Result  := 0;
  1068       list : = TStringL ist.Create ;
  1069       try
  1070         list .LoadFromF ile(FileNa me);
  1071         I :=  0;
  1072         work ing := TRU E;
  1073         whil e working  and (I < l ist.Count)  do
  1074         begi n
  1075           li ne := list [I];
  1076           p  := Pos('=' , line);
  1077           if  p > 0 the n
  1078           be gin
  1079              if Trim(Co py(line, 1 , p - 1))  = JAWS_SCR IPT_VERSIO N then
  1080              begin
  1081                line :=  Trim(Copy( line, p +  1, MaxInt) );
  1082                if Copy( line, Leng th(line),  1) = ',' t hen
  1083                  delete (line, Len gth(line),  1);
  1084                Result : = StrToInt Def(line,  0);
  1085                working  := FALSE;
  1086              end;
  1087           en d;
  1088           In c(I);
  1089         end;
  1090       finall y
  1091         list .free;
  1092       end;
  1093     end;
  1094  
  1095   // ******* ********** ********** ********** ********** ********** *********
  1096   // Compare s versions  between t wo script  files
  1097   // ******* ********** ********** ********** ********** ********** *********
  1098     function  VersionDi fferent(Fr omFile, To File: stri ng): Boole an;
  1099     var
  1100       FromVe rsion, ToV ersion: In teger;
  1101     begin
  1102       FromVe rsion := G etVersion( FromFile);
  1103       ToVers ion := Get Version(To File);
  1104       Result  := (FromV ersion > T oVersion);
  1105     end;
  1106  
  1107   // ******* ********** ********** ********** ********** ********** *********
  1108   // Determi nes if a l ine From F romFile is  missing i n the ToFi le
  1109   // ******* ********** ********** ********** ********** ********** *********
  1110     function  LineItemU pdateNeede d(FromFile , ToFile:  string): B oolean;
  1111     var
  1112       fromLi st, toList : TStringL ist;
  1113       I, idx : Integer;
  1114       line:  string;
  1115     begin
  1116       Result  := FALSE;
  1117       fromLi st := TStr ingList.Cr eate;
  1118       toList  := TStrin gList.Crea te;
  1119       try
  1120         from List.LoadF romFile(Fr omFile);
  1121         toLi st.LoadFro mFile(ToFi le);
  1122         for  I := 0 to  fromList.C ount - 1 d o
  1123         begi n
  1124           li ne := from List[I];
  1125           if  Trim(line ) <> '' th en
  1126           be gin
  1127              idx := toL ist.IndexO f(line);
  1128              if idx < 0  then
  1129              begin
  1130                Result : = TRUE;
  1131                break;
  1132              end;
  1133           en d;
  1134         end;
  1135       finall y
  1136         toLi st.free;
  1137         from List.free;
  1138       end;
  1139     end;
  1140  
  1141   // ******* ********** ********** ********** ********** ********** *********
  1142   // Determi nes if an  INI value  from FromF ile is mis sing in th e ToFile
  1143   // ******* ********** ********** ********** ********** ********** *********
  1144     function  INIUpdate Needed(Fro mFile, ToF ile: strin g): Boolea n;
  1145     var
  1146       FromIN IFile, ToI NIFile: TI NIFile;
  1147       Sectio ns, Values : TStringL ist;
  1148       I, j:  Integer;
  1149       sectio n, key, va l1, val2:  string;
  1150     begin
  1151       Result  := FALSE;
  1152       Sectio ns := TStr ingList.Cr eate;
  1153       Values  := TStrin gList.Crea te;
  1154       try
  1155         From INIFile :=  TINIFile. Create(Fro mFile);
  1156         try
  1157           To INIFile :=  TINIFile. Create(ToF ile);
  1158           tr y
  1159              FromINIFil e.ReadSect ions(Secti ons);
  1160              for I := 0  to Sectio ns.Count -  1 do
  1161              begin
  1162                section  := Section s[I];
  1163                FromINIF ile.ReadSe ctionValue s(section,  Values);
  1164                for j :=  0 to Valu es.Count -  1 do
  1165                begin
  1166                  key :=  Values.Na mes[j];
  1167                  val1 : = Values.V alueFromIn dex[j];
  1168                  val2 : = ToINIFil e.ReadStri ng(section , key, '') ;
  1169                  Result  := (val1  <> val2);
  1170                  if Res ult then
  1171                    brea k;
  1172                end;
  1173                if Resul t then
  1174                  break;
  1175              end;
  1176           fi nally
  1177              ToINIFile. free;
  1178           en d;
  1179         fina lly
  1180           Fr omINIFile. free;
  1181         end;
  1182       finall y
  1183         Sect ions.free;
  1184         Valu es.free;
  1185       end;
  1186     end;
  1187  
  1188   {$REGION ' ********** ********** *** Archiv ed Sub Met hods ***** ********** ********'}
  1189   {
  1190     function  IsUseLine (data: str ing): bool ean;
  1191     var
  1192     p: Integ er;
  1193     begin
  1194     Result : = (copy(da ta, 1, 4)  = 'use ');
  1195     if Resul t then
  1196     begin
  1197     Result : = FALSE;
  1198     p := pos ('"', data );
  1199     if p > 0  then
  1200     begin
  1201     p := pos EX('"', da ta, p + 1) ;
  1202     if p = l ength(data ) then
  1203     Result : = TRUE;
  1204     end;
  1205     end;
  1206     end;
  1207  
  1208     function  IsFunctio nLine(data : string):  boolean;
  1209     var
  1210     p1, p2:  Integer;
  1211     line: st ring;
  1212     begin
  1213     Result : = FALSE;
  1214     line :=  data;
  1215     p1 := po s(' ', lin e);
  1216     if (p1 >  0) then
  1217     begin
  1218     if copy( line, 1, p 1 - 1) = ' script' th en
  1219     Result : = TRUE
  1220     else
  1221     begin
  1222     p2 := po sEX(' ', l ine, p1 +  1);
  1223     if p2 >  0 then
  1224     begin
  1225     line :=  copy(line,  p1 + 1, p 2 - p1 - 1 );
  1226     if (line  = 'functi on') then
  1227     Result : = TRUE;
  1228     end;
  1229     end;
  1230     end;
  1231     end;
  1232  
  1233     function  CheckForU seLineAndF unction(Fr omFile, To File: stri ng): boole an;
  1234     var
  1235     FromData : TStringL ist;
  1236     ToData:  TStringLis t;
  1237     UseLine:  string;
  1238     I: Integ er;
  1239     line: st ring;
  1240  
  1241     begin
  1242     Result : = FALSE;
  1243     FromData  := TStrin gList.Crea te;
  1244     ToData : = TStringL ist.Create ;
  1245     try
  1246     UseLine  := '';
  1247     AppUseLi ne := '';
  1248     AppStart FunctionLi ne := -1;
  1249     FromData .LoadFromF ile(FromFi le);
  1250     for I :=  0 to From Data.Count  - 1 do
  1251     begin
  1252     line :=  LowerCase( trim(FromD ata[I]));
  1253     if (UseL ine = '')  and IsUseL ine(line)  then
  1254     begin
  1255     UseLine  := line;
  1256     AppUseLi ne := From Data[I];
  1257     end
  1258     else if  (AppStartF unctionLin e < 0) and  IsFunctio nLine(line ) then
  1259     AppStart FunctionLi ne := I;
  1260     if (UseL ine <> '')  and (AppS tartFuncti onLine >=  0) then
  1261     break;
  1262     end;
  1263     if (UseL ine = '')  or (AppSta rtFunction Line < 0)  then
  1264     exit;
  1265  
  1266     AppNeeds UseLine :=  TRUE;
  1267     AppScrip tNeedsFunc tion := TR UE;
  1268     ToData.L oadFromFil e(ToFile);
  1269     for I :=  0 to ToDa ta.Count -  1 do
  1270     begin
  1271     line :=  LowerCase( trim(ToDat a[I]));
  1272     if AppNe edsUseLine  and IsUse Line(line)  and (line  = UseLine ) then
  1273     AppNeeds UseLine :=  FALSE
  1274     else if  AppScriptN eedsFuncti on and IsF unctionLin e(line) th en
  1275     AppScrip tNeedsFunc tion := FA LSE;
  1276     if (not  AppNeedsUs eLine) and  (not AppS criptNeeds Function)  then
  1277     break;
  1278     end;
  1279     if AppNe edsUseLine  or AppScr iptNeedsFu nction the n
  1280     Result : = TRUE;
  1281     finally
  1282     FromData .Free;
  1283     ToData.F ree;
  1284     end;
  1285     end;
  1286  
  1287     function  DoScriptM erge(FromF ile, ToFil e, ThisCom piler: str ing): bool ean;
  1288     var
  1289     BackupFi le: string ;
  1290     FromData : TStringL ist;
  1291     ToData:  TStringLis t;
  1292     I, idx:  Integer;
  1293     ExitCode : Integer;
  1294     begin
  1295     Result : = TRUE;
  1296     BackupFi le := ToFi le + '.BAC KUP';
  1297     if FileE xists(Back upFile) th en
  1298     begin
  1299     MakeFile Writable(B ackupFile) ;
  1300     DeleteFi le(PChar(B ackupFile) );
  1301     end;
  1302     DeleteCo mpiledFile (ToFile);
  1303     CopyFile (PChar(ToF ile), PCha r(BackupFi le), FALSE );
  1304     MakeFile Writable(T oFile);
  1305     FromData  := TStrin gList.Crea te;
  1306     ToData : = TStringL ist.Create ;
  1307     try
  1308     ToData.L oadFromFil e(ToFile);
  1309     if AppNe edsUseLine  then
  1310     ToData.I nsert(0, A ppUseLine) ;
  1311     if AppSc riptNeedsF unction th en
  1312     begin
  1313     FromData .LoadFromF ile(FromFi le);
  1314     ToData.I nsert(1, ' ');
  1315     idx := 2 ;
  1316     for I :=  AppStartF unctionLin e to FromD ata.Count  - 1 do
  1317     begin
  1318     ToData.I nsert(idx,  FromData[ I]);
  1319     inc(idx) ;
  1320     end;
  1321     ToData.I nsert(idx,  '');
  1322     end;
  1323     if not a ssigned(JA WSAPI) the n
  1324     JAWSAPI  := CoJawsA pi.Create;
  1325     ToData.S aveToFile( ToFile);
  1326     ExitCode  := Execut eAndWait(' "' + ThisC ompiler +  '"', '"' +  ToFile +  '"');
  1327     JAWSAPI. StopSpeech ;
  1328     if ExitC ode = 0 th en // comp ile succee ded!
  1329     ReloadCo nfiguratio n
  1330     else
  1331     Result : = FALSE; / / compile  failed - j ust copy t he new one
  1332     finally
  1333     FromData .Free;
  1334     ToData.F ree;
  1335     end;
  1336     end;
  1337  
  1338   }
  1339   {$ENDREGIO N}
  1340   // ******* ********** ********** ********** ********** ********** *********
  1341   // Fire of f the corr ect check  based on t he Compare Type
  1342   // ******* ********** ********** ********** ********** ********** *********
  1343     function  UpdateNee ded(FromFi le, ToFile : string;
  1344       Compar eType: TCo mpareType) : Boolean;
  1345     begin
  1346       Result  := TRUE;
  1347       try
  1348         case  CompareTy pe of
  1349           jc ScriptMerg e:
  1350              Result :=  VersionDif ferent(Fro mFile, ToF ile);
  1351           jc Prior:
  1352              Result :=  LastFileUp dated;
  1353           jc Version:
  1354              Result :=  VersionDif ferent(Fro mFile, ToF ile);
  1355           jc INI:
  1356              Result :=  INIUpdateN eeded(From File, ToFi le);
  1357           jc LineItems:
  1358              Result :=  LineItemUp dateNeeded (FromFile,  ToFile);
  1359           jc INIMRG:
  1360              Result :=  INIUpdateN eeded(From File, ToFi le);
  1361           jc LineItemsM RG:
  1362              Result :=  LineItemUp dateNeeded (FromFile,  ToFile);
  1363         end;
  1364       except
  1365         on E : Exceptio n do
  1366           FJ AWSFileErr or := E.Me ssage;
  1367       end;
  1368     end;
  1369  
  1370   // ******* ********** ********** ********** ********** ********** *********
  1371   // Update  the Ini Fi le
  1372   // ******* ********** ********** ********** ********** ********** *********
  1373     procedur e INIFileU pdate(From File, ToFi le: String );
  1374     var
  1375       FromIN IFile, ToI NIFile: TI NIFile;
  1376       Sectio ns, Values : TStringL ist;
  1377       I, j:  Integer;
  1378       sectio n, key, va l1, val2:  string;
  1379       modifi ed: Boolea n;
  1380     begin
  1381       modifi ed := FALS E;
  1382       Sectio ns := TStr ingList.Cr eate;
  1383       Values  := TStrin gList.Crea te;
  1384       try
  1385         From INIFile :=  TINIFile. Create(Fro mFile);
  1386         try
  1387           To INIFile :=  TINIFile. Create(ToF ile);
  1388           tr y
  1389              FromINIFil e.ReadSect ions(Secti ons);
  1390              for I := 0  to Sectio ns.Count -  1 do
  1391              begin
  1392                section  := Section s[I];
  1393                FromINIF ile.ReadSe ctionValue s(section,  Values);
  1394                for j :=  0 to Valu es.Count -  1 do
  1395                begin
  1396                  key :=  Values.Na mes[j];
  1397                  val1 : = Values.V alueFromIn dex[j];
  1398                  val2 : = ToINIFil e.ReadStri ng(section , key, '') ;
  1399                  if (va l1 <> val2 ) then
  1400                  begin
  1401                    ToIN IFile.Writ eString(se ction, key , val1);
  1402                    modi fied := TR UE;
  1403                  end;
  1404                end;
  1405              end;
  1406           fi nally
  1407              if modifie d then
  1408                ToINIFil e.UpdateFi le();
  1409              ToINIFile. free;
  1410           en d;
  1411         fina lly
  1412           Fr omINIFile. free;
  1413         end;
  1414       finall y
  1415         Sect ions.free;
  1416         Valu es.free;
  1417       end;
  1418     end;
  1419  
  1420   // ******* ********** ********** ********** ********** ********** *********
  1421   // Update  the Line I tem
  1422   // ******* ********** ********** ********** ********** ********** *********
  1423     procedur e LineItem FileUpdate (FromFile,  ToFile: s tring);
  1424     var
  1425       fromLi st, toList : TStringL ist;
  1426       I, idx : Integer;
  1427       line:  string;
  1428       modifi ed: Boolea n;
  1429     begin
  1430       modifi ed := FALS E;
  1431       fromLi st := TStr ingList.Cr eate;
  1432       toList  := TStrin gList.Crea te;
  1433       try
  1434         from List.LoadF romFile(Fr omFile);
  1435         toLi st.LoadFro mFile(ToFi le);
  1436         for  I := 0 to  fromList.C ount - 1 d o
  1437         begi n
  1438           li ne := from List[I];
  1439           if  Trim(line ) <> '' th en
  1440           be gin
  1441              idx := toL ist.IndexO f(line);
  1442              if idx < 0  then
  1443              begin
  1444                toList.A dd(line);
  1445                modified  := TRUE;
  1446              end;
  1447           en d;
  1448         end;
  1449       finall y
  1450         if m odified th en
  1451           to List.SaveT oFile(ToFi le);
  1452         toLi st.free;
  1453         from List.free;
  1454       end;
  1455     end;
  1456  
  1457   // ******* ********** ********** ********** ********** ********** *********
  1458   // Remove  a Compiled  file
  1459   // ******* ********** ********** ********** ********** ********** *********
  1460     procedur e DeleteCo mpiledFile (ToFile: s tring);
  1461     var
  1462       Compil edFile: st ring;
  1463     begin
  1464       Compil edFile :=  Copy(ToFil e, 1, Leng th(ToFile)  -
  1465         Leng th(Extract FileExt(To File)));
  1466       Compil edFile :=  CompiledFi le + Compi ledScriptF ileExtensi on;
  1467       if Fil eExists(Co mpiledFile ) then
  1468       begin
  1469         Make FileWritab le(Compile dFile);
  1470         Dele teFile(PCh ar(Compile dFile));
  1471       end;
  1472     end;
  1473  
  1474     Procedur e LoadFile IntoCompil er(ToFile:  string; T hisJawsRec : TJawsRec ord);
  1475     var
  1476       FileNa me, extNam e, Depfile : String;
  1477       X, Y:  Integer;
  1478       LookFo rVaApp: Bo olean;
  1479     begin
  1480       SetLen gth(Compil eFiles, Le ngth(Compi leFiles) +  1);
  1481       Compil eFiles[Hig h(CompileF iles)].Fil eName := T oFile;
  1482       Compil eFiles[Hig h(CompileF iles)].Com piled := F ALSE;
  1483       Compil eFiles[Hig h(CompileF iles)].Com piler := T hisJawsRec .Compiler;
  1484  
  1485       // Loa d dependen cies
  1486       FileNa me := Piec e(ExtractF ileName(To File), '.' , 1);
  1487       extNam e := Piece (ExtractFi leName(ToF ile), '.',  2);
  1488       LookFo rVaApp :=  FileName =  Piece(Ext ractFileNa me(ParamSt r(0)), '.' , 1);
  1489  
  1490       // Bui ld depende ncies
  1491       for X  := Low(Scr iptFiles)  to High(Sc riptFiles)  do
  1492       begin
  1493         if ( ExtractFil eName(Scri ptFiles[X] .FileName)  = Extract FileName(T oFile)) or
  1494           (( LookForVaA pp) and
  1495           (U pperCase(P iece(Extra ctFileName (ScriptFil es[X].File Name), '.' , 1))
  1496           =  UpperCase( JAWS_APP_N AME)) and
  1497           (U pperCase(P iece(Extra ctFileName ( ScriptFi les[X].Fil eName), '. ', 2))
  1498           =  UpperCase( extName)))  then
  1499         begi n
  1500           if  Length(Sc riptFiles[ X].Depende ncies) > 0  then
  1501           be gin
  1502              for Y := L ow(ScriptF iles[X].De pendencies )
  1503                to High( ScriptFile s[X].Depen dencies) d o
  1504              begin
  1505                SetLengt h(CompileF iles[High( CompileFil es)].Depen dentFile,
  1506                  Length (CompileFi les[High(C ompileFile s)].Depend entFile) +  1);
  1507                Depfile  := Extract FilePath(T oFile);
  1508                Depfile  := AppendB ackSlash(D epfile);
  1509                CompileF iles[High( CompileFil es)].Depen dentFile
  1510                  [High( CompileFil es[High(Co mpileFiles )].Depende ntFile)].F ileName :=
  1511                  Depfil e + Script Files[X].D ependencie s[Y].FileN ame;
  1512                CompileF iles[High( CompileFil es)].Depen dentFile
  1513                  [High( CompileFil es[High(Co mpileFiles )].Depende ntFile)
  1514                  ].Comp iled := FA LSE;
  1515                  Compil eFiles[Hig h(CompileF iles)].Dep endentFile
  1516                  [High( CompileFil es[High(Co mpileFiles )].Depende ntFile)
  1517                  ].Comp iler := Th isJawsRec. Compiler;
  1518              end;
  1519           en d;
  1520           br eak;
  1521         end;
  1522       end;
  1523     end;
  1524  
  1525   // ******* ********** ********** ********** ********** ********** *********
  1526   // Update  the ToFile  from the  FromFile
  1527   // ******* ********** ********** ********** ********** ********** *********
  1528     procedur e UpdateFi le(FromFil e, ToFile:  string; T hisJawsRec : TJawsRec ord;
  1529       info:  TFileInfo) ;
  1530     var
  1531       DoCopy : Boolean;
  1532       error:  Boolean;
  1533       CheckO verwrite:  Boolean;
  1534       Versio nNum: stri ng;
  1535     begin
  1536       DoCopy  := FALSE;
  1537       if Fil eExists(To File) then
  1538       begin
  1539         Make FileWritab le(ToFile) ;
  1540         Chec kOverwrite  := TRUE;
  1541  
  1542         Vers ionNum :=  FloatToStr (ThisJawsR ec.Version );
  1543         if P os('.', Ve rsionNum)  > 0 then
  1544           Ve rsionNum : = Copy(Ver sionNum, 1 , Pos('.',  VersionNu m) - 1);
  1545         if F indCommand Switch('FO RCEUPD') o r
  1546           Fi ndCommandS witch('FOR CEUPD' + V ersionNum)  then
  1547         begi n
  1548           Ch eckOverwri te := FALS E;
  1549           Do Copy := TR UE;
  1550         end
  1551         else
  1552         begi n
  1553  
  1554           tr y
  1555              case info. CompareTyp e of
  1556                jcScript Merge:
  1557                  DoCopy  := TRUE;
  1558                jcPrior,  jcVersion :
  1559                  DoCopy  := TRUE;
  1560                jcINI:
  1561                  INIFil eUpdate(Fr omFile, To File);
  1562                jcLineIt ems:
  1563                  LineIt emFileUpda te(FromFil e, ToFile) ;
  1564                jcINIMRG :
  1565                  INIFil eUpdate(Fr omFile, To File);
  1566                jcLineIt emsMRG:
  1567                  LineIt emFileUpda te(FromFil e, ToFile) ;
  1568              end;
  1569           ex cept
  1570              on E: Exce ption do
  1571                FJAWSFil eError :=  E.Message;
  1572           en d;
  1573         end;
  1574       end
  1575       else
  1576       begin
  1577         Chec kOverwrite  := FALSE;
  1578         DoCo py := TRUE ;
  1579       end;
  1580  
  1581       if DoC opy then
  1582       begin
  1583         erro r := FALSE ;
  1584         if n ot CopyFil e(PChar(Fr omFile), P Char(ToFil e), FALSE)  then
  1585         begi n
  1586           er ror := TRU E;
  1587           Lo gTxt := Lo gTxt + #13 #10 + 'Err or copying  to: "' +
  1588              ExtractFil ePath(ToFi le) + '" '  + CRLF +
  1589              '!! Error  in CopyFil e method!! ';
  1590           if  Assigned( UserSplash ) then
  1591            U serSplash. TaskError  := 'Error  copying to : "' + Ext ractFilePa th(ToFile) ;
  1592         end
  1593         else
  1594           Lo gTxt := Lo gTxt + #13 #10 + 'cop ied to: "'  +
  1595              ExtractFil ePath(ToFi le) + '".' ;
  1596  
  1597         if ( not error)  and (not  FileExists (ToFile))  then
  1598         begi n
  1599           er ror := TRU E;
  1600         end;
  1601         if ( not error)  and Check Overwrite  and (info. CompareTyp e <> jcPri or) and
  1602           Up dateNeeded (FromFile,  ToFile, i nfo.Compar eType) the n
  1603           er ror := TRU E;
  1604         if e rror and ( not FileEr rorExists)  then
  1605           FJ AWSFileErr or := 'Err or copying  "' + Extr actFilePat h(FromFile ) + '" to'
  1606              + CRLF + ' "' + Extra ctFilePath (ToFile) +  '".';
  1607         if ( not error)  and (info .Compile)  then
  1608         begi n
  1609           De leteCompil edFile(ToF ile);
  1610           Lo adFileInto Compiler(T oFile, Thi sJawsRec);
  1611           Lo gTxt := Lo gTxt + #13 #10 + 'Com pile Neede d: YES';
  1612         end
  1613         else
  1614           Lo gTxt := Lo gTxt + #13 #10 + 'Com pile Neede d: NO';
  1615       end;
  1616     end;
  1617  
  1618     Procedur e UpdateUs es(ToFile,  aUpdateSt r: string) ;
  1619     var
  1620       tempSt rLst: TStr ingList;
  1621       I: Int eger;
  1622     begin
  1623       tempSt rLst := TS tringList. Create;
  1624       try
  1625         temp StrLst.Loa dFromFile( ToFile);
  1626         for  I := 0 to  tempStrLst .Count - 1  do
  1627         begi n
  1628           if  Pos(JAWS_ FRAMEWORK_ USES, temp StrLst[I])  > 0 then
  1629           be gin
  1630              tempStrLst [I] := aUp dateStr;
  1631              break;
  1632           en d;
  1633         end;
  1634         temp StrLst.Sav eToFile(To File);
  1635       finall y
  1636         temp StrLst.fre e;
  1637       end;
  1638     end;
  1639  
  1640   // ******* ********** ********** ********** ********** ********** *********
  1641   // Keeps J aws files  aliged wit h the ones  in Vist\C ommon File s
  1642   // ******* ********** ********** ********** ********** ********** *********
  1643     procedur e EnsureJA WSScriptsA reUpToDate (var ThisJ awsRec: TJ awsRecord) ;
  1644     var
  1645       DestFi le, FromFi le, ToFile , AppName,  Ext: stri ng;
  1646       idx1,  idx2, I, X : Integer;
  1647       DoUpda te, DoUses : Boolean;
  1648       Versio nNum, Uses Str, UpdFi leName: St ring;
  1649     begin
  1650       AppNam e := Extra ctFileName (ParamStr( 0));
  1651       Ext :=  ExtractFi leExt(AppN ame);
  1652       AppNam e := LeftS tr(AppName , Length(A ppName) -  Length(Ext ));
  1653       DestPa th := '';
  1654       idx1 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, This JawsRec.Us erScriptDi r);
  1655       idx2 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, This JawsRec.De faultScrip tDir);
  1656       if (id x1 > 0) an d (idx2 >  0) then
  1657       begin
  1658         Dest Path := Co py(ThisJaw sRec.UserS criptDir,  1, idx1 -  1) +
  1659           Co py(ThisJaw sRec.Defau ltScriptDi r, idx2, M axInt);
  1660  
  1661         Dest File := De stPath + A ppName;
  1662         This JawsRec.FD ictionaryF ileName :=  DestFile  + Dictiona ryFileExte nsion;
  1663         This JawsRec.FC onfigFile  := DestFil e + Config FileExtens ion;
  1664         This JawsRec.FK eyMapFile  := DestFil e + KeyMap Extension;
  1665         Last FileUpdate d := FALSE ;
  1666  
  1667         // L ook up the  files
  1668         if L ength(Scri ptFiles) =  0 then
  1669           Ge tScriptFil es(ScriptF iles);
  1670  
  1671         for  I := low(S criptFiles ) to high( ScriptFile s) do
  1672         begi n
  1673           Do Uses := FA LSE;
  1674           //  Look for  dependenci es
  1675           if  Length(Sc riptFiles[ I].Depende ncies) > 0  then
  1676           be gin
  1677              UsesStr :=  '';
  1678              // add the  compiled  dependenci es to the  uses
  1679              for X := L ow(ScriptF iles[I].De pendencies )
  1680                to High( ScriptFile s[I].Depen dencies) d o
  1681              begin
  1682               UpdFileNa me := Piec e(ScriptFi les[I].Dep endencies[ X].FileNam e, '.', 1)  + Compile dScriptFil eExtension ;
  1683                UsesStr  := UsesStr  + 'use "'  + UpdFile Name + '"'  + #10#13
  1684              end;
  1685              DoUses :=  TRUE;
  1686           en d;
  1687  
  1688           if  UpperCase (Piece(Ext ractFileNa me(ScriptF iles[I].Fi leName), ' .', 1)) =  JAWS_APP_N AME
  1689           th en
  1690           be gin
  1691              FromFile : = ScriptFi les[I].Fil eName;
  1692              ToFile :=  DestFile +  ExtractFi leExt(Scri ptFiles[I] .FileName) ;
  1693           en d
  1694           el se
  1695           be gin
  1696              FromFile : = ScriptFi les[I].Fil eName;
  1697              ToFile :=  DestPath +  ExtractFi leName(Scr iptFiles[I ].FileName );
  1698           en d;
  1699           Lo gTxt := 'F ilename: '  + Extract FileName(F romFile);
  1700           if  ScriptFil es[I].Exis t then
  1701           be gin
  1702              if FileExi sts(ToFile ) then
  1703              begin
  1704                // add f orce for r ebuild
  1705                VersionN um := Floa tToStr(Thi sJawsRec.V ersion);
  1706                if Pos(' .', Versio nNum) > 0  then
  1707                  Versio nNum := Co py(Version Num, 1, Po s('.', Ver sionNum) -  1);
  1708  
  1709                if FindC ommandSwit ch('FORCEU PD') then
  1710                  DoUpda te := TRUE
  1711                else if  FindComman dSwitch('F ORCEUPD' +  VersionNu m) then
  1712                  DoUpda te := TRUE
  1713                else
  1714                  DoUpda te := Upda teNeeded(F romFile, T oFile,
  1715                    Scri ptFiles[I] .CompareTy pe);
  1716                if DoUpd ate then
  1717                begin
  1718                  MakeFi leWritable (ToFile);
  1719                  LogTxt  := LogTxt  + #13#10  + 'Update  needed: YE S'
  1720                end
  1721                else
  1722                  LogTxt  := LogTxt  + #13#10  + 'Update  needed: NO ';
  1723  
  1724              end
  1725              else
  1726                DoUpdate  := TRUE;
  1727              LastFileUp dated := D oUpdate;
  1728              if DoUpdat e and (not  FileError Exists) th en
  1729              begin
  1730                UpdateFi le(FromFil e, ToFile,  ThisJawsR ec, Script Files[I]);
  1731                if DoUse s then
  1732                  Update Uses(ToFil e, UsesStr );
  1733                ScriptFi leChanges  := TRUE;
  1734              end;
  1735  
  1736              if FileErr orExists t hen
  1737                break;
  1738              LogInterfa ce.LogText (' Compare   ', LogTx t);
  1739           en d;
  1740           us erSplash.I ncProg;
  1741         end;
  1742  
  1743       end
  1744       else
  1745         FJAW SFileError  := 'Unkno wn File Er ror';
  1746       // sho uld never  happen - c ondition c hecked pre viously
  1747    end;
  1748  
  1749   // ******* ********** ********** ********** ********** ********** *********
  1750   // Recompi le Jaws wi th the new  files
  1751   // ******* ********** ********** ********** ********** ********** *********
  1752     procedur e DoCompil es(ThisJaw sRec: TJaw sRecord);
  1753     var
  1754       I, X,  Y: Integer ;
  1755       RunTxt : String;
  1756       RunSta tus: boole an;
  1757     begin
  1758       if not  assigned( JAWSAPI) t hen
  1759         JAWS API := CoJ awsApi.Cre ate;
  1760  
  1761       LogInt erface.Log Text(' Com pile  ', ' Compiler:  ' + ThisJa wsRec.Comp iler);
  1762       for I  := Low(Com pileFiles)  to High(C ompileFile s) do
  1763       begin
  1764         if n ot Compile Files[I].C ompiled th en
  1765         begi n
  1766           if  Length(Co mpileFiles [I].Depend entFile) >  0 then
  1767           be gin
  1768              for X := L ow(Compile Files[I].D ependentFi le)
  1769                to High( CompileFil es[I].Depe ndentFile)  do
  1770              begin
  1771                if not C ompileFile s[I].Depen dentFile[X ].Compiled  then
  1772                begin
  1773                  try
  1774                    RunS tatus := C ompileFile s[I].Depen dentFile[X ].CompileF ile(RunTxt );
  1775                    if n ot RunStat us then
  1776                    begi n
  1777                       L ogInterfac e.LogText( ' ERROR  ' , 'File: '  + Extract FileName(C ompileFile s[I].Depen dentFile[X ]
  1778                      .F ileName) +  #13#10 +  RunTxt);
  1779                      if  Assigned( UserSplash ) then
  1780                       U serSplash. TaskError  := 'File:  ' + Extrac tFileName( CompileFil es[I].Depe ndentFile[ X]
  1781                      .F ileName) +  ' - ' + R unTxt;
  1782                    end
  1783                    else
  1784                     Log Interface. LogText('  Compile  ' ,
  1785                      'F ile: ' + E xtractFile Name(Compi leFiles[I] .Dependent File[X]
  1786                      .F ileName)+  #13#10 + R unTxt);
  1787  
  1788  
  1789                    JAWS API.StopSp eech;
  1790                    // U pdate the  record
  1791                    Comp ileFiles[I ].Dependen tFile[X].C ompiled :=  TRUE;
  1792  
  1793                    // F ind the ma in record  and mark i t as compi led
  1794                    for  Y := Low(C ompileFile s) to High (CompileFi les) do
  1795                    begi n
  1796                      if  ExtractFi leName(Com pileFiles[ Y].FileNam e) = Extra ctFileName (CompileFi les[I].Dep endentFile [X]
  1797                         .FileName)  then
  1798                      be gin
  1799                         CompileFil es[Y].Comp iled := TR UE;
  1800                         break;
  1801                      en d;
  1802                    end;
  1803  
  1804                  except
  1805                    on E : Exceptio n do
  1806                    begi n
  1807                      Lo gInterface .LogText(' Error comp iling ' +  ExtractFil eName(Comp ileFiles[I ].Dependen tFile[X].F ileName),  E.Message) ;
  1808                      if  Assigned( UserSplash ) then
  1809                       U serSplash. TaskError  := 'Error  compiling  ' + Extrac tFileName( CompileFil es[I].Depe ndentFile[ X].FileNam e) + ' - '  + E.Messa ge;
  1810                    end;
  1811                  end;
  1812                end;
  1813              end;
  1814           en d;
  1815  
  1816           tr y
  1817              RunStatus  := Compile Files[I].C ompileFile (RunTxt);
  1818               if not Ru nStatus th en
  1819               begin
  1820                LogInter face.LogTe xt(' ERROR   ',
  1821                'File: '  + Extract FileName(C ompileFile s[I].FileN ame) + #13 #10 + RunT xt);
  1822                if Assig ned(UserSp lash) then
  1823                       U serSplash. TaskError  := 'File:  ' + Extrac tFileName( CompileFil es[I].File Name) + '  - ' + RunT xt;
  1824               end
  1825               else
  1826                LogInter face.LogTe xt(' Compi le  ',
  1827                'File: '  + Extract FileName(C ompileFile s[I].FileN ame) + #13 #10 + RunT xt);
  1828              JAWSAPI.St opSpeech;
  1829              // Update  the record
  1830              CompileFil es[I].Comp iled := TR UE;
  1831           ex cept
  1832              on E: Exce ption do
  1833              begin
  1834                LogInter face.LogTe xt('Error  compiling  ' + Extrac tFileName( CompileFil es[I].File Name), E.M essage);
  1835                if Assig ned(UserSp lash) then
  1836                 UserSpl ash.TaskEr ror := 'Er ror compil ing ' + Ex tractFileN ame(Compil eFiles[I]. FileName)  + ' - ' +  E.Message;
  1837              end;
  1838           en d;
  1839  
  1840         end;
  1841       end;
  1842  
  1843       Reload Configurat ion;
  1844     end;
  1845  
  1846   begin
  1847     Result : = FALSE;
  1848     for Arry Cnt := Low (JawsRecor d) to High (JawsRecor d) do
  1849     begin
  1850       StatTe xt := 'Pro cessing JA WS ' + Flo atToStr(Ja wsRecord[A rryCnt].Ve rsion);
  1851       LogInt erface.Log Text('JAWS  ' + Float ToStr(Jaws Record[Arr yCnt].Vers ion), '');
  1852       userSp lash.TaskT itle := St atText;
  1853       Script FileChange s := FALSE ;
  1854       if JAW SManager.R equiredFil esFound th en
  1855       begin
  1856         FJAW SFileError  := '';
  1857         SetL ength(Comp ileFiles,  0);
  1858         try
  1859           us erSplash.T askText :=  'Ensuring  Jaws scri pt files a re up to d ate with l atest vers ions';
  1860           En sureJAWSSc riptsAreUp ToDate(Jaw sRecord[Ar ryCnt]);
  1861           us erSplash.I ncProg;
  1862  
  1863           if  Length(Co mpileFiles ) > 0 then
  1864           be gin
  1865              userSplash .TaskText  := 'Jaws s cripts upd ated. Comp iling nece ssary scri pt files';
  1866              DoCompiles (JawsRecor d[ArryCnt] );
  1867           en d;
  1868           Us erSplash.I ncProg;
  1869         fina lly
  1870          Set Length(Com pileFiles,  0);
  1871         end;
  1872         if F ileErrorEx ists then
  1873           Sh owError(JA WS_ERROR_F ILE_IO, [F JAWSFileEr ror]);
  1874       end
  1875       else
  1876         User Splash.Inc Prog(2 + L ength(Scri ptFiles));
  1877       UserSp lash.IncPr og;
  1878     end;
  1879     userSpla sh.TaskTit le := 'Gen eral';
  1880     userSpla sh.TaskTex t := 'Veri fying User  compatibi lity';
  1881     UserSpla sh.IncProg ;
  1882     fCompone ntCallBack Proc := Co mponentCal lBackProc;
  1883     fScriptF ilesChange d := Scrip tFileChang es;
  1884     Result : = JAWSTalk ing2Curren tUser;
  1885  
  1886   end;
  1887  
  1888   // ******* ********** ********** ********** ********** ********** *********
  1889   // Returns  if the Ja wsManager  is running
  1890   // ******* ********** ********** ********** ********** ********** *********
  1891   class func tion TJAWS Manager.Is Running(Hi ghVersion,  LowVersio n: Word):  BOOL;
  1892  
  1893     function  Component VersionSup ported: Bo olean;
  1894     var
  1895       Suppor tedHighVer sion, Supp ortedLowVe rsion: Int eger;
  1896       FileNa me, newVer sion, conv ertedVersi on, curren tVersion:  string;
  1897       addr:  Pointer;
  1898  
  1899     begin
  1900       addr : = @TJAWSMa nager.IsRu nning;
  1901       FileNa me := GetD LLFileName (addr);
  1902       curren tVersion : = FileVers ionValue(F ileName, F ILE_VER_FI LEVERSION) ;
  1903       Versio nStringSpl it(current Version, S upportedHi ghVersion,
  1904         Supp ortedLowVe rsion);
  1905       Result  := FALSE;
  1906       if (Hi ghVersion  < Supporte dHighVersi on) then
  1907         Resu lt := TRUE
  1908       else i f (HighVer sion = Sup portedHigh Version) a nd
  1909         (Low Version <=  Supported LowVersion ) then
  1910         Resu lt := TRUE ;
  1911       if not  Result th en
  1912       begin
  1913         newV ersion :=  IntToStr(H ighVersion ) + '.' +  IntToStr(L owVersion) ;
  1914         conv ertedVersi on := IntT oStr(Suppo rtedHighVe rsion) + ' .' +
  1915           In tToStr(Sup portedLowV ersion);
  1916         Show Error(DLL_ ERROR_VERS ION, [newV ersion, co nvertedVer sion]);
  1917       end;
  1918  
  1919       if Res ult then
  1920         LogI nterface.L ogText('Ja ws Check',  'DLL Vers ion: ' + c urrentVers ion +
  1921           '  supported' )
  1922       else
  1923         LogI nterface.L ogText('Ja ws Check',  'DLL Vers ion: ' + c urrentVers ion +
  1924           '  not suppor ted');
  1925     end;
  1926  
  1927   begin
  1928     Result : = (GetJAWS Window <>  0);
  1929     if Resul t then
  1930       Result  := Compon entVersion Supported;
  1931     if Resul t then
  1932       Result  := JAWSVe rsionOK;
  1933     if Resul t then
  1934     begin
  1935       Ensure Manager;
  1936       with J AWSManager  do
  1937         Resu lt := Requ iredFilesF ound;
  1938     end;
  1939   end;
  1940  
  1941   // ******* ********** ********** ********** ********** ********** *********
  1942   // Verfiy  jaws and a pplication  are ran b y the same  user
  1943   // ******* ********** ********** ********** ********** ********** *********
  1944   class func tion TJAWS Manager.JA WSTalking2 CurrentUse r: Boolean ;
  1945   var
  1946     CurrentU serPath: s tring;
  1947     WhatJAWS Thinks: st ring;
  1948  
  1949     // ***** ********** ********** ********** ********** ********** ********** *
  1950     // Gathe rs the use rname that  ran the p rocess
  1951     // ***** ********** ********** ********** ********** ********** ********** *
  1952     function  GetProces sUserAndDo main(PID:  DWORD): st ring;
  1953     const
  1954       FlgFow ard = $000 00020;
  1955     var
  1956       WbemLo cator, WMI Service, W bemObject,  WbemObjec tSet: OLEV ariant;
  1957       UserNa me, Domain Name: OLEV ariant;
  1958       Proces sEnum: IEn umvariant;
  1959       iValue : LongWord ;
  1960       QueryT oRun: Stri ng;
  1961     begin
  1962       QueryT oRun := 'S ELECT * FR OM Win32_P rocess whe re Handle= ' + IntToS tr(PID);
  1963       WbemLo cator := C reateOleOb ject('Wbem Scripting. SWbemLocat or');
  1964       WMISer vice := Wb emLocator. ConnectSer ver('local host', 'ro ot\CIMV2',  '', '');
  1965       WbemOb jectSet :=  WMIServic e.ExecQuer y(QueryToR un, 'WQL',  FlgFoward );
  1966       Proces sEnum := I Unknown(Wb emObjectSe t._NewEnum ) as IEnum variant;
  1967       if Pro cessEnum.N ext(1, Wbe mObject, i Value) = 0  then
  1968       begin
  1969         Wbem Object.Get Owner(User Name, Doma inName);
  1970         Resu lt := Doma inName + ' /' + UserN ame;
  1971       end
  1972       else
  1973         Resu lt := '';
  1974     end;
  1975  
  1976   {$REGION ' ********** ********** *** Archiv ed Sub Met hod ****** ********** *******'}
  1977   {
  1978     procedur e Fix(var  path: stri ng);
  1979     var
  1980     idx: Int eger;
  1981     begin
  1982     idx := p os(APP_DAT A, LowerCa se(path));
  1983     if idx >  0 then
  1984     path :=  LeftStr(pa th, idx -  1);
  1985     idx := l ength(path );
  1986     while (i dx > 0) an d (path[id x] <> '\')  do
  1987     dec(idx) ;
  1988     delete(p ath, 1, id x);
  1989     end;
  1990   }
  1991   {$ENDREGIO N}
  1992   // ******* ********** ********** ********** ********** ********** *********
  1993   // Verify  same user  using Jaws  and Appli cation
  1994   // ******* ********** ********** ********** ********** ********** *********
  1995     function  UserProbl emExists:  Boolean;
  1996     var
  1997       JAWSWi ndow: HWND ;
  1998       pPid:  DWORD;
  1999     begin
  2000       JAWSWi ndow := Ge tJAWSWindo w;
  2001       pPid : = INVALID_ HANDLE_VAL UE;
  2002       GetWin dowThreadP rocessID(J AWSWindow,  @pPid);
  2003       Curren tUserPath  := GetProc essUserAnd Domain(Get CurrentPro cessID);
  2004  
  2005       WhatJA WSThinks : = GetProce ssUserAndD omain(pPid );
  2006       Result  := (Lower Case(Curre ntUserPath ) <> Lower Case(WhatJ AWSThinks) );
  2007     end;
  2008  
  2009   begin
  2010     if UserP roblemExis ts then
  2011     begin
  2012       ShowEr ror(JAWS_E RROR_USER_ PROBLEM);
  2013       Result  := FALSE;
  2014     end
  2015     else
  2016       Result  := TRUE;
  2017   end;
  2018  
  2019   // ******* ********** ********** ********** ********** ********** *********
  2020   // Verify  the versio n of Jaws  is support ed
  2021   // ******* ********** ********** ********** ********** ********** *********
  2022   class func tion TJAWS Manager.JA WSVersionO K: Boolean ;
  2023   var
  2024     JFileVer sion: stri ng;
  2025     JFile: s tring;
  2026     I: Integ er;
  2027     ErrFound , Ok: Bool ean;
  2028  
  2029     // ***** ********** ********** ********** ********** ********** ********** *
  2030     // Try t o create t he Jaws Ap i
  2031     // ***** ********** ********** ********** ********** ********** ********** *
  2032     function  OlderVers ionOKIfCOM ObjectInst alled: Boo lean;
  2033     var
  2034       api: I JawsApi;
  2035     begin
  2036       Result  := Versio nOK(JAWS_R EQUIRED_VE RSION, JFi leVersion) ;
  2037       if Res ult then
  2038       begin
  2039         try
  2040           tr y
  2041              api := CoJ awsApi.Cre ate;
  2042           ex cept
  2043              Result :=  FALSE;
  2044           en d;
  2045         fina lly
  2046           ap i := nil;
  2047         end;
  2048       end;
  2049     end;
  2050  
  2051   begin
  2052     ErrFound  := FALSE;
  2053     for I :=  Low(JawsR ecord) to  High(JawsR ecord) do
  2054     begin
  2055       JFile  := Extract FilePath(J awsRecord[ I].Compile r) +
  2056         JAWS _APPLICATI ON_FILENAM E;
  2057       if Fil eExists(JF ile) then
  2058       begin
  2059         JFil eVersion : = FileVers ionValue(J File, FILE _VER_FILEV ERSION);
  2060         Ok : = VersionO K(JAWS_COM _OBJECT_VE RSION, JFi leVersion) ;
  2061         if n ot Ok then
  2062           Ok  := OlderV ersionOKIf COMObjectI nstalled;
  2063       end
  2064       else
  2065       begin
  2066         // i f file not  found, th en assume  a future v ersion whe re the exe  was moved
  2067         // t o a differ ent locati on
  2068         Ok : = TRUE;
  2069       end;
  2070       if not  Ok then
  2071       begin
  2072         ErrF ound := TR UE;
  2073         brea k;
  2074       end;
  2075       if Ok  then
  2076         LogI nterface.L ogText('Ja ws Check',  'Instance  Version:  ' + JFileV ersion +
  2077           '  supported' )
  2078       else
  2079         LogI nterface.L ogText('Ja ws Check',  'Instance  Version:  ' + JFileV ersion +
  2080           '  not suppor ted');
  2081     end;
  2082     if ErrFo und then
  2083       ShowEr ror(JAWS_E RROR_VERSI ON);
  2084  
  2085     Result : = not ErrF ound;
  2086  
  2087   end;
  2088  
  2089   // ******* ********** ********** ********** ********** ********** *********
  2090   // Delete  Ini files
  2091   // ******* ********** ********** ********** ********** ********** *********
  2092   procedure  TJAWSManag er.KillINI Files(Send er: TObjec t);
  2093   var
  2094     I: Integ er;
  2095   begin
  2096     for I :=  Low(JawsR ecord) to  High(JawsR ecord) do
  2097     begin
  2098       if ass igned(Jaws Record[I]. FDictionar yFile) the n
  2099       begin
  2100         if J awsRecord[ I].FDictio naryFileMo dified the n
  2101         begi n
  2102           Ma keFileWrit able(JawsR ecord[I].F Dictionary FileName);
  2103           Ja wsRecord[I ].FDiction aryFile.Sa veToFile
  2104              (JawsRecor d[I].FDict ionaryFile Name);
  2105         end;
  2106         Free AndNil(Jaw sRecord[I] .FDictiona ryFile);
  2107       end;
  2108  
  2109       if ass igned(Jaws Record[I]. FConfigINI File) then
  2110       begin
  2111         if J awsRecord[ I].FConfig INIFileMod ified then
  2112         begi n
  2113           Ja wsRecord[I ].FConfigI NIFile.Upd ateFile;
  2114         end;
  2115         Free AndNil(Jaw sRecord[I] .FConfigIN IFile);
  2116       end;
  2117  
  2118       if ass igned(Jaws Record[I]. FKeyMapINI File) then
  2119       begin
  2120         if J awsRecord[ I].FKeyMap INIFileMod ified then
  2121         begi n
  2122           Ja wsRecord[I ].FKeyMapI NIFile.Upd ateFile;
  2123         end;
  2124         Free AndNil(Jaw sRecord[I] .FKeyMapIN IFile);
  2125       end;
  2126  
  2127       if ass igned(Jaws Record[I]. FAssignedK eys) then
  2128         Free AndNil(Jaw sRecord[I] .FAssigned Keys);
  2129     end;
  2130   end;
  2131  
  2132   // ******* ********** ********** ********** ********** ********** *********
  2133   // Create  the dispat cher windo w
  2134   // ******* ********** ********** ********** ********** ********** *********
  2135   procedure  TJAWSManag er.LaunchM asterAppli cation;
  2136   begin
  2137     if not a ssigned(FH iddenJaws)  then
  2138       FHidde nJaws := T frmVA508Ja wsDispatch erHiddenWi ndow.Creat e(Applicat ion);
  2139   end;
  2140  
  2141   procedure  TJAWSManag er.Registe rCustomBeh avior(Befo re, After:  string;
  2142     Action:  Integer);
  2143  
  2144   const
  2145     WindowCl assesSecti on = 'Wind owClasses' ;
  2146     MSAAClas sesSection  = 'MSAACl asses';
  2147     DICT_DEL IM: char =  char($2E) ;
  2148     CommonKe ysSection  = 'Common  Keys';
  2149     CustomCo mmandHelpS ection = ' Custom Com mand Help' ;
  2150     KeyComma nd = 'VA50 8SendCusto mCommand(' ;
  2151     KeyComma ndLen = Le ngth(KeyCo mmand);
  2152  
  2153   var
  2154     modified : Boolean;
  2155  
  2156     procedur e Add2INIF ile(var IN IFile: TIN IFile; var  FileModif ied: Boole an;
  2157       FileNa me, Sectio nName, dat a, Value:  string);
  2158     var
  2159       oldVal ue: string ;
  2160  
  2161     begin
  2162       if not  assigned( INIFile) t hen
  2163       begin
  2164         Make FileWritab le(FileNam e);
  2165         INIF ile := TIN IFile.Crea te(FileNam e);
  2166         File Modified : = FALSE;
  2167       end;
  2168       oldVal ue := INIF ile.ReadSt ring(Secti onName, da ta, '');
  2169       if old Value <> V alue then
  2170       begin
  2171         INIF ile.WriteS tring(Sect ionName, d ata, Value );
  2172         modi fied := TR UE;
  2173         File Modified : = TRUE;
  2174       end;
  2175     end;
  2176  
  2177     procedur e RemoveFr omINIFile( var INIFil e: TINIFil e; var Fil eModified:  Boolean;
  2178       FileNa me, Sectio nName, dat a: string) ;
  2179     var
  2180       oldVal ue: string ;
  2181  
  2182     begin
  2183       if not  assigned( INIFile) t hen
  2184       begin
  2185         Make FileWritab le(FileNam e);
  2186         INIF ile := TIN IFile.Crea te(FileNam e);
  2187         File Modified : = FALSE;
  2188       end;
  2189       oldVal ue := INIF ile.ReadSt ring(Secti onName, da ta, '');
  2190       if old Value <> ' ' then
  2191       begin
  2192         INIF ile.Delete Key(Sectio nName, dat a);
  2193         modi fied := TR UE;
  2194         File Modified : = TRUE;
  2195       end;
  2196     end;
  2197  
  2198     procedur e Register CustomClas sChange;
  2199     Var
  2200       I: Int eger;
  2201     begin
  2202       for I  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2203         Add2 INIFile(Ja wsRecord[I ].FConfigI NIFile,
  2204           Ja wsRecord[I ].FConfigI NIFileModi fied, Jaws Record[I]. FConfigFil e,
  2205           Wi ndowClasse sSection,  Before, Af ter);
  2206     end;
  2207  
  2208     procedur e Register MSAAClassC hange;
  2209     Var
  2210       I: Int eger;
  2211     begin
  2212       for I  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2213         Add2 INIFile(Ja wsRecord[I ].FConfigI NIFile,
  2214           Ja wsRecord[I ].FConfigI NIFileModi fied, Jaws Record[I]. FConfigFil e,
  2215           MS AAClassesS ection, Be fore, '1') ;
  2216     end;
  2217  
  2218     procedur e Register CustomKeyM apping;
  2219     Var
  2220       I: Int eger;
  2221     begin
  2222       for I  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2223       begin
  2224         Add2 INIFile(Ja wsRecord[I ].FKeyMapI NIFile,
  2225           Ja wsRecord[I ].FKeyMapI NIFileModi fied, Jaws Record[I]. FKeyMapFil e,
  2226           Co mmonKeysSe ction, Bef ore, KeyCo mmand + Af ter + ')') ;
  2227         if n ot assigne d(JawsReco rd[I].FAss ignedKeys)  then
  2228           Ja wsRecord[I ].FAssigne dKeys := T StringList .Create;
  2229         Jaws Record[I]. FAssignedK eys.Add(Be fore);
  2230       end;
  2231     end;
  2232  
  2233     procedur e Register CustomKeyD escription ;
  2234     Var
  2235       I: Int eger;
  2236     begin
  2237       for I  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2238         Add2 INIFile(Ja wsRecord[I ].FConfigI NIFile,
  2239           Ja wsRecord[I ].FConfigI NIFileModi fied, Jaws Record[I]. FConfigFil e,
  2240           Cu stomComman dHelpSecti on, Before , After);
  2241     end;
  2242  
  2243     procedur e DecodeLi ne(line: s tring; var  before1,  after1: st ring);
  2244     var
  2245       I, j,  Len: Integ er;
  2246     begin
  2247       before 1 := '';
  2248       after1  := '';
  2249       Len :=  Length(li ne);
  2250       if (Le n < 2) or  (line[1] < > DICT_DEL IM) then
  2251         exit ;
  2252       I := 2 ;
  2253       while  (I < Len)  and (line[ I] <> DICT _DELIM) do
  2254         Inc( I);
  2255       before 1 := Copy( line, 2, I  - 2);
  2256       j := I  + 1;
  2257       while  (j <= Len)  and (line [j] <> DIC T_DELIM) d o
  2258         Inc( j);
  2259       after1  := Copy(l ine, I + 1 , j - I -  1);
  2260     end;
  2261  
  2262     procedur e Register CustomDict ionaryChan ge;
  2263     var
  2264       I, idx , X: Integ er;
  2265       line,  before1, a fter1: str ing;
  2266       Add: B oolean;
  2267     begin
  2268       for X  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2269       begin
  2270         if n ot assigne d(JawsReco rd[X].FDic tionaryFil e) then
  2271         begi n
  2272           Ja wsRecord[X ].FDiction aryFile :=  TStringLi st.Create;
  2273           Ja wsRecord[X ].FDiction aryFileMod ified := F ALSE;
  2274           if  FileExist s(JawsReco rd[X].FDic tionaryFil eName) the n
  2275              JawsRecord [X].FDicti onaryFile. LoadFromFi le
  2276                (JawsRec ord[X].FDi ctionaryFi leName);
  2277         end;
  2278  
  2279         Add  := TRUE;
  2280         idx  := -1;
  2281         for  I := 0 to  JawsRecord [X].FDicti onaryFile. Count - 1  do
  2282         begi n
  2283           li ne := Jaws Record[X]. FDictionar yFile[I];
  2284           De codeLine(l ine, befor e1, after1 );
  2285           if  (before1  = Before)  then
  2286           be gin
  2287              idx := I;
  2288              if after1  = After th en
  2289                Add := F ALSE;
  2290              break;
  2291           en d;
  2292         end;
  2293         if A dd then
  2294         begi n
  2295           li ne := DICT _DELIM + B efore + DI CT_DELIM +  After + D ICT_DELIM;
  2296           if  idx < 0 t hen
  2297              JawsRecord [X].FDicti onaryFile. Add(line)
  2298           el se
  2299              JawsRecord [X].FDicti onaryFile[ idx] := li ne;
  2300           mo dified :=  TRUE;
  2301           Ja wsRecord[X ].FDiction aryFileMod ified := T RUE;
  2302         end;
  2303       end;
  2304     end;
  2305  
  2306     procedur e RemoveCo mponentCla ss;
  2307     Var
  2308       I: Int eger;
  2309     begin
  2310       for I  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2311         Remo veFromINIF ile(JawsRe cord[I].FC onfigINIFi le,
  2312           Ja wsRecord[I ].FConfigI NIFileModi fied, Jaws Record[I]. FConfigFil e,
  2313           Wi ndowClasse sSection,  Before);
  2314     end;
  2315  
  2316     procedur e RemoveMS AAClass;
  2317     Var
  2318       I: Int eger;
  2319     begin
  2320       for I  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2321         Remo veFromINIF ile(JawsRe cord[I].FC onfigINIFi le,
  2322           Ja wsRecord[I ].FConfigI NIFileModi fied, Jaws Record[I]. FConfigFil e,
  2323           MS AAClassesS ection, Be fore);
  2324     end;
  2325  
  2326     procedur e PurgeKey Mappings;
  2327     var
  2328       I, X:  Integer;
  2329       Name,  Value: str ing;
  2330       keys:  TStringLis t;
  2331       delete : Boolean;
  2332     begin
  2333       for X  := Low(Jaw sRecord) t o High(Jaw sRecord) d o
  2334       begin
  2335         if n ot assigne d(JawsReco rd[X].FKey MapINIFile ) then
  2336         begi n
  2337           Ma keFileWrit able(JawsR ecord[X].F KeyMapFile );
  2338           Ja wsRecord[X ].FKeyMapI NIFile :=
  2339              TINIFile.C reate(Jaws Record[X]. FKeyMapFil e);
  2340           Ja wsRecord[X ].FKeyMapI NIFileModi fied := FA LSE;
  2341         end;
  2342         keys  := TStrin gList.Crea te;
  2343         try
  2344           Ja wsRecord[X ].FKeyMapI NIFile.Rea dSectionVa lues(Commo nKeysSecti on, keys);
  2345           fo r I := key s.Count -  1 downto 0  do
  2346           be gin
  2347              Value := C opy(keys.V alueFromIn dex[I], 1,  KeyComman dLen);
  2348              if Value =  KeyComman d then
  2349              begin
  2350                name :=  keys.Names [I];
  2351                delete : = (not ass igned(Jaws Record[X]. FAssignedK eys));
  2352                if not d elete then
  2353                  delete  := (JawsR ecord[X].F AssignedKe ys.IndexOf (name) < 0 );
  2354                if delet e then
  2355                begin
  2356                  JawsRe cord[X].FK eyMapINIFi le.DeleteK ey(CommonK eysSection , name);
  2357                  JawsRe cord[X].FK eyMapINIFi leModified  := TRUE;
  2358                  modifi ed := TRUE ;
  2359                end;
  2360              end;
  2361           en d;
  2362         fina lly
  2363           ke ys.free;
  2364         end;
  2365       end;
  2366     end;
  2367  
  2368   begin
  2369     { TODO :  check fil e io error s when upd ating conf ig files }
  2370     modified  := FALSE;
  2371     case Act ion of
  2372       BEHAVI OR_ADD_DIC TIONARY_CH ANGE:
  2373         Regi sterCustom Dictionary Change;
  2374       BEHAVI OR_ADD_COM PONENT_CLA SS:
  2375         Regi sterCustom ClassChang e;
  2376       BEHAVI OR_ADD_COM PONENT_MSA A:
  2377         Regi sterMSAACl assChange;
  2378       BEHAVI OR_ADD_CUS TOM_KEY_MA PPING:
  2379         Regi sterCustom KeyMapping ;
  2380       BEHAVI OR_ADD_CUS TOM_KEY_DE SCRIPTION:
  2381         Regi sterCustom KeyDescrip tion;
  2382       BEHAVI OR_REMOVE_ COMPONENT_ CLASS:
  2383         Remo veComponen tClass;
  2384       BEHAVI OR_REMOVE_ COMPONENT_ MSAA:
  2385         Remo veMSAAClas s;
  2386       BEHAVI OR_PURGE_U NREGISTERE D_KEY_MAPP INGS:
  2387         Purg eKeyMappin gs;
  2388     end;
  2389     if modif ied and as signed(FMa inForm) th en
  2390     begin
  2391       FMainF orm.ResetI NITimer(Ki llINIFiles );
  2392       FMainF orm.Config ReloadNeed ed;
  2393     end;
  2394   end;
  2395  
  2396   // ******* ********** ********** ********** ********** ********** *********
  2397   // Fires o ff the rel oad all co nfigs thro ugh Jaws
  2398   // ******* ********** ********** ********** ********** ********** *********
  2399   procedure  TJAWSManag er.ReloadC onfigurati on;
  2400   begin
  2401     if not a ssigned(JA WSAPI) the n
  2402       JAWSAP I := CoJaw sApi.Creat e;
  2403     JAWSAPI. RunFunctio n('ReloadA llConfigs' );
  2404   end;
  2405  
  2406   // ******* ********** ********** ********** ********** ********** *********
  2407   // Send ei ther data  or event t o Jaws
  2408   // ******* ********** ********** ********** ********** ********** *********
  2409   procedure  TJAWSManag er.SendCom ponentData (WindowHan dle: HWND;
  2410     DataStat us: LongIn t; Caption , Value, d ata, Contr olType, St ate, Instr uctions,
  2411     ItemInst ructions:  PChar);
  2412  
  2413   // ******* ********** ********** ********** ********** ********** *********
  2414   // Send to  dispatche r
  2415   // ******* ********** ********** ********** ********** ********** *********
  2416     procedur e SendRequ estRespons e;
  2417     begin
  2418       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_CAPTIO N, Caption );
  2419       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_VALUE,  Value);
  2420       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_CONTRO L_TYPE, Co ntrolType) ;
  2421       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_STATE,  State);
  2422       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_INSTRU CTIONS, In structions );
  2423       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_ITEM_I NSTRUCTION S,
  2424         Item Instructio ns);
  2425       FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_DATA_S TATUS, Int ToStr(Data Status));
  2426       FMainF orm.PostDa ta;
  2427     end;
  2428  
  2429   // ******* ********** ********** ********** ********** ********** *********
  2430   // Run the  change ev ent throug h Jaws
  2431   // ******* ********** ********** ********** ********** ********** *********
  2432     procedur e SendChan geEvent;
  2433     var
  2434       Event:  WideStrin g;
  2435     begin
  2436       Event  := 'VA508C hangeEvent (' + IntTo Str(Window Handle) +  ',' +
  2437         IntT oStr(DataS tatus) + ' ,"' + StrP as(Caption ) + '","'  + StrPas(V alue) +
  2438         '"," ' + StrPas (ControlTy pe) + '"," ' + StrPas (State) +  '","' +
  2439         StrP as(Instruc tions) + ' ","' + Str Pas(ItemIn structions ) + '"';
  2440       if not  assigned( JAWSAPI) t hen
  2441         JAWS API := CoJ awsApi.Cre ate;
  2442       JAWSAP I.RunFunct ion(Event)
  2443     end;
  2444  
  2445   begin
  2446     if (data  <> nil) a nd (Length (data) > 0 ) then
  2447     begin
  2448       Value  := data;
  2449       DataSt atus := Da taStatus A ND DATA_MA SK_DATA;
  2450       DataSt atus := Da taStatus O R DATA_VAL UE;
  2451     end;
  2452     if (Data Status and  DATA_CHAN GE_EVENT)  <> 0 then
  2453     begin
  2454       DataSt atus := Da taStatus A ND DATA_MA SK_CHANGE_ EVENT;
  2455       SendCh angeEvent;
  2456     end
  2457     else
  2458       SendRe questRespo nse;
  2459   end;
  2460  
  2461   // ******* ********** ********** ********** ********** ********** *********
  2462   // Display  a certian  error
  2463   // ******* ********** ********** ********** ********** ********** *********
  2464   class proc edure TJAW SManager.S howError(E rrorNumber : Integer) ;
  2465   begin
  2466     ShowErro r(ErrorNum ber, []);
  2467   end;
  2468  
  2469   // ******* ********** ********** ********** ********** ********** *********
  2470   // Display  a certian  formated  error
  2471   // ******* ********** ********** ********** ********** ********** *********
  2472   class proc edure TJAW SManager.S howError(E rrorNumber : Integer;
  2473     data: ar ray of con st);
  2474   var
  2475     error: s tring;
  2476  
  2477   begin
  2478     if not J AWSErrorsS hown[Error Number] th en
  2479     begin
  2480       error  := JAWSErr orMessage[ ErrorNumbe r];
  2481       if Len gth(data)  > 0 then
  2482         erro r := Forma t(error, d ata);
  2483       JAWSEr rorsShown[ ErrorNumbe r] := TRUE ;
  2484      if Assi gned(UserS plash) the n
  2485       UserSp lash.ShowS ystemError ('JAWS Acc essibility  Component  Error' +  CRLF + PCh ar(error))
  2486      else
  2487       Messag eBox(0, PC har(error) , 'JAWS Ac cessibilit y Componen t Error',
  2488        MB_OK  or MB_ICO NERROR or  MB_TASKMOD AL or MB_T OPMOST);
  2489  
  2490     end;
  2491   end;
  2492  
  2493   // ******* ********** ********** ********** ********** ********** *********
  2494   // Clean u p files an d memory
  2495   // ******* ********** ********** ********** ********** ********** *********
  2496   procedure  TJAWSManag er.ShutDow n;
  2497   var
  2498     I: Integ er;
  2499   begin
  2500     if FWasS hutdown th en
  2501       exit;
  2502     if assig ned(JAWSAP I) then
  2503     begin
  2504       try
  2505         JAWS API := nil ; // cause s access v iolation
  2506       except
  2507       end;
  2508     end;
  2509     KillINIF iles(nil);
  2510     if assig ned(FMainF orm) then
  2511       FreeAn dNil(FMain Form);
  2512     FWasShut down := TR UE;
  2513     if assig ned(FHidde nJaws) the n
  2514       FHidde nJaws.free ;
  2515     SetLengt h(JawsReco rd, 0);
  2516     for I :=  Low(Scrip tFiles) to  High(Scri ptFiles) d o
  2517     begin
  2518       SetLen gth(Script Files[I].A dd_To_Uses , 0);
  2519       SetLen gth(Script Files[I].D ependencie s, 0);
  2520     end;
  2521     SetLengt h(ScriptFi les, 0);
  2522   end;
  2523  
  2524   // ******* ********** ********** ********** ********** ********** *********
  2525   // Say a s pecific st ring throu gh Jaws
  2526   // ******* ********** ********** ********** ********** ********** *********
  2527   procedure  TJAWSManag er.SpeakTe xt(Text: P Char);
  2528   begin
  2529     if not a ssigned(JA WSAPI) the n
  2530       JAWSAP I := CoJaw sApi.Creat e;
  2531     JAWSAPI. SayString( Text, FALS E);
  2532   end;
  2533  
  2534  
  2535     // ***** ********** ********** ********** ********** ********** ********** *
  2536     // Ensur e the hidd en main wi ndow is cr eated and  recompile
  2537     // ***** ********** ********** ********** ********** ********** ********** *
  2538     procedur e TJAWSMan ager.Ensur eWindow;
  2539     begin
  2540       if not  assigned( FMainForm)  then
  2541         FMai nForm := T frmVA508Hi ddenJawsMa inWindow.C reate(nil) ;
  2542       FMainF orm.Compon entDataCal lBackProc  := fCompon entCallBac kProc;
  2543       FMainF orm.Config ReloadProc  := Reload Configurat ion;
  2544       FMainF orm.Handle Needed;
  2545       Applic ation.Proc essMessage s;
  2546     end;
  2547  
  2548   {$REGION ' ********** ********** ****** Arc hived Meth od ******* ********** ********'}
  2549   {
  2550     class fu nction TJA WSManager. GetPathFro mJAWS(Path ID: Intege r;
  2551     DoLowerC ase: boole an = TRUE) : string;
  2552     const
  2553     JAWS_MES SAGE_ID =  'JW_GET_FI LE_PATH';
  2554     // versi on is in d irectory a fter JAWS  \Freedom S cientific\ JAWS\*.*\. ..
  2555     JAWS_PAT H_ID_APPLI CATION = 0 ;
  2556     JAWS_PAT H_ID_USER_ SCRIPT_FIL ES = 1;
  2557     JAWS_PAT H_ID_JAWS_ DEFAULT_SC RIPT_FILES  = 2;
  2558     // 0 = C :\Program  Files\Free dom Scient ific\JAWS\ 8.0\jfw.IN I
  2559       // 1 = D:\ Documents  and Settin gs\ DNS \Applicati on Data\Fr eedom Scie ntific\JAW S\8.0\USER .INI
  2560     // 2 = D :\Document s and Sett ings\All U sers\Appli cation Dat a\Freedom  Scientific \JAWS\8.0\ Settings\e nu\DEFAULT .SBL
  2561     var
  2562     atm: ATO M;
  2563     len: Int eger;
  2564     path: st ring;
  2565     JAWSWind ow: HWND;
  2566     JAWSMsgI D: UINT =  0;
  2567     begin
  2568     JAWSWind ow := GetJ AWSWindow;
  2569     if JAWSM sgID = 0 t hen
  2570     JAWSMsgI D := Regis terWindowM essage(JAW S_MESSAGE_ ID);
  2571     Result : = '';
  2572     atm := S endMessage (JAWSWindo w, JAWSMsg ID, PathID , 0);
  2573     if atm < > 0 then
  2574     begin
  2575     SetLengt h(path, MA X_PATH * 2 );
  2576     len := G lobalGetAt omName(atm , PChar(pa th), MAX_P ATH * 2);
  2577     GlobalDe leteAtom(a tm);
  2578     if len >  0 then
  2579     begin
  2580     SetLengt h(path, le n);
  2581     Result : = ExtractF ilePath(pa th);
  2582     if DoLow erCase the n
  2583     Result : = LowerCas e(Result);
  2584     end;
  2585     end;
  2586     end;
  2587   }
  2588   {$ENDREGIO N}
  2589   {$ENDREGIO N}
  2590  
  2591   {function  tCompileFi le.Compile File(var R tnMsg: Str ing): inte ger;
  2592   begin
  2593    result :=  ExecuteAn dWait('"'  + Compiler  + '"', Rt nMsg, '"'  + FileName  + '"');
  2594   end; }
  2595  
  2596   function t CompileFil e.CompileF ile(var Rt nMsg: Stri ng): Boole an;
  2597   var
  2598    RtnLst: T StringList ;
  2599   begin
  2600    RtnLst :=  TStringLi st.Create;
  2601    try
  2602    Result :=  RunSilent Cmd(Compil er, FileNa me, RtnMsg );
  2603    RtnLst.te xt := RtnM sg;
  2604    if RtnLst .Count > 1  then
  2605     Result : = false;
  2606  
  2607    finally
  2608      RtnLst. Free;
  2609    end;
  2610  
  2611   end;
  2612  
  2613   Function F indCommand Switch(Swi tchName: s tring; var  ReturnVal ue: string )
  2614     : Boolea n;
  2615   begin
  2616   {$IFDEF VE R180}
  2617     Result : = D2006Fin dCmdLineSw itch('Swit chName', R eturnValue , TRUE,
  2618       [clstD 2006ValueA ppended]);
  2619   {$ELSE}
  2620     Result : = FindCmdL ineSwitch( 'SwitchNam e', Return Value, TRU E,
  2621       [clstV alueAppend ed]);
  2622   {$ENDIF}
  2623   end;
  2624  
  2625   Function F indCommand Switch(Swi tchName: s tring): Bo olean;
  2626   begin
  2627   {$IFDEF VE R180}
  2628     Result : = D2006Fin dCmdLineSw itch(Switc hName, ['- '], TRUE);
  2629   {$ELSE}
  2630     Result : = FindCmdL ineSwitch( SwitchName , ['-'], T RUE);
  2631   {$ENDIF}
  2632   end;
  2633  
  2634   initializa tion
  2635  
  2636   LogInterfa ce.Active  := FindCom mandSwitch ('JL');
  2637  
  2638   CoInitiali zeEx(nil,  COINIT_MUL TITHREADED );//COINIT _APARTMENT THREADED);
  2639  
  2640   Applicatio n.MainForm OnTaskbar  := True;
  2641  
  2642   finalizati on
  2643  
  2644   ShutDown;
  2645  
  2646   CoUninitia lize;
  2647  
  2648   end.