home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / keybusbr.zip / KeybInst.CMD next >
OS/2 REXX Batch file  |  1999-07-22  |  11KB  |  143 lines

  1. /* Installs KeybUSBR.CMD and icons in target directory
  2.    and creates program object on desktop.
  3.  
  4.    Use it if you like it. Don't if you don't. No legalese.
  5.  
  6.    (c) 1999 Marcus de Geus
  7.             marcus@degeus.com
  8.             http://www.degeus.com
  9.  
  10.    **************************************************/
  11.  
  12. signal on Halt                                                                                                     /* handle halt condition */
  13.  
  14. if (\LoadREXXUtils()) then                                                                                         /* if we cannot load the REXX utilities */
  15. do
  16.  call Halt                                                                                                         /* quit */
  17. end
  18.  
  19. parse source . . ProgSpec                                                                                          /* get ProgSpec */
  20. SourceDir = filespec('D',ProgSpec)||filespec('P',ProgSpec)                                                         /* the source directory name */
  21.  
  22. Destination = GetLoc('Enter the new location for the KeybUSBR files:')                                             /* get the destination folder */
  23.  
  24. if (Destination = '') then                                                                                         /* if we have no destination */
  25. do
  26.  call beep 333,333                                                                                                 /* signal */
  27.  say 'Aborting installation'                                                                                       /* report */
  28.  call Halt                                                                                                         /* just quit */
  29. end
  30.  
  31. say 'Copying program files to '||Destination                                                                       /* report */
  32.  
  33. '@copy "'||SourceDir||'keybinst.cmd " "'||Destination||'" >NUL'                                                         /* copy this file to the destination folder */
  34. '@copy "'||SourceDir||'keybusbr.cmd " "'||Destination||'" >NUL'                                                         /* copy this file to the destination folder */
  35. '@copy "'||SourceDir||'keybisus.ico " "'||Destination||'" >NUL'                                                         /* copy this file to the destination folder */
  36. '@copy "'||SourceDir||'keybisbr.ico " "'||Destination||'" >NUL'                                                         /* copy this file to the destination folder */
  37. '@copy "'||SourceDir||'readme.txt " "'||Destination||'" >NUL'                                                           /* copy this file to the destination folder */
  38.  
  39. say 'Creating program object on desktop'                                                                           /* report */
  40.  
  41. Settings = 'EXENAME='||Destination||'\KEYBUSBR.CMD;MINIMIZED=YES;PROGTYPE=WINDOWABLEVIO;OBJECTID=<KEYB_US_BR274>'  /*settings for the program object */
  42. if (\syscreateobject('WPProgram','Keyboard US/BR274','<WP_DESKTOP>',Settings)) then                                /* create the program object on the desktop */
  43. do
  44.  call beep 333,333                                                                                                 /* signal */
  45.  say 'ERROR: The KeybUSBR program object could not be created on the desktop'                                      /* report */
  46.  call Halt                                                                                                         /* and quit */
  47. end
  48.  
  49. say 'Setting program object icon to match keyboard state'                                                          /* report */
  50. '@cmd.exe /c '||Destination||'\keybusbr.cmd >NUL'                                                                  /* run the program once to set the icon to match the keyboard state */
  51.  
  52. say ''                                                                                                             /* empty line */
  53. say 'Use the Keyboard US/BR 274 program to change between US and BR 274 keyboards.'                                /* report */
  54. say 'The program object icon will be set to match the keyboard state.'                                             /* report */
  55.  
  56. call Halt                                                                                                          /* and quit */
  57.  
  58.  
  59. /*****************************************************************/
  60.  
  61. GetLoc: procedure                                                                                                  /* gets RexxMail destination folder */
  62.  
  63. parse arg Message                                                                                                  /* get the message */
  64.  
  65. say Message                                                                                                        /* report */
  66.  
  67. parse pull Location                                                                                                /* get the location*/
  68.  
  69. Location = strip(Location,'B',' ')                                                                                 /* get rid of any leading and trailing blanks */
  70. Location = strip(Location,'T','\')                                                                                 /* get rid of any trailing backslash */
  71. if (Location = '') then                                                                                            /* if we have nothing */
  72. do
  73.  say 'No location entered'                                                                                         /* report */
  74.  return ''                                                                                                         /* return empty */
  75. end
  76.  
  77. DriveLetter = filespec('D',Location)                                                                               /* get any drive letter from the new location */
  78. if (DriveLetter = '') then                                                                                         /* if there is no drive letter */
  79. do
  80.  say 'The location must include a drive letter'                                                                    /* report */
  81.  return ''                                                                                                         /* return empty */
  82. end
  83.  
  84. call sysfiletree Location,'Loc.','DO'                                                                              /* look for the new location */
  85. if (Loc.0 = 0) then                                                                                                /* if it is not found */
  86. do
  87.  say '"'||Location||'" does not exist; should the directory be created?'                                           /* report */
  88.  say 'Type Y to confirm, any other key to abort; finish with [Enter]'                                              /* report */
  89.  parse upper pull Confirm                                                                                          /* get a reply in upper case */
  90.  Confirm = strip(Confirm,'B',' ')                                                                                  /* get rid of blanks */
  91.  if (substr(Confirm,1,1) >< 'Y') then                                                                              /* if it is not a yes */
  92.  do
  93.   return ''                                                                                                        /* return empty */
  94.  end
  95.  
  96.  say 'Creating directory: '||Location                                                                              /* report */
  97.  if (sysmkdir(Location) >< 0) then                                                                                 /* if we cannot create the new location folder */
  98.  do
  99.   say 'Cannot create '||Location                                                                                   /* report */
  100.   return ''                                                                                                        /* return empty */
  101.  end
  102.  
  103. end
  104.  
  105. return Location                                                                                                    /* return with the new location */
  106.  
  107.  
  108. /***************************************************************/
  109.  
  110. LoadREXXUtils: procedure                                                                                           /* loads the REXX utilities library */
  111.  
  112. Result = 1                                                                                                         /* start with a good result */
  113.  
  114. if rxfuncquery('SysLoadFuncs') then                                                                                /* if it is not already loaded */
  115. do
  116.  if (rxfuncadd('SysLoadFuncs','RexxUtil','SysLoadFuncs') >< 0) then                                                /* if we cannot add it */
  117.  do
  118.   call beep 333,333                                                                                                /* signal */
  119.   say 'Error : Cannot register Rexx Utilities library'                                                             /* report */
  120.   Result = 0                                                                                                       /* bad result */
  121.  end
  122.  else                                                                                                              /* if we can add it */
  123.  do
  124.   if (SysLoadFuncs() = 0) then                                                                                     /* if we cannot load it */
  125.   do
  126.    say 'Error : Cannot load Rexx Utilities library'                                                                /* report */
  127.    Result = 0                                                                                                      /* bad result */
  128.   end
  129.  end
  130. end
  131.  
  132. return Result                                                                                                      /* end of LoadREXXUtils */
  133.  
  134. /*****************************************************************/
  135.  
  136. Halt:                                                                                                              /* handles halt condition */
  137.  
  138. say ''                                                                                                             /* empty line */
  139. say 'End of '||ProgSpec||'; Press [Enter]'                                                                         /* report */
  140. parse pull .                                                                                                       /* get a reply */
  141.  
  142. exit                                                                                                               /* that's all, folks! */
  143.