home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / bz0395.zip / BELOWZRO.CMD next >
OS/2 REXX Batch file  |  1993-12-21  |  4KB  |  170 lines

  1. /*
  2.    Created by Snow Storm Software
  3.     (c) Copyright SLY Industries Inc., 1992.  All Rights Reserved.
  4.  
  5.    Command:  INSTALL
  6. */
  7.  
  8. /* Register REXX API extensions. */
  9. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  10. Call SysLoadFuncs
  11. Call SysCls
  12.  
  13. Say
  14. Say '<<<  Snow Storm Software Installation Utility  >>>'
  15. Say
  16.  
  17. /* Initialize Variables */
  18. Source = "A:\"
  19. Target = "C:\BZ"
  20. finished = "Y"
  21.  
  22. do until finished = 'Y'
  23.    /* Get target directory. */
  24.    Say
  25.    Call Prompt 'Please enter the target drive and directory (default 'Target'):'
  26.    Pull NewTarget
  27.  
  28.    /* Default Check */
  29.    If NewTarget <> " " then
  30.       Target = NewTarget
  31.  
  32.    /* Get source directory. */
  33.    Say
  34.    Call Prompt 'Please enter the source drive and directory (default 'Source'):'
  35.    Pull NewSource
  36.  
  37.    /* Default Check */
  38.    If NewSource <> " " then
  39.       Source = NewSource
  40.  
  41.    /* Request confirmation of selections */
  42.    Call SysCls
  43.    Say
  44.    Say '<<<  Snow Storm Software Installation  >>>'
  45.    Say
  46.    Say '         Installation information'
  47.    Say
  48.    Say '         Target : 'Target
  49.    Say '         Source : 'Source
  50.  
  51.    finished = Question( 'Is the above information correct?' )
  52. end
  53. Call Question 'About to install using information given.  Continue?', 'Abort'
  54.  
  55.  
  56. rc = 0
  57.  
  58. do until rc = 0
  59.    /* Create target directory if it does not exist */
  60.    Call SysFileTree Target, FileStem, 'D'
  61.  
  62.    If FileStem.0 = '0' Then Do
  63.       /* Directory was not found */
  64.       Say 'Creating target directory : ' Target
  65.       rc = SysMkDir( Target )
  66.       if rc <> 0 Then
  67.       Do
  68.          Say Target' could not be created, please try again.'
  69.          Say
  70.          Call Prompt 'Please enter the target drive and directory (default 'Target'):'
  71.          Pull NewTarget
  72.  
  73.          /* Default Check */
  74.          If NewTarget <> " " then
  75.             Target = NewTarget
  76.  
  77.       End
  78.    End
  79. end
  80.  
  81. rc = 0
  82. do until rc = 0
  83.    /* Locate source directory */
  84.    Call SysFileTree Target, FileStem, 'D'
  85.  
  86.    If FileStem.0 = '0' Then Do
  87.       /* Directory was not found */
  88.       rc = 1
  89.       Say Source' could not be found, please try again.'
  90.       Say
  91.       Call Prompt 'Please enter the source drive and directory (default 'Source'):'
  92.       Pull NewSource
  93.  
  94.       /* Default Check */
  95.       If NewSource <> " " then
  96.          Source = NewSource
  97.  
  98.    End
  99. end
  100.  
  101. /* Copy files. */
  102. Say
  103. Say 'Unpacking files from 'Source' to 'Target'.'
  104. Command = '@unpack 'Source' 'Target
  105. Command
  106. if rc \= 0 Then Do
  107.     Call Question 'Error occured during file transfer.  Abort ', 'Abort'
  108. End
  109.  
  110. /* Prompt to create Workplace Shell Program Objects. */
  111. Say
  112. Say 'Creating Workplace Shell Object.'
  113. r = SysCreateObject( "WPProgram",,
  114.                      "Below Zero",,
  115.                      "<WP_DESKTOP>",,
  116.                      "EXENAME=VIEW.EXE;PARAMETERS=BelowZro introduction;STARTUPDIR="||Target, 'U' )
  117.  
  118. /* Success */
  119. Say
  120. Say '<<<  Snow Storm Software Installation Successfull  >>>'
  121. Say
  122. Call Prompt 'Press Enter to exit installation....'
  123. Pull ExitInstallation
  124.  
  125. Exit
  126.  
  127. /* Prompt for user input */
  128. Prompt: Parse Arg szPromptText
  129.  
  130.     /* Current cursor position. */
  131.     Parse Value SysCurPos() With Row .
  132.  
  133.     /* Screen size. */
  134.     Parse Value SysTextScreenSize() With NumRows .
  135.  
  136.     /* End of screen check. */
  137.     if Row = NumRows - 1 Then Row = Row - 1
  138.  
  139.     /* Prompt length. */
  140.     Col = Length( szPromptText ) + 1
  141.  
  142.     /* Show prompt and position cursor at end. */
  143.     Say szPromptText
  144.     Call SysCurPos Row, Col
  145.  
  146.     Return
  147.  
  148. /* Ask simple yes or no question, aborting if critical */
  149. Question: Parse Arg szText, AbortFlag
  150.  
  151.     /* Use prompt to get user response. */
  152.     Say szText' (Y or N)?'
  153.  
  154.     /* Wait for user input */
  155.     Do Forever
  156.         KeyPress = SysGetKey( 'NOECHO' )
  157.         If KeyPress = 'Y' | KeyPress = 'y' Then Do
  158.             Say
  159.             Return 'Y'
  160.         End
  161.         Else If KeyPress = 'N' | KeyPress = 'n' Then Do
  162.             Say
  163.             If AbortFlag = 'Abort' Then Exit
  164.             Return 'N'
  165.         End
  166.     End
  167.     Return 'Error'
  168.  
  169.  
  170.