home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / addprog.cmd < prev    next >
OS/2 REXX Batch file  |  1994-05-19  |  3KB  |  117 lines

  1. /* AddProg.CMD */
  2.  
  3. /*
  4. ** Creates a program object on the desktop
  5. ** for a user selectable program and icon
  6. **
  7. */
  8.  
  9. /* First, load the VREXX functions */
  10. '@echo off'
  11. call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  12. initcode = VInit()
  13. if initcode = 'ERROR' then signal CLEANUP
  14. signal on failure name CLEAN_F
  15. signal on halt name CLEAN_H
  16. signal on syntax name CLEAN_S
  17.  
  18.  
  19. /* Next, load in the utility REXX functions */
  20. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  21. call SysLoadFuncs
  22.  
  23.  
  24. /* Show a title screen and get ok or cancel */
  25. msg.0 = 4
  26. msg.1 = '    Program Object Creator'
  27. msg.2 = ''
  28. msg.3 = '         by Mark Ziller'
  29. msg.4 = ''
  30. call VDialogPos 50, 50
  31. rb = VMsgBox('Program Object Creator', msg, 3)
  32. if rb = 'CANCEL' then signal CLEANUP
  33.  
  34.  
  35. /* Get the program title from the user */
  36. prompt.0 = 1
  37. prompt.1 = 'Enter the program title:'
  38. prompt.vstring = ''
  39. button = VInputBox('Title', prompt, 30, 3)
  40. if button = 'CANCEL' then signal STOPPED
  41. Obj.Title = prompt.vstring
  42. if Obj.Title = '' then Obj.Title = 'Program'
  43.  
  44.  
  45. /* get the filename and icon from the user */
  46. button = VFileBox('Select the executable program:', 'c:\*.exe', 'file')
  47. if button = 'CANCEL' then signal STOPPED
  48. Obj.ProgName = file.vstring
  49.  
  50. button = VFileBox('Select the icon:', 'c:\icons\*.ico', 'file')
  51. if button = 'CANCEL' then signal STOPPED
  52. Obj.IconName = file.vstring
  53.  
  54. Obj.WorkDir = FILESPEC("drive", Obj.ProgName) || FILESPEC("path", Obj.ProgName)
  55.  
  56.  
  57. /* confirm the choices to make sure */
  58. msg.0 = 6
  59. msg.1 = 'Are these choices correct?'
  60. msg.2 = ' '
  61. msg.3 = 'Title         = ' || Obj.Title
  62. msg.4 = 'Program     = ' || Obj.ProgName
  63. msg.5 = 'Working Dir = ' || Obj.WorkDir
  64. msg.6 = 'Icon         = ' || Obj.IconName 
  65. call VDialogPos 50, 50
  66. rb = VMsgBox('Confirm', msg, 6)
  67. if rb = 'YES' then signal DO_IT
  68. else signal STOPPED 
  69.  
  70.  
  71. /* User selected cancel -- exit without doing anything */
  72. STOPPED:
  73. msg.0 = 1
  74. msg.1 = '   Program stopped at user request.'
  75. call VMsgBox 'Exiting', msg, 1
  76. signal CLEANUP
  77.  
  78.  
  79. /* All data entered correctly -- create program object and icon */
  80. DO_IT:
  81. /* now set object options for working directory, icon, etc */
  82. Obj.Options = 'EXENAME=' || Obj.ProgName || ';'
  83. Obj.Options = Obj.Options || 'STARTUPDIR=' || Obj.WorkDir || ';'
  84. Obj.Options = Obj.Options || 'ICONFILE=' || Obj.IconName || ';'
  85.  
  86. msg.0 = 1
  87. result = SysCreateObject("WPProgram",Obj.Title,"<WP_DESKTOP>",Obj.Options) then
  88. if result = 0 then do
  89.     msg.0 = 1
  90.     msg.1 = 'Unable to create Program Object'
  91.     call VMsgBox 'Program Object Creator', msg, 1
  92.     end
  93.   
  94.  
  95.  
  96. /* Cleanup and exit */
  97. CLEANUP:
  98.    call VExit
  99. exit
  100.  
  101. CLEAN_S:
  102.    call VExit
  103.    say "Syntax error -- Abnormal Program Termination"
  104. exit
  105.  
  106. CLEAN_F:
  107.    call VExit
  108.    say "Failure error -- Abnormal Program Termination"
  109. exit
  110.  
  111. CLEAN_H:
  112.    call VExit
  113.    say "Halt error -- Abnormal Program Termination"
  114. exit
  115.  
  116.  
  117.