home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv7.zip / VACPP / IBMCPP / smarts / SCRIPTS / HELPSCR.CMD < prev    next >
OS/2 REXX Batch file  |  1995-06-02  |  8KB  |  213 lines

  1. /*REXX*/
  2.  
  3. /*   HELPSCR.CMD   Project Smarts install script for Help project
  4.  *
  5.  *   Licensed Materials - Property of IBM
  6.  *
  7.  *   "Restricted Materials of IBM"
  8.  *
  9.  *   IBM WorkFrame
  10.  *
  11.  *   (C) Copyright IBM Corp. 1995. All Rights Reserved.
  12.  *
  13.  *   US Government Users Restricted Rights - Use, duplication or
  14.  *   disclosure restricted by GSA ADP Schedule Contract with
  15.  *   IBM Corp.
  16.  *
  17.  */
  18.  
  19.  
  20. /* Initialize - use a global stem variable. */
  21. stem = "stem"
  22. RC_OK     = 0
  23. RC_CANCEL = 95
  24.  
  25.  
  26. /* Open the installation console. */
  27. rc = IwfOpenConsole(stem);
  28.  
  29.  
  30. /* Load the REXX utility functions. */
  31. rc = RxFuncAdd('SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs');
  32. rc = SysLoadFuncs();
  33.  
  34.  
  35. /* Extract the passed parameters. */
  36. if (Arg() <> 3) Then
  37.    call Abort("Error in parameter list.");
  38. Parse Arg Proj,Src,Cat;
  39.  
  40. SAY Cat
  41.  
  42. /* Initialize the progress, status, and log. */
  43. stem.usPercent     = 0
  44. stem.pszStatusText = "Initializing..."
  45. rc = IwfUpdateConsoleProgress(stem);
  46. rc = IwfUpdateConsoleStatus(stem);
  47. SAY "Initializing the Project Smarts install..."
  48. SAY " "
  49.  
  50. /* Present disclaimers. */
  51. stem.usPercent     = 10
  52. stem.pszStatusText = "Presenting disclaimers..."
  53. rc = IwfUpdateConsoleProgress(stem);
  54. rc = IwfUpdateConsoleStatus(stem);
  55. line1 = 'DISCLAIMER OF WARRANTIES.  The code that will be installed is '
  56. line2 = 'template code created by IBM Corporation. This code is not '
  57. line3 = 'part of any standard or IBM product and is provided to you solely '
  58. line4 = 'for  the purpose of assisting you in the development of your '
  59. line5 = 'applications.  The code is provided "AS IS", without '
  60. line6 = 'warranty of any kind.  IBM shall not be liable for any damages '
  61. line7 = 'arising out of your use of the sample code, even if they have been '
  62. line8 = 'advised of the possibility of such damages.'
  63. SAY line1||line2||line3||line4||line5||line6||line7||line8
  64. SAY " "
  65.  
  66.  
  67. /* Query the target location for the install. */
  68. stem.usPercent     = 30
  69. stem.pszStatusText = "Querying the install location..."
  70. rc = IwfUpdateConsoleProgress(stem);
  71. rc = IwfUpdateConsoleStatus(stem);
  72. SAY "Enter the project name, target directory, and folder for the installation."
  73. /* Set defaults for Location dialog */
  74. env='OS2ENVIRONMENT';                  /* Default target directory */
  75. tmploc = VALUE('tmp',,env)             /* is on TMP variable dir   */  
  76. tmploc = STRIP(tmploc,Trailing,'\');   /* Strip any backslashes at end of path */
  77. Locn = tmploc||'\hlpprj';
  78. stem.pszTargetProject   = Proj
  79. stem.pszTargetDirectory = Locn
  80. stem.pszTargetFolder    = "Desktop"
  81. do until (rc = RC_OK)
  82.    rc = IwfQueryLocation(stem);
  83.    if (rc  = RC_CANCEL) then call Cancel
  84.    else
  85.    if (rc <> RC_OK) then call Abort("Error querying target information.");
  86. end
  87.  
  88.  
  89. /* Set up default variable settings for the installation. */
  90. stem.usPercent     = 40
  91. stem.pszStatusText = "Confirming variable settings..."
  92. stem.usVariableCount = 5
  93. stem.pszVariableName.1        = "Your_Name"
  94. stem.pszVariableDescription.1 = "Your name for the source file prolog."
  95. stem.pszVariableValue.1       = "Your name"
  96. stem.pszVariableName.2        = "Date"
  97. stem.pszVariableDescription.2 = "The date for the source file prolog."
  98. stem.pszVariableValue.2       = Date()
  99. stem.pszVariableName.3        = "Title"
  100. stem.pszVariableDescription.3 = "The title of the Help information you want to create. This title will appear in the title bar of the Help window."
  101. stem.pszVariableValue.3       = "Help for an Application"
  102. stem.pszVariableName.4        = "File_name"
  103. stem.pszVariableDescription.4 = "The file name for the generated files, for example, HELP."
  104. stem.pszVariableValue.4       = "help"
  105. stem.pszVariableName.5        = "Prolog"
  106. stem.pszVariableDescription.5 = "The prolog that appears at the head of all the generated source files."
  107. stem.pszVariableValue.5       = ".* %TITLE%.  This file was created for %YOUR_NAME% \n.* by Project Smarts on %DATE%. ";
  108. rc = IwfUpdateConsoleProgress(stem);
  109. rc = IwfUpdateConsoleStatus(stem);
  110. SAY "Confirm the settings of variables used to customize the installation."
  111. /* Restore any saved variable settings */
  112. stem.pszCatalog = Cat;
  113. stem.pszApplication = 'VAPSHelp';
  114. rc = IwfRestoreVariables(stem);
  115. if (rc <> RC_OK) then SAY ("Could not restore variable settings. Will use defaults.");
  116. /* Restore date to current date */
  117. stem.pszVariableValue.2 = Date()
  118. /* Display variable settings window */
  119. do until (rc = RC_OK)
  120.    rc = IwfQueryVariables(stem);
  121.    if (rc  = RC_CANCEL) then call Cancel
  122.    else
  123.    if (rc <> RC_OK) then call Abort("Error querying variable settings.");
  124. end
  125. /* Save variable settings */
  126. rc = IwfSaveVariables(stem);
  127. if (rc <> RC_OK) then SAY ("Error saving variable settings.");
  128.  
  129.  
  130. /**** Process variable settings ****/
  131. /* Take only an 8-character file name */
  132. /* stem.pszVariableValue.4 = SUBSTR(stem.pszVariableValue.4,1,8);   */
  133. /* stem.pszVariableValue.4 = STRIP(stem.pszVariableValue.4);        */
  134. SAY "New file name is: "stem.pszVariableValue.4;
  135. /* Strip any backslashes from the end of the specified target path */
  136. stem.pszTargetDirectory = STRIP(stem.pszTargetDirectory,Trailing,'\');
  137.  
  138.  
  139. /* Copy the files over, substituting the variable settings. */
  140. stem.usPercent     = 50
  141. stem.pszStatusText = "Copying files, with substitution."
  142. rc = IwfUpdateConsoleProgress(stem);
  143. rc = IwfUpdateConsoleStatus(stem);
  144. SAY "The project source files in" Src "are being copied to" stem.pszTargetDirectory"."
  145. stem.pszSourceFileMask = Src;
  146. rc = IwfCopyWithSubstitution(stem);
  147. if (rc <> RC_OK) then call Abort("Error performing copy with substitution.");
  148.  
  149. /* Renaming files */
  150. stem.usPercent     = 60
  151. stem.pszStatusText = "Renaming files."
  152. rc = IwfUpdateConsoleProgress(stem);
  153. rc = IwfUpdateConsoleStatus(stem);
  154. curdir = DIRECTORY();
  155. newdir = DIRECTORY(stem.pszTargetDirectory);
  156. rename 'help.* 'stem.pszVariableValue.4'.*'
  157. if (rc <> RC_OK) then call Abort("Error renaming files. The specified file name may be invalid or the disk is full. Please delete any created files and start over.");
  158. call DIRECTORY curdir;
  159.  
  160.  
  161. /* Create the WorkFrame project */
  162. stem.usPercent     = 90;
  163. stem.pszStatusText = "Creating the Workframe/2 project.";
  164. rc = IwfUpdateConsoleProgress(stem);
  165. rc = IwfUpdateConsoleStatus(stem);
  166. SAY "The project will be created in "||stem.pszTargetFolder;
  167. pszTarDir = stem.pszTargetDirectory;
  168. /* Get the path of the shell projects */
  169. ShellPath = VALUE('CPPMAIN',,env);   /* on CPPMAIN variable path */
  170. if ShellPath='' then call Abort("Error obtaining Project Smarts path.");
  171. ShellPath = ShellPath'\smarts\projects';
  172. stem.pszSourceProject = ShellPath'\Help'
  173. stem.pszTargetProjectSetup = 'TARGETNAME='stem.pszVariableValue.4'.hlp;MAKEFILENAME=help.mak;PAMLOCATION:IWFBPAM='pszTarDir';PAMDEFAULT:IWFBPAM='pszTarDir';INHERITLIST=<CPPDFTPRJ>;TITLE='stem.pszTargetProject';'
  174. SAY stem.pszTargetProjectSetup;
  175. rc = IwfCreateProjectFromProject(stem)
  176. if (rc <> RC_OK) then call Abort("Error creating project.");
  177.  
  178.  
  179. /* Done! */
  180. stem.usPercent     = 100
  181. stem.pszStatusText = "Installation successful."
  182. rc = IwfUpdateConsoleProgress(stem);
  183. rc = IwfUpdateConsoleStatus(stem);
  184. SAY "Done!"
  185. SAY "The installation is complete and was successful."
  186. rc = RxMessageBox("The WorkFrame project has been created.", "Done!", "OK", "Information");
  187.  
  188.  
  189. /* We are done. */
  190. call Done(0);
  191.  
  192.  
  193. Cancel:
  194. rcCancel = RxMessageBox("Do you really want to cancel?", , "YesNo", "Query")
  195. if (rcCancel = 6) Then
  196.    call Done(8)
  197. return
  198.  
  199. Abort:
  200. parse arg abortMessage
  201. rcAbort = RxMessageBox(abortMessage, , "OK", "Error")
  202. call Done(16)
  203.  
  204. Done:
  205. arg exitRc
  206. /* Close the installation console. */
  207. rcDone = IwfCloseConsole(stem);
  208. exit(exitRc)
  209.  
  210.  
  211.  
  212.  
  213.