home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / fi_98148.zip / EXAMPLE.CMD next >
OS/2 REXX Batch file  |  1998-05-28  |  3KB  |  68 lines

  1. /* TEST PROGRAM FOR FASTINI.DLL (http://www.ozemail.com.au/~dbareis) */
  2.  
  3. /*--- Get parameter ---------------------------------------------------------*/
  4. UserCmd = translate(strip(arg(1)));
  5. if UserCmd <> "FAST" & UserCmd <> "SLOW" then
  6. do
  7.    say 'ERROR: This test program requires a parameter "FAST" or "SLOW"!';
  8.    exit(255);
  9. end;
  10.  
  11. /*--- Initialization --------------------------------------------------------*/
  12. IniFile = "INITEST.INI";
  13. call RxFuncAdd  'SysIni', 'RexxUtil', 'SysIni';
  14.  
  15. /*--- Prepare INI for fast access -------------------------------------------*/
  16. Dummy = time('Reset');
  17. if UserCmd = "FAST" then
  18. do
  19.    /*--- Load up functions --------------------------------------------------*/
  20.    call RxFuncAdd  'FastIniStart',   'FastIni',  'FastIniStart';
  21.    call RxFuncAdd  'FastIniEnd',     'FastIni',  'FastIniEnd';
  22.    call RxFuncAdd  'FastIniVersion', 'FastIni',  'FastIniVersion';
  23.  
  24.    /*--- Output information -------------------------------------------------*/
  25.    say 'You can have as many INI files opened for "fast" access as you wish.  You';
  26.    say 'should note that any writes are not written to disk until you close them.';
  27.    say 'It is highly recommended that you Trap "NOVALUE"/"SYNTAX"/"HALT" at least';
  28.    say 'and ensure any opened handles are closed.';
  29.    say '';
  30.    say 'Note that a future release (not distant!) will provide better and safer';
  31.    say 'example code that can be included into your code with HTMLPP.';
  32.    say '';
  33.    say '';
  34.  
  35.    /*--- Load INI to improve performance ------------------------------------*/
  36.    FastRc = FastIniStart(IniFile, "IniHandle");   /* Don't really need to check Rc */
  37.    if  FastRc = 'OK' then
  38.        say 'IniHandle=' || IniHandle;
  39.    else
  40.        say 'Fast Load failed. ' || FastRc;
  41. end;
  42.  
  43. /*--- Write 200 values ------------------------------------------------------*/
  44. Count = 0;
  45. do x = 1 to 20
  46.    do  Key = 1 to 10
  47.        call SysIni IniFile, App||x, Key, "New Value - " || Count;
  48.        Count = Count + 1;
  49.    end;
  50. end;
  51. say Count || ' values set....';
  52. say ''
  53.  
  54. /*--- Close Fast INI file ---------------------------------------------------*/
  55. if UserCmd = "FAST" then
  56. do
  57.    /*--- This will write out (checkpoint) all previous changes --------------*/
  58.    call FastIniEnd  IniHandle;
  59. end;
  60.  
  61. /*--- Tell user how long it took --------------------------------------------*/
  62. say 'Took ' || time('Elapsed') || ' seconds in ' || UserCmd || ' mode.';
  63.  
  64. /*--- Output version Info ---------------------------------------------------*/
  65. call FastIniVersion("VersionInfo");
  66. say  VersionInfo;
  67. exit(0);
  68.