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

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