home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 4 Drivers / 04-Drivers.zip / osawew3.zip / DISK2 / WINSTALL.CMD
OS/2 REXX Batch file  |  1996-10-17  |  35KB  |  786 lines

  1. /* ╔═════════════════════════════════════════════════════════════╗ */
  2. /* ║    !!! DO NOT MODIFY THIS FILE UNDER ANY CIRCUMSTANCES !!!  ║ */
  3. /* ╚═════════════════════════════════════════════════════════════╝ */
  4. /* ┌─────────────────────────────────────────────────────────────┐ */
  5. /* │                Adding WINOS2 Audio Support                  │ */
  6. /* ├─────────────────────────────────────────────────────────────┤ */
  7. /* │                                                             │ */
  8. /* │ This REXX program installs the WIN-OS2 audio support        │ */
  9. /* │ for the following current OS/2-supported audio adapters:    │ */
  10. /* │                                                             │ */
  11. /* │        -   The IBM M-Audio Adapter                          │ */
  12. /* │        -   The Sound Blaster Non-Pro ISA or MCV Adapter     │ */
  13. /* │        -   The Sound Blaster Pro OPL2 Adapter               │ */
  14. /* │        -   The Sound Blaster Pro MCV or OPL3 Adapter        │ */
  15. /* │        -   The Sound Blaster 16 / PnP                       │ */
  16. /* │        -   The Pro Audio Spectrum 16                        │ */
  17. /* │        -   The Media Vision Jazz 16 Adapter                 │ */
  18. /* │        -   The Aztech Sound Galaxy NOVA 16 EXTRA            │ */
  19. /* │        -   The Aztech Sound Galaxy Wave 32 +                │ */
  20. /* │        -   The ESS-688 Audio Adapter                        │ */
  21. /* │        -   The ESS-1688 Audio Adapter                       │ */
  22. /* │        -   The ESS-1788 Audio Adapter                       │ */
  23. /* │        -   The ESS-1868 Audio Adapter                       │ */
  24. /* │        -   The ESS-1888 Audio Adapter                       │ */
  25. /* │        -   The Sound Blaster AME 32 Adapter / PnP           │ */
  26. /* │        -   The Crystal Semi CS4231 Adapter                  │ */
  27. /* │        -   The Crystal Semi CS4232/4236 PnP Adapter         │ */
  28. /* │        -   The IBM Thinkpad Audio - Crystal Semi 4231       │ */
  29. /* │                                                             │ */
  30. /* │ Usage:                                                      │ */
  31. /* │        At an OS/2 prompt, type:                             │ */
  32. /* │                                                             │ */
  33. /* │            WINSTALL SB16D2                                  │ */
  34. /* │                                                             │ */
  35. /* │                                                             │ */
  36. /* │ (C) Copyright International Business Machines Corp.  1996   │ */
  37. /* └─────────────────────────────────────────────────────────────┘ */
  38.  
  39. '@echo off'
  40. trace 'o'
  41. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  42. call SysLoadFuncs
  43.  
  44. call SysCls
  45. say
  46. say '  ╔═════════════════════════════════════════════════════════════╗'
  47. say '  ║                                                             ║'
  48. say '  ║    Updating WIN-OS2 system files now.  Please wait ...      ║'
  49. say '  ║                                                             ║'
  50. say '  ╚═════════════════════════════════════════════════════════════╝'
  51.  
  52.  
  53. /*******************************************************************/
  54. /*                                                                 */
  55. /*   Get the BOOTDRIVE of OS/2 using environment variable PATH     */
  56. /*   All files to be modified will be on this BOOTDRIVE            */
  57. /*                                                                 */
  58. /*******************************************************************/
  59.  
  60. BootDrvSpec = SysSearchPath('PATH', 'CMD.EXE')
  61. OSDrvCheck  = SysSearchPath('PATH', 'OS2KRNL')
  62. if (BootDrvSpec = '') then
  63.         call NON_OS2_PARTITION_ERROR
  64. if (OSDrvCheck = '') then
  65.         call NON_OS2_PARTITION_ERROR
  66.  
  67.               /* if reached here, boot drive is an OS/2 partition */
  68. BootDrv = left(OSDrvCheck, 2)
  69.  
  70. /*******************************************************************/
  71. /*                                                                 */
  72. /*   Check whether WINOS2 is installed; if yes, is SYSTEM.INI file */
  73. /*   there?  This file is essential for WINOS2 audio to work       */
  74. /*                                                                 */
  75. /*******************************************************************/
  76.  
  77. WinOS2Check = SysSearchPath('PATH', 'SYSTEM.INI')
  78. if (WinOS2Check = '') then
  79. do
  80.         call SysFileTree BootDrv||'\OS2\MDOS\WINOS2\SYSTEM.INI', ini_check, 'F'
  81.         if ini_check.0 = 0 then
  82.                 call NO_WINOS2_INSTALLED_ERROR
  83. end
  84.  
  85. /*******************************************************************/
  86. /*  a parameter is expected at the prompt:                         */
  87. /*                                                                 */
  88. /*      winstall sb16d2                                            */
  89. /*                                                                 */
  90. /*  Error if no parameter following winstall.                      */
  91. /*******************************************************************/
  92.  
  93. DefaultFound = 0
  94. WinDriverList = BootDrv||'\OS2\DRIVERS\*.'
  95. call SysFileTree WinDriverList, WinDrivers, 'OD'
  96.  
  97. /* if no win driver files under \os2\drivers directory */
  98. /* then cannot proceed installation; exit              */
  99.  
  100. if WinDrivers.0 = 0 then
  101.         call NO_WIN_DRIVERS_ERROR
  102.  
  103. /* if there are win drivers, there is one matching the one on   */
  104. /* command line?                                                */
  105. Parse Arg all
  106. Do i=1 to 1     /* expandable to handle more than one args      */
  107.         word = translate(word(all,i))
  108.         call CheckControlFile BootDrv||'\OS2\DRIVERS\'||word
  109.         WinDriver = BootDrv||'\OS2\DRIVERS\'||word
  110. End
  111.  
  112. /*******************************************************************/
  113. /*                                                                 */
  114. /*    If only one audio device found, fall through here ...        */
  115. /*    At this point, we got WinDriver, which is also the name of   */
  116. /*    the .ctl file; for example, WinDriver = es1688dd, then we    */
  117. /*    expect a file es1688dd.ctl in the \OS2\DRIVERS\ES1688DD dir  */
  118. /*                                                                 */
  119. /*    We also know:                                                */
  120. /*                                                                 */
  121. /*      .  the .ctl file exists;                                   */
  122. /*      .  it is a valid file for this audio device;               */
  123. /*      .  source directory where to copy the WIN-OS2 drivers from */
  124. /*      .  Boot drive: BootDrv                                     */
  125. /*                                                                 */
  126. /*    Start parsing the .ctl file here; error handling done here   */
  127. /*                                                                 */
  128. /*******************************************************************/
  129.  
  130.                                    /* Get all the global variables */
  131.  
  132. parse value WinDriver with '\OS2\DRIVERS\' win_driver
  133. control_file = WinDriver||'\'||win_driver||'.ctl'
  134. call SysFileTree control_file, ctl_check, 'F'
  135. if ctl_check.0 = 0 then
  136.         call FILE_NOT_EXISTENT_OUTPUT control_file
  137.  
  138. /* say 'copying control file ' control_file */
  139. copy control_file WinDriver||'\'||win_driver||'.JUK'
  140. control_file2 = WinDriver||'\'||win_driver||'.JUK'      /* for a subroutine                 */
  141. TargetDir     = BootDrv||'\OS2\MDOS\WINOS2\SYSTEM\'     /* official place to put the driver */
  142. IniFileDir    = BootDrv||'\OS2\MDOS\WINOS2\'            /* where system.ini is              */
  143. copy IniFileDir||'system.ini' IniFileDir||'system.org > NUL' /* back up system.ini          */
  144. copy IniFileDir||'system.ini' IniFileDir||'system.bak > NUL' /* back up system.ini          */
  145. copy IniFileDir||'system.ini' IniFileDir||'system.juk > NUL' /* temp system.ini for source  */
  146.  
  147. /*******************************************************************/
  148. /*                                                                 */
  149. /*   From the .ctl file, get the names of driver files to be       */
  150. /*   copied and copy them from the source directory to the target  */
  151. /*   directory; exit if any of those files do not exist; WINOS2    */
  152. /*   audio will not work if these files are missing                */
  153. /*                                                                 */
  154. /*******************************************************************/
  155.  
  156.                     /* Get [COPIED_FILES] section in the .ctl file */
  157.  
  158. call SysFileSearch '[COPIED_FILES]', control_file, 'DrvFiles.', 'N'
  159. if DrvFiles.0 = 0 then
  160.         call CONTROL_FILE_ERROR_OUTPUT control_file
  161. else
  162.         parse value DrvFiles.1 with startline ' '
  163.  
  164. do startline
  165.         line = linein(control_file)     /* brings to the first line  */
  166.                                         /* of [COPIED_FILES] section */
  167. end
  168. line = linein(control_file)
  169. parse value line with '"' NumFiles '"'  /* parse out number of files */
  170.  
  171. do i = 1 to NumFiles                    /* parse out the files and   */
  172.         line = linein(control_file)     /* copy them; check errors   */
  173.         parse value line with '"' DriverFile '"' '"' CopyToDir '"'
  174.         call SysFileTree WinDriver||'\'||DriverFile, 'check', 'FSO'     /* 'FSO' works best  */
  175.         if (check.0 = 0) then                                           /* with copy command */
  176.                 call FILE_NOT_EXISTENT_OUTPUT DriverFile
  177.         copy check.1 BootDrv||CopyToDir' > NUL'
  178. end
  179.  
  180.  
  181. /*******************************************************************/
  182. /*                                                                 */
  183. /*   Get [MODIFY] section and start modifying the .INI file(s)     */
  184. /*   under the \OS2\MDOS\WINOS2 directory                          */
  185. /*                                                                 */
  186. /*******************************************************************/
  187.  
  188. call lineout(control_file)         /* close it to reset all values */
  189. call SysFileSearch '[MODIFY]', control_file, 'Modify.', 'N'
  190. if Modify.0 = 0 then
  191.         call CONTROL_FILE_ERROR_OUTPUT control_file
  192. else
  193.         parse value Modify.1 with startline ' '
  194.  
  195. do startline
  196.         line = linein(control_file)     /* brings to the first line  */
  197.                                         /* of that section           */
  198. end
  199. line = linein(control_file)
  200. parse value line with '"' num_files_modify '"'
  201.  
  202.  
  203. /*******************************************************************/
  204. /*                                                                 */
  205. /*    The following section contains nested loops.  The basic      */
  206. /*    structure is as follows:                                     */
  207. /*                                                                 */
  208. /*    Number of FILES to be modified                               */
  209. /*      Number of SECTIONS in each FILE to be modified/created     */
  210. /*        Number of LINES in each SECTION to be added              */
  211. /*        end                                                      */
  212. /*      end                                                        */
  213. /*    end                                                          */
  214. /*                                                                 */
  215. /*******************************************************************/
  216.  
  217. do nth =1 to num_files_modify
  218.  
  219.      /* need to go to the line describing how to modify 'nth' file */
  220.   cur_file = 0
  221.   call lineout(control_file)        /* close it if opened to reset */
  222.   do while cur_file <> nth
  223.         line = linein(control_file)
  224.         parse value line with '"' NumSections '"' '"' file_path '"' '"' file_name '"' '"<FILE' cur_file '>"'
  225.  
  226.   end
  227.   /*
  228.         say 'File #' cur_file 'Numsections = ' NumSections
  229.         say 'File #' cur_file 'Filepath    = ' BootDrv||file_path
  230.         say 'File #' cur_file 'FileName    = ' file_name
  231.   */
  232.                                /* make a backup of this file first */
  233.   say
  234.   say ' Backing up file: ' file_name ' ...'
  235.   say ' '
  236.   call DISPLAY_MOVING_BAR 10
  237.   say ' '
  238.  
  239.   parse value file_name with prefix '.' junk
  240.   copy BootDrv||file_path||'\'||file_name BootDrv||file_path||'\'||prefix||'.org > NUL'
  241.   copy BootDrv||file_path||'\'||file_name BootDrv||file_path||'\'||prefix||'.juk > NUL'
  242.  
  243.  
  244.   /******************************************************/
  245.   /*   Modify the sections now in file gotten above     */
  246.   /******************************************************/
  247.  
  248.   say ' Updating the system file(s) now.  Please wait ... '
  249.  
  250.  
  251.   original_file = BootDrv||file_path||'\'||prefix||'.juk'
  252.   modified_file = BootDrv||file_path||'\'||file_name
  253.  
  254.   do i = 1 to NumSections                    /* parse out the lines which  */
  255.         Current = 0                          /* to put in the system.ini   */
  256.         current_file = 0
  257.         call lineout modified_file,,1        /* open; set at 1             */
  258.         do while (Current <> i & current_file <> nth)     /* Skip non-related lines */
  259.                 line = linein(control_file)
  260.                 parse value line with '"' Current '"' '"[' SectionName ']"' '"<FILE' current_file '>"'
  261.         end
  262.         line = linein(control_file)
  263.         parse value line with '"' NumLines '"'
  264.         call SysFileSearch '['SectionName']', original_file, 'iniSection.', 'N'
  265.         if iniSection.0 = 0 then
  266.           do
  267.                 call lineout(modified_file)
  268.                 insertThis = ' '
  269.                 call lineout modified_file, insertThis
  270.                 insertThis = '['SectionName']'
  271.                 call lineout modified_file, insertThis
  272.                 do while (lines(original_file) <> 0)
  273.                    junk = linein(original_file)
  274.                 end          /* force to be at the end of ini file */
  275.                              /* New section will be added at end   */
  276.           end
  277.         else
  278.           do
  279.                 parse value iniSection.1 with startline ' '
  280.                 do startline                            /* write from beginning to */
  281.                     iniLine = Linein(original_file)     /* insertion point         */
  282.                     call lineout modified_file, iniLine
  283.                 end
  284.           end
  285.         do j = 1 to NumLines            /* ready to insert additional lines */
  286.                 line = linein(control_file)
  287.                 parse value line with '"' insertThis '"'
  288.  
  289.                 /* check if this line needs value parsed from config.sys */
  290.                 /* The .ctl file tells which parameter to parse          */
  291.  
  292.                 parse value insertThis with junk '=' test_param
  293.                 if (left(test_param, 1) = '*') then     /* need setting from config.sys */
  294.                   do
  295.                         /* get default value now */
  296.                         parse value line with '"' replace_line '"' '"' default_val '"'
  297.                         parse value replace_line with left_part '=*' param_name '*'
  298.                         new_value = default_val
  299.                         call GetOS2ParamValue control_file2||'=='||param_name        /* result will have the value */
  300.                         if (result = -1) then   /* nothing found in config.sys */
  301.                                 nop             /* do nothing, so use default  */
  302.                         else
  303.                                 new_value = result
  304.                         insertThis = left_part||'='||new_value
  305.                   end
  306.                 call lineout modified_file, insertThis
  307.         end
  308.  
  309.         do while (lines(original_file) <> 0)       /* finish writing the rest section */
  310.                 iniLine = linein(original_file)
  311.                 call lineout modified_file, iniLine
  312.         end
  313.  
  314.         call lineout(modified_file)    /* closes files so sys calls */
  315.         call lineout(original_file)    /* can re-new values         */
  316.         copy modified_file BootDrv||file_path||'\'||prefix||'.juk > NUL' /* back up file modified so far */
  317.   end
  318.  
  319.   /* cleaning up .juk files */
  320.   call SysFileDelete original_file
  321.   backed_up = BootDrv||file_path||'\'||prefix||'.org'
  322.  
  323.   say ' '
  324.   call DISPLAY_MOVING_BAR 15
  325.   say ' '
  326.  
  327.   say
  328. /*  say '  File 'original_file' is updated successfully.' */
  329.   say '  File 'file_name' is updated successfully.'
  330.   say '  Original version is backed up to 'backed_up'.'
  331.   say
  332.  
  333. end /* of do loop for number of files */
  334.  
  335. /*******************************************************************/
  336. /*                                                                 */
  337. /*   Get [WINOS2_SETTINGS] section and start modifying WINOS2      */
  338. /*   settings.                                                     */
  339. /*                                                                 */
  340. /*******************************************************************/
  341.  
  342. call lineout(control_file)         /* close it to reset all values */
  343. call SysFileSearch '[WINOS2_SETTINGS]', control_file, 'winos2.', 'N'
  344. if winos2.0 = 0 then
  345.         call CONTROL_FILE_ERROR_OUTPUT control_file
  346. else
  347.         parse value winos2.1 with startline ' '
  348.  
  349. do startline
  350.         line = linein(control_file)     /* brings to the first line  */
  351.                                         /* of that section           */
  352. end
  353. line = linein(control_file)
  354. parse value line with '"' num_settings_modify '"'
  355. do j=1 to num_settings_modify
  356.         line = linein(control_file)     /* get one setting each time */
  357.         parse value line with '"' current_setting '"'
  358.         call UPDATE_WIN_OS2_SETTINGS current_setting
  359. end
  360.  
  361.  
  362.  
  363. /*******************************************************************/
  364. /*                                                                 */
  365. /*   Get [SPECIAL_SETTINGS] section and start modifying WINOS2 or  */
  366. /*   DOS_DEVICE settings in which values may need to be parsed from*/
  367. /*   OS/2's config.sys file.                                       */
  368. /*                                                                 */
  369. /*******************************************************************/
  370.  
  371. call lineout(control_file)         /* close it to reset all values */
  372. call SysFileSearch '[SPECIAL_SETTINGS]', control_file, 'special.', 'N'
  373. if special.0 = 0 then
  374.         nop             /* if this section does not exist, do nothing */
  375. else
  376.   do
  377.         parse value special.1 with startline ' '
  378.  
  379.         do startline
  380.             line = linein(control_file)     /* brings to the first line  */
  381.                                             /* of that section           */
  382.         end
  383.         line = linein(control_file)
  384.         parse value line with '"' num_special_modify '"'
  385.         do j=1 to num_special_modify
  386.           line = linein(control_file)     /* get one setting each time */
  387.  
  388.           /* start reconstructing a new line with parsed values */
  389.           parse value line with '"' num_parsed '"' '"' String '"'
  390.           leftover = String
  391.           new_string = ''
  392.           do i=1 to num_parsed
  393.             parse value leftover with prefix '*' var_name '*' '<' default '>' leftover
  394.             /* get default value now */
  395.             var_value = default
  396.             if compare(var_name, 'BOOTDRV') = 0 then    /* special case */
  397.                 var_value = BootDrv
  398.             else
  399.               do
  400.                 call GetOS2ParamValue control_file2||'=='||var_name        /* result will have the value */
  401.                 if (result = -1) then   /* nothing found in config.sys */
  402.                         nop             /* do nothing, so use default  */
  403.                 else
  404.                         var_value = result
  405.               end /* else */
  406.  
  407.             /* keep appending finished values -- reconstructing String */
  408.             new_string = new_string||prefix||var_value
  409.           end /* do i=1 */
  410.           new_string = new_string||leftover     /* get trailing stuff */
  411.           call UPDATE_WIN_OS2_SETTINGS new_string
  412.         end /* num_special_modify */
  413.   end /* else */
  414.  
  415.  
  416. /*******************************************************************/
  417. /*                                                                 */
  418. /*   Cleaning up ...                                               */
  419. /*                                                                 */
  420. /*******************************************************************/
  421.  
  422. call SysFileDelete control_file2
  423. say
  424. say '  ╔═════════════════════════════════════════════════════════════╗'
  425. say '  ║                                                             ║'
  426. say '  ║    WINOS2 Audio is updated successfully.                    ║'
  427. say '  ║    To get WINOS2 sound, switch to a WIN-OS2 Session after   ║'
  428. say '  ║    rebooting your system.                                   ║'
  429. say '  ║                                                             ║'
  430. say '  ╚═════════════════════════════════════════════════════════════╝'
  431. say
  432. exit
  433.  
  434.  
  435.  
  436. /*******************************************************************/
  437. /*                                                                 */
  438. /*   Procedures called by the main program above                   */
  439. /*                                                                 */
  440. /*******************************************************************/
  441.  
  442. CONTROL_FILE_ERROR_OUTPUT: PROCEDURE
  443. do
  444.         arg control_file
  445.         say
  446.         say 'Error: file 'control_file' contains invalid formats;'
  447.         say '       Install cannot proceed without a valid control file.'
  448.         exit
  449. end
  450.  
  451. FILE_NOT_EXISTENT_OUTPUT: procedure
  452. do
  453.         arg FileName
  454.         say
  455.         say 'Error: file 'FileName' does not exist on your system;'
  456.         say '       In order to install WIN-OS2 audio, you must have'
  457.         say '       this file.'
  458.         say
  459.         say 'Suggestion: Use Selective Install to install the corresponding'
  460.         say '            OS/2 driver for your audio device.'
  461.         say
  462.         exit
  463. end
  464.  
  465. UPDATE_WIN_OS2_SETTINGS: PROCEDURE
  466. do
  467.         arg new_setting
  468.         /* say '::UPDATE_WIN_OS2..., param passed in is ' new_setting */
  469.         call SysSetObjectData '<WP_WINFS>',   new_setting
  470.         call SysSetObjectData '<WP_WIN2WIN>', new_setting
  471.         return
  472. end
  473.  
  474. NON_OS2_PARTITION_ERROR: PROCEDURE
  475. do
  476.         say
  477.         say 'ERROR: Either OS/2 is not running, or this program is not running'
  478.         say 'from an OS/2 Window.  Please run this command from an OS/2 window.'
  479.         say
  480.         exit
  481. end
  482.  
  483. NO_WINOS2_INSTALLED_ERROR: PROCEDURE
  484. do
  485.         say
  486.         say 'ERROR: WIN-OS2 is not installed in your system.'
  487.         say 'If you have WARP Full Pack, use Selective Install to'
  488.         say 'install WIN-OS2.  Then, try this program.'
  489.         say
  490.         exit
  491. end
  492.  
  493. NO_WIN_DRIVERS_ERROR: PROCEDURE
  494. do
  495.         say
  496.         say 'Error: No valid drivers found under \OS2\DRIVERS directory;'
  497.         say '       In order to install WIN-OS2 audio, you must have'
  498.         say '       driver files which reside under a particular diectory.'
  499.         say
  500.         say 'Suggestion: Use Selective Install to install the corresponding'
  501.         say '            OS/2 driver for your audio device.'
  502.         say
  503.         exit
  504. end
  505.  
  506.  
  507. /*******************************************************************/
  508. /*                                                                 */
  509. /*   PROCEDURE: IsDefault                                          */
  510. /*                                                                 */
  511. /*              Check to see if driver name passed in is a default */
  512. /*              OS/2 device; we need the settings such as port     */
  513. /*              address, interrupt level, etc. from the OS/2 driver*/
  514. /*              if it is default, then return 1 (true); if not,    */
  515. /*              return 0 (false).                                  */
  516. /*                                                                 */
  517. /*   Input    : Driver name.  For example, ES1688DD.SYS            */
  518. /*   Output   : 1 if yes; 0 if no                                  */
  519. /*                                                                 */
  520. /*******************************************************************/
  521.  
  522. IsDefault: PROCEDURE
  523. do
  524.         arg DriverPathName
  525.         call CheckControlFile DriverPathName     /* if exists, return; otherwise, exit */
  526.         BootDrv = left(DriverPathName, 2)
  527.         parse value DriverPathName with '\OS2\DRIVERS\' control_file
  528.         control_file = DriverPathName||'\'||control_file||'.CTL'
  529.  
  530.         call SysFileTree control_file, ctl_check, 'F'
  531.         if ctl_check.0 = 0 then
  532.                 call FILE_NOT_EXISTENT_OUTPUT
  533.  
  534.         call SysFileSearch '[PDD_INFO]', control_file, 'params.', 'N'
  535.         if DrvFiles.0 = 0 then
  536.                 call CONTROL_FILE_ERROR_OUTPUT
  537.         else
  538.                 parse value params.1 with startline ' '
  539.  
  540.         /* say '::IsDefault, startline for [PDD_INFO] = ' startline */
  541.         do startline
  542.                 line = linein(control_file)     /* brings to the first line  */
  543.                                                 /* of [PDD_INFO] section */
  544.         end
  545.         line = linein(control_file)
  546.         parse upper value line with '"' pdd_name '"'
  547.         /* say '::IsDefault, line starts with OS/2 audio driver:' pdd_name */
  548.         line = linein(control_file)            /* get number of params */
  549.         parse upper value line with '"' vdd_name '"'
  550.         line = linein(control_file)
  551.         parse value line with '"' num_params '"'
  552.  
  553.         /* with pdd_name and vdd_name, it is sufficient to find out default  */
  554.         /* OS/2 audio device; search for [defaultnames] section in MMPM2.INI */
  555.  
  556.  
  557. /*?*/
  558.         call lineout(BootDrv||'\MMOS2\MMPM2.INI')    /* close mmpm2.ini for later search */
  559.  
  560.  
  561.  
  562.         call SysFileSearch '[defaultnames]', BootDrv||'\MMOS2\MMPM2.INI', 'd_names.', 'N'
  563.         if d_names.0 = 0 then
  564.         do
  565.                 call lineout(control_file)     /* close file if opened       */
  566.                 return 1                       /* none or 1 device installed */
  567.         end
  568.         parse value d_names.1 with startline ' ' junk
  569.         do startline
  570.                 line = linein(BootDrv||'\MMOS2\MMPM2.INI')
  571.         end
  572.  
  573.         w_word = ' '
  574.         count = 0
  575.         do while (compare('WAVEAUDIO', w_word, ' ') & count < 10)
  576.                 line = linein(BootDrv||'\MMOS2\MMPM2.INI')
  577.                 parse upper value line with w_word '=' wave_device
  578.                 w_word = right(w_word, 9)       /* forget blanks */
  579.                 count = count + 1               /* if mmpm2.ini is corrupted */
  580.                                                 /* this will stop infinite loop */
  581.         end
  582.  
  583.         call lineout(BootDrv||'\MMOS2\MMPM2.INI')    /* close mmpm2.ini for later search */
  584.                                                      /* VERY IMPORTANT!!                  */
  585.         call SysFileSearch '['||wave_device||']', BootDrv||'\MMOS2\MMPM2.INI', 'waveaudio.', 'N'
  586.         if ( waveaudio.0 = 0) then
  587.                 call MMPM2_CORRUPTED_ERROR
  588.         /* say 'waveaudio section found = ' waveaudio.1 */
  589.         parse value waveaudio.1 with startline ' '
  590.         do startline
  591.                 line = linein(BootDrv||'\MMOS2\MMPM2.INI')
  592.         end
  593.  
  594.         pdd_word = ''
  595.         count = 0
  596.         do while (compare(pdd_word, 'PDDNAME') & count < 50)
  597.                 line = linein(BootDrv||'\MMOS2\MMPM2.INI')
  598.                 parse upper value line with pdd_word '=' pdd_name_ini
  599.                 pdd_word = right(pdd_word, 7)   /* need just PDDNAME */
  600.                 count = count + 1               /* if mmpm2.ini is corrupted, stop at 50 lines */
  601.         end
  602.         if (compare(pdd_name_ini, vdd_name) <> 0) then
  603.           do
  604.                 call lineout(control_file)      /* close file before return */
  605.                 return 0
  606.           end
  607.         else
  608.           do
  609.                 call lineout(control_file)      /* close file before return */
  610.                 return 1
  611.           end
  612.  
  613. end /* IsDefault */
  614.  
  615.  
  616. /*******************************************************************/
  617. /*                                                                 */
  618. /*   Procedure : CheckControlFile                                  */
  619. /*                                                                 */
  620. /*               Check the existence of the WIN-OS2 driver passed  */
  621. /*               in by checking the corresponding directories      */
  622. /*               under \OS2\DRIVERS\. The directory name is the    */
  623. /*               name of the control file with extension .ctl.     */
  624. /*               For example, for ES1688DD, the control file is    */
  625. /*               es1688dd.ctl.                                     */
  626. /*                                                                 */
  627. /*   Input     : Directory name for the WIN-OS2 audio driver       */
  628. /*   Output    : just return if found; exit if not there           */
  629. /*                                                                 */
  630. /*******************************************************************/
  631.  
  632. CheckControlFile: PROCEDURE
  633. do
  634.  
  635.   arg WinDriverDir
  636.  
  637.   /* is the .ctl file there? */
  638.  
  639.   parse value WinDriverDir with '\OS2\DRIVERS\' WinDriver
  640.   call SysFileTree WinDriverDir||'\'||WinDriver||'.CTL', control_file, 'FS'
  641.   if  control_file.0 = 0  then
  642.     do
  643.         say
  644.         say 'Error: 'WinDriver'.CTL does not exist.'
  645.         say 'This file is essential for installing this WIN-OS2 driver.'
  646.         say
  647.         say 'Suggestion: Selective Install the corresponding OS/2 driver.'
  648.         say
  649.         exit
  650.     end
  651.   else /* .ctl file found */
  652.         return
  653. end /* of CheckControlFile */
  654.  
  655.  
  656. MMPM2_CORRUPTED_ERROR: PROCEDURE
  657. do
  658.         say
  659.         say 'ERROR: MMPM2.INI file may be corrupted;'
  660.         say '       Please re-install Multimedia.'
  661.         say
  662.         exit
  663. end
  664.  
  665.  
  666. /*******************************************************************/
  667. /*                                                                 */
  668. /*   Procedure : GetOS2ParamValue                                  */
  669. /*                                                                 */
  670. /*               Use parameter name, such as /A:, to search the    */
  671. /*               config.sys file to find out its setting, such as  */
  672. /*               240.  If no lettered parameter passed, it is      */
  673. /*               positional, meaning 1 for 1st parameter that      */
  674. /*               follow the DEVICE line.                           */
  675. /*                                                                 */
  676. /*   Input     : Packed information: control file location and     */
  677. /*               the name of the parameter.                        */
  678. /*                                                                 */
  679. /*   Output    : -1 if no valid value found; the value if valid.   */
  680. /*                                                                 */
  681. /*******************************************************************/
  682.  
  683. GetOS2ParamValue: PROCEDURE
  684. do
  685.         arg packed_info
  686.         parse value packed_info with control_file '==' param_name
  687.         /* say '::GetOS2ParamValue, control_file is = ' control_file */
  688.         BootDrv = left(control_file, 2)
  689.         config_sys = BootDrv||'\'||CONFIG.SYS
  690.         call SysFileSearch param_name, control_file, 'file.'
  691.         if (file.0 = 0) then
  692.           do
  693.                 say
  694.                 say 'Error in the control file.'
  695.                 say 'Please check the [PDD_INFO] section and [MODIFY] section'
  696.                 sya 'in 'control_file'.'
  697.                 call lineout(control_file)      /* close file before return */
  698.                 return -1                       /* junk value, will be checked upon return */
  699.           end
  700.         parse value file.1 with '"' param_letter '"' '"' junk '"'
  701.  
  702.         /* get PDD name from the .ctl file */
  703.         /* it is used to search in config.sys */
  704.  
  705.         call SysFileSearch '[PDD_INFO]', control_file, 'pdd_info.', 'N'
  706.         if (pdd_info.0 = 0) then
  707.                 call CONTROL_FILE_ERROR_OUTPUT
  708.         else
  709.                 parse value pdd_info.1 with startline ' '
  710.  
  711.         do startline
  712.                 line = linein(control_file)     /* brings to the first line  */
  713.         end                                   /* of [PDD_INFO] section     */
  714.         line = linein(control_file)
  715.         parse value line with '"' pdd_sys '"'
  716.  
  717.         call SysFileSearch pdd_sys, config_sys, 'sys_line.', 'N'
  718.         if (sys_line.0 = 0) then      /* no DEVICE line found for pdd_sys */
  719.           do
  720.                 call lineout(control_file)
  721.                 return -1
  722.           end
  723.  
  724.         /* add REM line checking here if desired */
  725.  
  726.  
  727.         /* is parameter without a letter-indicator? */
  728.         /* if yes, it is positional.                */
  729.  
  730.         if (verify(param_letter, '1234567890') = 0) then   /* no param letter */
  731.         do                                                 /* only ith param  */
  732.           parse value sys_line.1 with getrid1 ':' getrid2 ' ' left_over
  733.           do while (left(left_over, 1) = ' ')
  734.             parse value left_over with getrid ' ' left_over
  735.           end
  736.           do n=1 to param_letter-1
  737.             parse value left_over with getrid ' ' left_over
  738.             do while (left(left_over, 1) = ' ') /* get rid of leading blanks */
  739.               parse value left_over with ' ' left_over
  740.             end
  741.           end /* do n=1 to param_letter */
  742.           parse value left_over with param_value ' ' throw_away
  743.           call lineout(control_file)    /* close before return */
  744.           return param_value
  745.         end /* if (verify...) */
  746.  
  747.         /* otherwise, search for the letter parameter indicator */
  748.  
  749.         parse value sys_line.1 with junk1 ':' junk2 ' ' rest_line
  750.         do while (left(rest_line, 1) = ' ')     /* get rid of leading blanks */
  751.           parse value rest_line with ' ' rest_line
  752.         end
  753.         do while (left(rest_line, length(param_letter)) <> param_letter)
  754.           parse value rest_line with junk ' ' rest_line
  755.           do while (left(rest_line, 1) = ' ')     /* get rid of leading blanks */
  756.             parse value rest_line with ' ' rest_line
  757.           end
  758.         end /* do while (left(rest_line... */
  759.  
  760.         /* found the parameter that we want */
  761.         rest_line = right(rest_line, length(rest_line) - length(param_letter))
  762.         parse value rest_line with param_value ' ' throw_away
  763.         call lineout(control_file)
  764.         return param_value
  765. end
  766.  
  767.  
  768. DISPLAY_MOVING_BAR: PROCEDURE
  769. DO
  770.         arg row
  771.         base_line = '├─────────────────────────────────────────────────────────────┤'
  772.         cur       = '█'
  773.         i = 2
  774.         do 61
  775.           pos = SysCurPos(row, 2)
  776.           new_line = overlay(cur, base_line, i)
  777.           base_line = new_line
  778.           i = i +1
  779.           say new_line
  780.           say '  0%                           50%                           100%'
  781.           end /* do */
  782.         return
  783. END
  784.  
  785. /* last modified 10/11/96 */
  786.