home *** CD-ROM | disk | FTP | other *** search
/ IBM Aptiva Multimedia Exploration / BPCDROM.ISO / recovery / recovery.cmd < prev    next >
Encoding:
Text File  |  1995-09-22  |  73.1 KB  |  2,356 lines

  1. /*:VRX         MAIN
  2. */
  3. /*
  4. *
  5. * Recovery: This program is intended to provide the Aptiva User with a simple
  6. *           interface into the Aptiva OS/2 Warp Recovery Options.
  7. *           This program will present the user with a simple menu. From this
  8. *           menu the user will be able to;
  9. *
  10. *           1) Install Aptiva OS/2 Warp Software
  11. *           2) Recover Configuration Files
  12. *           3) Edit Autoexec.bat
  13. *           4) Edit Config.sys
  14. *           5) Edit Startup.cmd
  15. *           6) Go to OS/2 Warp Command Prompt
  16. *
  17. *
  18. *           The program will prompt the user for the drive letter of their
  19. *           CD and will expect to find the needed recovery utilities in
  20. *           the \Recovery subdirectory on the Aptiva OS/2 CD-Rom.
  21. *
  22. */
  23.  
  24.  
  25. /*
  26. * Description: Entry point into recovery menu.
  27. *
  28. * NOTE: This program is NOT Generic and will need modifications for different
  29. *       Preload images. The main areas for modification will be the Menus
  30. *       and the Translated text.
  31. */
  32. Main:
  33.  
  34.     /* Do not allow this menu to be interrupted.
  35.     */
  36.     CALL ON HALT
  37.  
  38.     /* Initialize all Global Variables
  39.     */
  40.     Call Initialize
  41.  
  42.     /* Allow Testing
  43.     */
  44.     Parse arg Testing
  45.  
  46.     if strip(Testing) <> "" then do
  47.         GV._TESTING = 1
  48.     end
  49.  
  50.     /* MENU LOOP - We spend ALL out time in this loop.
  51.     */
  52.     Call MainMenu
  53.     Call Value "PROMPT","$_"||GV._Prompt2||"$_[$P]","OS2ENVIRONMENT"
  54.     Call CLS
  55. exit
  56.  
  57. /*:VRX         __VXREXX____APPENDS__
  58. */
  59. __VXREXX____APPENDS__:
  60. /*
  61. */
  62. return
  63. /*:VRX         AskForBoot
  64. */
  65. /* Description: Prompt the user for the Boot Drive Letter.
  66. *
  67. *
  68. *
  69. */
  70. AskForBoot: procedure expose GV.
  71.  
  72.     Boot = GV._OriginalBootDrive
  73.     /* Warn User that this Option is only valid on the Original Boot Drive
  74.     */
  75.     Msg = TranslateString(GV._BootPromptMsg,,
  76.                           GV._Separator||Boot||,
  77.                           GV._Separator||Boot||,
  78.                           GV._Separator||Boot)
  79.     Call Make_CurrentMessage Msg
  80.  
  81.     Call CLS
  82.  
  83.     Response = PromptMessage("GV._CurrentMessage.",,
  84.                              GV._BootPromptTitle,,
  85.                              GV._BootPrompt,,
  86.                              5,5)
  87.  
  88.     /* If user says ok to continue then return the Boot Drive , else ""
  89.     */
  90.     /* MODIFIED - DEFECT 137983 - Make this logic a little more NLV
  91.     *  enabled by keying it off of the text in the prompt. In reality
  92.     *  the Translation file should explicitly specify the Correct response.
  93.     */
  94.     /* Pick up the response from the translation.
  95.     *  Assumes the response is of the form "(Yes/No)"
  96.     */
  97.     Parse var GV._BootPrompt "(" AffirmativeResponse "/" .
  98.  
  99.     /* Clean it up
  100.     */
  101.     AffirmativeResponse = translate(strip(AffirmativeResponse))
  102.  
  103.     /* If we actually found a response string, use it
  104.     */
  105.     if Length(AffirmativeResponse) > 0 then do
  106.         If abbrev(AffirmativeResponse,translate(Response),1) \== 1 then do
  107.             Boot = ""
  108.         end
  109.     end
  110.     /* If no string found, default to English
  111.     */
  112.     else do
  113.         If abbrev("YES",translate(Response),1) \== 1 then do
  114.             Boot = ""
  115.         end
  116.     end
  117.  
  118. return Boot
  119. /*:VRX         AskForCD
  120. */
  121. /* Description: Prompt the user for the CD Drive that has the Aptiva
  122. *               software on it. The user MUST provide a valid drive
  123. *               letter. This routine will access the Drive and Validate.
  124. *
  125. */
  126. AskForCD: procedure expose GV.
  127.     /* Clear the Screen
  128.     */
  129.     Call CLS
  130.  
  131.     /* Create the CD Prompt
  132.     */
  133.     Call Make_CurrentMessage translatestring(GV._CDPromptMsg,,
  134.                                              GV._Separator||GV._LeaveCDPrompt)
  135.  
  136.  
  137.     /* We MUST get a CD-ROM Drive letter to continue
  138.     */
  139.     Do until (CD <> "")
  140.         CD = PromptMessage("GV._CurrentMessage.",,
  141.                            GV._CDPromptTitle,,
  142.                            GV._CDPrompt,,
  143.                             5,5)
  144.  
  145.         if (Translate(CD) \== GV._LeaveCDPrompt) then do
  146.  
  147.             CD = strip(left(CD,1))
  148.  
  149.             /* Is it valid ?
  150.             */
  151.             if pos(CD,GV._Drives) = 0 then do
  152.                 /* Put up error message
  153.                 */
  154.                 Call ErrorBeep
  155.                 Call GoToRowCol 15,5
  156.                 Call ClearToEOL
  157.                 Call Charout ,GV._BadCDMsg CD
  158.  
  159.                 /* Clear choice
  160.                 */
  161.                 CD = ""
  162.             end
  163.  
  164.             /* Now test to see that the proper CD is in the Drive
  165.             *  Only test is a valid drive was provided.
  166.             */
  167.             If CD <> "" then do
  168.                 If ProperCD(CD) = "" then do
  169.                     /* Put up error message
  170.                     */
  171.                     Call ErrorBeep
  172.                     Call GoToRowCol 15,5
  173.                     Call ClearToEOL
  174.                     msg = translatestring(GV._WrongCDMsg,,
  175.                                              GV._Separator||CD)
  176.                     Call Charout ,msg
  177.  
  178.                     /* Clear choice
  179.                     */
  180.                     CD = ""
  181.                 end
  182.                 else do
  183.                     /* Set DPATH to point to the \RECOVERY directory
  184.                     */
  185.                     Call Value "DPATH",,
  186.                                "\;"||CD||":"||GV._RecoveryDir||";",,
  187.                                "OS2ENVIRONMENT"
  188.                 end
  189.             end
  190.         end
  191.         else do
  192.             CD=""
  193.             leave
  194.         end
  195.     end
  196.  
  197.     /* Clear the screen
  198.     */
  199.     Call CLS
  200. return CD
  201.  
  202. /*:VRX         CommandProcessor
  203. */
  204. /* Description: Invoke a Command Prompt, with special prompt.
  205. *
  206. */
  207. CommandProcessor: procedure expose GV.
  208.  
  209.     /* Tell the user how to get back
  210.     */
  211.     Call WriteAt 20, 1, GV._RememberExitMsg
  212.     Call GotoRowCol 21,1
  213.     Call Pause
  214.  
  215.     /* Clear the screen
  216.     */
  217.     Call WriteAt 1,1,GV._ANSI._BoldOff
  218.     Call CLS
  219.  
  220.     /* Set up a local prompt
  221.     */
  222.     Call SetLocal
  223.     "@Prompt $_"||GV._Prompt||"$_[$P]"
  224.  
  225.     /* Start the session
  226.     */
  227.     "@CMD"
  228.  
  229.     /* Make sure we have the correct diskette back in the drive
  230.     */
  231.     parse source . . me .
  232.     parse var me . ":" me
  233.     fspec = ""
  234.     do while fspec == ""
  235.         fspec = Stream(me,"C","Query Exists")
  236.         if fspec == "" then do
  237.             Call RequestCmdDisk
  238.         end
  239.         else do
  240.             line = linein(fspec)
  241.             Call Stream fspec,"C","CLOSE"
  242.             if line <> GV._MEFLAG then do
  243.                 Call RequestCmdDisk
  244.                 fspec = ""
  245.             end
  246.         end
  247.     end
  248.  
  249.     /* Resume normal prompt
  250.     */
  251.     Call EndLocal
  252. return
  253.  
  254. /*:VRX         EditAFile
  255. */
  256. /* Description: Edit A File
  257. *
  258. */
  259. EditAFile: procedure expose GV.
  260.     Parse arg File
  261.  
  262.     /* Build the Editor Path, with possible Prompting
  263.     */
  264.     GV._EditorFullSpec = MakeEditorSpec()
  265.  
  266.     /* Make Sure we can locate the editor
  267.     */
  268.     SIGNAL ON NOTREADY Name NotReadyEdit
  269.     DriveReady = 0
  270.     Call Stream GV._EditorFullSpec, "D"
  271.     DriveReady = 1
  272.  
  273.     FullSpec = Stream(GV._EditorFullSpec,"C","Query Exists")
  274.     if FullSpec <> "" then do
  275.  
  276.         /* Get CD and Bootdrive
  277.         */
  278.         command = SubstituteParms(FullSpec File)
  279.         if GV._BootDrive <> "" then do
  280.             /* Pass the command to cmd.exe
  281.             */
  282.             command
  283.         end
  284.     end
  285.     else do
  286.  
  287.         /* Break up the Message into separate lines (crlf delimted)
  288.         *  Returns with GV._CurrentMessage.0 = # or lines
  289.         *               GV._CurrentMessage.n = line n
  290.         */
  291.         Call Make_CurrentMessage translatestring(GV._EditorNotFoundMsg,,
  292.                                              GV._Separator||GV._EditorFullSpec)
  293.  
  294.         Call WarningMessage "GV._CurrentMessage.", 5,5
  295.  
  296.     end
  297.  
  298. NotReadyEdit:
  299.     if DriveReady = 0 then do
  300.  
  301.         /* Break up the Message into separate lines (crlf delimted)
  302.         *  Returns with GV._CurrentMessage.0 = # or lines
  303.         *               GV._CurrentMessage.n = line n
  304.         */
  305.         Call Make_CurrentMessage translatestring(GV._EditorDriveNotReadyMsg,,
  306.                                          GV._Separator||GV._EditorFullSpec)
  307.        Call WarningMessage "GV._CurrentMessage.",5,5
  308.  
  309.     end
  310. return
  311.  
  312. /*:VRX         EditAutoexec
  313. */
  314. /* Description: Edit Autoexec.bat
  315. *
  316. */
  317. EditAutoexec: procedure expose GV.
  318.     Call EditAFile "%T:\Autoexec.bat"
  319. return
  320.  
  321. /*:VRX         EditConfig
  322. */
  323. /* Description: Edit Config.sys
  324. *
  325. */
  326. EditConfig: procedure expose GV.
  327.     Call EditAFile "%T:\Config.sys"
  328. return
  329.  
  330. /*:VRX         EditStartup
  331. */
  332. /* Description: Edit Startup.cmd
  333. *
  334. */
  335. EditStartup: procedure expose GV.
  336.     Call EditAFile "%T:\startup.cmd"
  337. return
  338.  
  339. /*:VRX         ExecuteACommand
  340. */
  341. /* Description: This is where all the work happens. Each command = line in the
  342. *               recovery script is passed to this routine and if it is a
  343. *               known command, the command line is massaged if needed and
  344. *               executed. If it is an unknown command it is assumed to be a
  345. *               REXX interpretable string and is interpreted.
  346. *
  347. */
  348. ExecuteACommand: procedure expose GV.
  349.     parse arg Command
  350.  
  351.     /* Clear Result Code
  352.     */
  353.     ResultCode = ""
  354.  
  355.     /* Split command into Verb , Parameters
  356.     */
  357.     parse var Command Verb "," Parameters
  358.  
  359.     /* Now get the uppercase version of the command for comparison
  360.     */
  361.     Command= translate(Verb)
  362.  
  363.     /* Add in the CD and Bootdrives
  364.     */
  365.     Parameters = SubstituteParms(Parameters)
  366.  
  367.     Select
  368.         when Command = "UNZIP" then do
  369.             say GV._UnzipImageMsg
  370.             GV._CD||":"||GV._RecoveryDir||"\UNZIP "Parameters
  371.             ResultCode = rc
  372.         end
  373.         when Command = "LOADRAM2" then do
  374.             GV._CD||":"||GV._RecoveryDir||"\LOADRAM2 "Parameters
  375.             ResultCode = rc
  376.         end
  377.         when Command = "RESTORE" then do
  378.             "ECHO Y | "GV._CD||":"||GV._RecoveryDir||"\RESTORE "Parameters "/S"
  379.             ResultCode = rc
  380.         end
  381.         when Command = "RECOVER" then do
  382.             "ECHO Y | "GV._CD||":"||GV._RecoveryDir||"\RESTORE "Parameters "/S"
  383.             ResultCode = rc
  384.         end
  385.         when Command = "ATTRIB" then do
  386.             GV._CD||":"||GV._RecoveryDir||"\ATTRIB "Parameters
  387.         end
  388.         when Command = "UNPACK" then do
  389.             GV._CD||":\RECOVERY\UNPack /C "Parameters GV._BootDrive":"
  390.         end
  391.         when Command = "MKDIR" then do
  392.             "MKDir "Parameters
  393.         end
  394.         when Command = "EAJOIN" then do
  395.             GV._CD||":\RECOVERY\EAUTIL /J" Parameters
  396.         end
  397.         when Command = "COPY" then do
  398.             "Copy "Parameters
  399.             ResultCode = rc
  400.         end
  401.         when Command = "SYSINSTX" then do
  402.             "SysInstX "GV._BootDrive":"
  403.             ResultCode = rc
  404.         end
  405.         when Command = "DELETE" then do
  406.             "Delete "Parameters
  407.         end
  408.         when Command = "RMDIR" then do
  409.             "RmDir "Parameters
  410.         end
  411.         when Command = "MKMAGICBOOTABLE" then do
  412.             /*  (126770) Enable a system to boot from DOS
  413.             */
  414.             call MakeSystemDOSBootable
  415.         end
  416.         when Command = "PRLDTBLCOPY" then do
  417.             /*  (127646) Handle refreshing of PRLDUZIP.TBL file.
  418.             *            This file is required for PRLDUZIP.CMD.
  419.             *   (127707) Made "say" commands NLS enabled.
  420.             */
  421.             parse var Parameters fromfile tofile .
  422.             if (Stream(fromfile,'c','query exists') == "") then do
  423.                 say GV._PrldZipTblErr
  424.                 say translatestring(GV._FileExistErr,GV._Separator||fromfile)
  425.                 ResultCode = 99
  426.             end
  427.             else do
  428.                 cpystr = GV._Separator||fromfile||GV._Separator||tofile
  429.                 say translatestring(GV._CopyAFileMsg,cpystr)
  430.                 "Copy "fromfile" "tofile
  431.                 ResultCode = rc
  432.             end
  433.         end
  434.         when Command = "UNLOCKFILES" then do
  435.             /*  (127707) Unlock all +R +S +H files
  436.             */
  437.             say GV._UnlockingFilesMsg
  438.             if (LastPos("\",Parameters) == Length(Parameters)) then do
  439.                  searchspec = Parameters||"*.*"
  440.             end
  441.             else searchspec = Parameters
  442.             call GatherLockedFiles searchspec, GV._AttributeWorkFile
  443.             do z = 1 to GV._LockedFileList.0
  444.                 itemstr = TurnOffAttrString(GV._LockedFileList.z._Attributes)||" "||,
  445.                           '"'||GV._LockedFileList.z._File||'"'
  446.                 say translatestring(GV._UnLockAFileMsg,GV._Separator||GV._LockedFileList.z._File)
  447.                 GV._CD||":"||GV._RecoveryDir||"\ATTRIB "itemstr
  448.             end
  449.         end
  450.         when Command = "LOCKFILES" then do
  451.             /*  (127707) Re-lock all "unlocked" files and
  452.             *   handle [Image File Attributes] section
  453.             */
  454.             say GV._LockingFilesMsg
  455.             do z = 1 to GV._LockedFileList.0
  456.                 itemstr = TurnOnAttrString(GV._LockedFileList.z._Attributes)||" "||,
  457.                           '"'||GV._LockedFileList.z._File||'"'
  458.                 say translatestring(GV._LockAFileMsg,GV._Separator||GV._LockedFileList.z._File)
  459.                 GV._CD||":"||GV._RecoveryDir||"\ATTRIB "itemstr
  460.             end
  461.             if ProcessPreservedImageAttributes() then do
  462.                 say GV._MissingPreserveSection
  463.                 ResultCode = 98
  464.             end
  465.         end
  466.         when Command = "RESTORECONFIGFILES" then do
  467.             /*  (128484) Restore configuration files.
  468.             */
  469.             ResultCode = RestoreConfigFiles()
  470.         end
  471.         otherwise do
  472.             /*  Attempt to process unknown command
  473.             */
  474.             Interpret Command Parameters
  475.         end
  476.     end
  477.     if ResultCode \== "" & ResultCode \== 0 then do
  478.         Say ""
  479.         Say GV._CommandError
  480.         Call Pause
  481.         Say ""; Say ""
  482.     end
  483.  
  484. return GV.Success
  485.  
  486. /*:VRX         ExecuteCommands
  487. */
  488. /* Description: Searches thru SectionNames commands and passes the commands
  489. *               one at a time to ExecuteACommand.
  490. *
  491. */
  492. ExecuteCommands: procedure expose GV.
  493.     Parse UPPER arg SectionName
  494.  
  495.     /* Find this SectionName
  496.     */
  497.     Section = 0
  498.     do i = 1 to GV._ScriptSections.0
  499.         if translate(GV._ScriptSections.i) = SectionName then do
  500.             Section = i
  501.             leave
  502.         end
  503.     end
  504.  
  505.     /* If we found the section
  506.     */
  507.     if Section <> 0 then do
  508.         /* Look for the command= keywords
  509.         */
  510.         do i = 1 to GV._Script.Section.0
  511.             line = GV._Script.Section.i
  512.             parse var line keyword "=" value
  513.  
  514.             /* If we found one, execute it
  515.             */
  516.             if translate(keyword) = "COMMAND" then do
  517.                 ok = ExecuteACommand(value)
  518.             end
  519.         end
  520.         /* Success if we found a section
  521.         */
  522.         ExitCode = GV._Success
  523.     end
  524.     else do
  525.         /* Failure if we could not find a section
  526.         */
  527.         ExitCode = GV._Fail
  528.     end
  529. return ExitCode
  530.  
  531.  
  532. /*:VRX         ExecuteConfig
  533. */
  534. /* Description: Searches thru Config Section
  535. *
  536. */
  537. ExecuteConfig: procedure expose GV.
  538.     Parse UPPER arg SectionName
  539.  
  540.     /* Find this SectionName
  541.     */
  542.     Section = 0
  543.     do i = 1 to GV._ScriptSections.0
  544.         if translate(GV._ScriptSections.i) = SectionName then do
  545.             Section = i
  546.             leave
  547.         end
  548.     end
  549.  
  550.     /* If we found the section
  551.     */
  552.     if Section <> 0 then do
  553.         /* Look for the command= keywords
  554.         */
  555.         do i = 1 to GV._Script.Section.0
  556.             line = GV._Script.Section.i
  557.             parse var line keyword "=" value
  558.  
  559.             /* If we found one, execute it
  560.             */
  561.             keyword = translate(keyword)
  562.             select
  563.                 when keyword = "BOOTDRIVE" then do
  564.                     GV._OriginalBootDrive = value
  565.                 end
  566.                 when keyword = "RECOVERYDIR" then do
  567.                     GV._RecoveryDir = value
  568.                 end
  569.                 otherwise do
  570.                     nop
  571.                 end
  572.             end
  573.         end
  574.         /* Success if we found a section
  575.         */
  576.         ExitCode = GV._Success
  577.     end
  578.     else do
  579.         /* Failure if we could not find a section
  580.         */
  581.         ExitCode = GV._Fail
  582.     end
  583. return ExitCode
  584.  
  585. /*:VRX         FatalError
  586. */
  587. /* Description: Warn user or Error that we cannot recover from.
  588. *
  589. */
  590. FatalError: procedure expose GV.
  591.  
  592.     Parse arg messagestem
  593.     Col = 5
  594.     Call ErrorMessage messagestem, 5, 5
  595.  
  596. exit
  597.  
  598. /*:VRX         Halt
  599. */
  600. /* Description: Allow Control-Break but tell the user how to get back.
  601. *
  602. */
  603. Halt:
  604.     /* Tell the user how to get back
  605.     */
  606.     Call WriteAt 1,1, GV._ANSI._BlackBack||GV._ANSI._WhiteFore
  607.     Call CLS
  608.  
  609.     Call WriteAt 20, 1, GV._RememberHaltMsg
  610.     Call GotoRowCol 22,1
  611.     Call Pause
  612.  
  613.     /* Clear the screen
  614.     */
  615.     Call WriteAt 1,1,GV._ANSI._BoldOff
  616.     Call CLS
  617.  
  618.     "@Prompt $_"||GV._HaltPrompt||"$_[$P]"
  619.  
  620.     exit
  621. return
  622.  
  623. /*:VRX         Help
  624. */
  625. Help: procedure expose GV.
  626.  
  627.     /* Set the Screen Color
  628.     */
  629.     Say GV._ANSI._ScreenColor
  630.  
  631.     /* Make the color take hold
  632.     */
  633.     Call CLS
  634.  
  635.     /* Help starts here
  636.     */
  637.     Row = 1 ; Col = 1
  638.  
  639.     Num = Make_CurrentMessage(GV._Helpmsg)
  640.  
  641.     Call WriteStemAt Row,Col,"GV._CurrentMessage."
  642.  
  643.     Call WriteAt 25,1,GV._ClearHelpMsg
  644.     Call GetResponse
  645. return
  646.  
  647. /*:VRX         Initialize
  648. */
  649. /* Description: Set up Global Variables
  650. *
  651. */
  652. Initialize: procedure expose GV.
  653.  
  654.     /* Create and Text strings
  655.     */
  656.     GV.=""
  657.     Call Translation
  658.  
  659.     /* Initialze ANSI Package
  660.     */
  661.     Call ANSIInit
  662.  
  663.     /* We control the screen
  664.     */
  665.     "@ECHO OFF"
  666.  
  667.     /* Load Rexx Utilities DLL
  668.     */
  669.     Call LoadExternalFuncs 7
  670.  
  671.     /* Flag to see if we read in the recovery script
  672.     */
  673.     GV._CommandFileRead = 0
  674.  
  675.     /* Path to recovery script
  676.     */
  677.     GV._RecoverFileSpec = ":\recovery\recover.scr"
  678.     GV._RecoverFileSpec1 = ":\recovery\attrib.exe"
  679.     GV._RecoverFileSpec2 = ":\recovery\unzip.exe"
  680.  
  681.     /* Recovery script Section names
  682.     */
  683.     GV._AptivaWare = "AptivaWare"
  684.     GV._ConfigFiles = "ConfigFiles"
  685.     GV._Config = "Configuration"
  686.  
  687.     /* Return Codes
  688.     */
  689.     GV._Fail = 1
  690.     GV._Success = 0
  691.  
  692.     /* Possible drive letters
  693.     */
  694.     GV._Drives = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  695.  
  696.     /* Translation separator
  697.     */
  698.     GV._Separator = "%"
  699.  
  700.     /* Menu selections and associated Functions
  701.     */
  702.     GV._MainMenu._Selections = "1 2 3 4 5 6"
  703.     GV._MainMenu._Functions  = "RecoverBoth "||,
  704.                              "RecoverConfig EditAutoexec "||,
  705.                              "EditConfig EditStartup CommandProcessor"
  706.     GV._EscapeChars = ""
  707.  
  708.     /* Help flags
  709.     */
  710.     GV._HELPFLAG =  "HELP TEXT "
  711.     GV._HELPSTART = "START"
  712.     GV._HELPEND   = "END"
  713.  
  714.     /* Location of TEDIT
  715.     */
  716.     GV._EditorDisk = "2"    /* 1, 2, 3 or %S or %T or A, B */
  717.     GV._EditorPath = "\TEDIT.EXE"
  718.  
  719.     /* Location of Recovery CMD File
  720.     */
  721.     GV._CmdDisk = "2"
  722.     GV._CmdDrive = "A"
  723.  
  724.     /* Original Boot Drive that the recovery images were made from
  725.     */
  726.     GV._OriginalBootDrive = "C"
  727.  
  728.     /* Expected Recovery Directory
  729.     */
  730.     GV._RecoveryDir = "\Recovery"
  731.  
  732.     /*  (127707) Default Attribute work file and Boot Data File.
  733.     */
  734.     GV._AttributeWorkFile = "C:\ATTRDATA.!!!"
  735.     GV._BootDataFile = "C:\BOOTDATA.!!!"
  736.  
  737.     /* First line of this program - used to check if correct disk is inserted
  738.     */
  739.     GV._MEFLAG = "/*:VRX         MAIN"
  740.  
  741.     /* Retranslate MRI with any replacable strings.
  742.     */
  743.     Call Translation
  744. return
  745.  
  746. /*:VRX         MainMenu
  747. */
  748. MainMenu: procedure expose GV.
  749.  
  750.     /* Set flag to Clear the Screen
  751.     */
  752.     Clear = 1
  753.  
  754.     /* Start with first menu item selected
  755.     */
  756.     HighLight = 1
  757.  
  758.     /* Flush the Keyboard
  759.     */
  760.     do while Chars()
  761.         Call PrldGetKey "NOECHO"
  762.     end
  763.  
  764.     /* Do until we get the Escape sequence
  765.     */
  766.     option = Menu("GV._MainMenu.", GV._MainMenuPrompt,,
  767.                    GV._MainMenuTitle, HighLight, Clear , GV._EscapeChars)
  768. return
  769.  
  770. /*:VRX         MakeEditorSpec
  771. */
  772. /* Description: Build fully qualified filespec for editor. And possibly
  773. *               prompt for Diskette insertion.
  774. */
  775. MakeEditorSpec: procedure expose GV.
  776.     Select
  777.         when wordpos(GV._EditorDisk,"1 2 3") <> 0 then do
  778.             /* Prompt for Disk Insertion
  779.             */
  780.             Drive = "A"
  781.             Call Make_CurrentMessage translatestring(GV._PromptForEditorMsg,,
  782.                                          GV._Separator||GV._EditorDisk)
  783.  
  784.             Call MessageAndWait "GV._CurrentMessage.",,
  785.                                 5,5,,
  786.                                 GV._ANSI._ScreenColor,GV._ANSI._ScreenColor
  787.  
  788.         end
  789.         when Pos("%",GV._EditorDisk) then do
  790.             /* Replace Drive
  791.             */
  792.             Drive = SubstituteParms(GV._EditorDisk)
  793.         end
  794.         otherwise do
  795.             Drive = GV._EditorDisk
  796.         end
  797.     end
  798.     FullSpec = Drive||":"||GV._EditorPath
  799. return FullSpec
  800.  
  801. /*:VRX         ProperCD
  802. */
  803. /* Description: Verify that the CD in the drive specified by the user
  804. *               has the proper files in it.
  805. *
  806. */
  807. ProperCD: procedure expose GV.
  808.     Parse arg CDDrive
  809.     ExitCode = ""
  810.     SIGNAL ON NOTREADY Name CDNotReady
  811.     ExitCode = Stream(CDDrive||GV._RecoverFileSpec,"C","Query Exists")
  812.     if ExitCode <> "" then do
  813.         ExitCode = Stream(CDDrive||GV._RecoverFileSpec1,"C","Query Exists")
  814.     end
  815.     if ExitCode <> "" then do
  816.         ExitCode = Stream(CDDrive||GV._RecoverFileSpec2,"C","Query Exists")
  817.     end
  818. CDNotReady:
  819. return ExitCode
  820.  
  821. /*:VRX         ReadCommandFile
  822. */
  823. /* Description: Reads in the recover script and creates the recovery structure.
  824. *               This structure consists of;
  825. *
  826. *               GV._ScriptSections.0 : Number of Sections read.
  827. *               GV._ScriptSections.1,n : Each Section Name
  828. *               GV._Script.i.0 : The number of keys for GV._ScriptSections.i
  829. *               GV._Script.i.1,n : Each keyword for GV._ScriptSections.i
  830. *
  831. *  Returns: The number of sections found.
  832. *
  833. */
  834. ReadCommandFile: procedure expose GV.
  835.     parse arg FileName
  836.  
  837.     /* Initialize Global Script Data Variable
  838.     */
  839.     GV._Script.=""
  840.     GV._ScriptSections. = ""
  841.     GV._ScriptSections.0 = 0
  842.  
  843.     rc = Linein(FileName,1,0)
  844.  
  845.     /* Skip to first section, so we do not have to always test for it
  846.     */
  847.     Section = ""
  848.     do while lines(FileName) > 0
  849.         line = Linein(FileName)
  850.  
  851.         /* Did we find a section
  852.         */
  853.         if left(line,1) = "[" then do
  854.             /* Clean it up, remove the [ ]
  855.             */
  856.             line = strip(line)
  857.             Sections = GV._ScriptSections.0 + 1
  858.             Section = substr(Line,2,length(Line) - 2)
  859.  
  860.             /* Save it and increase the count
  861.             */
  862.             Call Value "GV._ScriptSections."||Sections, Section
  863.             GV._ScriptSections.0 = Sections
  864.             leave
  865.         end
  866.     end
  867.  
  868.     /* Now get the rest of the file
  869.     */
  870.     do while lines(FileName) > 0
  871.         line = Linein(FileName)
  872.         Select
  873.             /* New Section
  874.             */
  875.             when left(line,1) = "[" then do
  876.                 /* Clean it up, remove the [ ]
  877.                 */
  878.                 line = strip(line)
  879.                 Sections = GV._ScriptSections.0 + 1
  880.                 Section = substr(Line,2,length(Line) - 2)
  881.  
  882.                 /* Save it and increase the count
  883.                 */
  884.                 Call Value "GV._ScriptSections."||Sections, Section
  885.                 GV._ScriptSections.0 = Sections
  886.             end
  887.             /* Comment or Empty line
  888.             */
  889.             when left(line,1) = ";"  | strip(line) = "" then do
  890.                 nop
  891.             end
  892.             when pos("=",line) <> 0 then do
  893.                 /* See if we have seen this Section/keyword before
  894.                 */
  895.                 if datatype(GV._Script.Sections.0) <> "NUM" then do
  896.                     Call Value "GV._Script."||Sections.0 , 0
  897.                 end
  898.  
  899.                 /* increase the count
  900.                 */
  901.                 index = value("GV._Script."||Sections.0) + 1
  902.  
  903.                 /* Save this keyword
  904.                 */
  905.                 Call Value "GV._Script."Sections.index, line
  906.                 Call Value "GV._Script."Sections.0, index
  907.             end
  908.             otherwise do
  909.                 nop
  910.             end
  911.         end
  912.     end
  913. return GV._ScriptSections.0
  914.  
  915. /*:VRX         Recover
  916. */
  917. Recover: procedure expose GV.
  918.     parse arg section
  919.  
  920.     /* Make sure we have the driver info we need first
  921.     */
  922.     if GV._CommandFileRead = 0 then do
  923.         if GV._CD == "" then do
  924.             GV._CD = AskForCD()
  925.         end
  926.         if GV._CD <> "" then do
  927.             GV._BootDrive = AskForBoot()
  928.         end
  929.  
  930.         /* Get out early if the user does not want to continue
  931.         */
  932.         if GV._BootDrive == "" then do
  933.             return 0
  934.         end
  935.         if GV._CD == "" then do
  936.             return 0
  937.         end
  938.  
  939.         /* Read in the recovery script
  940.         */
  941.         GV._CommandFileRead = ReadCommandFile(GV._CD||GV._RecoverFileSpec)
  942.     end
  943.     /* If read went well , execute the commands
  944.     */
  945.     if GV._CommandFileRead <> 0 then do
  946.         ok = ExecuteCommands(section)
  947.     end
  948.     else do
  949.         /* Report Error
  950.         */
  951.         Call Make_CurrentMessage GV._CouldNotReadMsg
  952.         Call FatalError "GV._CurrentMessage.", 5,5
  953.     end
  954. return ok
  955.  
  956. /*:VRX         RecoverAptiva
  957. */
  958. /* Description: ReCreates All Aptiva Application files on users hard drive.
  959. *
  960. */
  961. RecoverAptiva: procedure expose GV.
  962.         ok = Recover(GV._AptivaWare)
  963. return ok
  964.  
  965. /*:VRX         RecoverBoth
  966. */
  967. /* Description: Recover Aptiva Software and OS/2
  968. *
  969. */
  970. RecoverBoth: procedure expose GV.
  971.     ok = Recover(GV._AptivaWare)
  972. return
  973.  
  974. /*:VRX         RecoverConfig
  975. */
  976. /* Description: Recover Configuration Files
  977. *
  978. */
  979. RecoverConfig: procedure expose GV.
  980.         ok = Recover(GV._ConfigFiles)
  981. return
  982.  
  983. /*:VRX         RecoverOS2
  984. */
  985. /* Description: Recreates all of OS2 on the users Hard drive
  986. *
  987. */
  988. RecoverOS2: procedure expose GV.
  989.     ok = Recover(GV._OS2)
  990. return ok
  991.  
  992. /*:VRX         RecoveryScriptSpec
  993. */
  994. RecoveryScriptSpec: procedure expose GV.
  995. /*
  996. This section documents the format of the Recovery Scripts and the respective
  997. keywords. The basic format is similar to the Standard Windows INI file layout
  998. with Sections left justified and delimited with [ ].
  999.  
  1000. [A Section]
  1001.  
  1002. Comments start in column 1 with a semi-colon.
  1003.  
  1004. ; this is a comment
  1005.  
  1006. Keywords and values are paired between sections and are separated by the
  1007. equal (=) sign.
  1008.  
  1009. keyword=value
  1010.  
  1011. Keywords are not case sensitive but values are.
  1012. When using Keywords that cause execution or display text, order is important
  1013. and execution/display will occur from Top of File towards End of File.
  1014.  
  1015. The Following strings may be used in values and will be translated as specified
  1016. below;
  1017.  
  1018. %S = Source Drive Letter: The drive where the Recovery files are located.
  1019. %T = Target Drive Letter: The drive where the Recovered file will be
  1020.                          recovered to.
  1021.  
  1022. The Following special section if available may contain Configuration info.
  1023. [Configuration]
  1024.  
  1025.  
  1026. Keyword         Description
  1027. --------------  ---------------------------------------------------------------
  1028. description     One line of text describing this section. This should make
  1029.                 sense to the end user and needs to be translated.
  1030.  
  1031. command         Command to be executed. This will usually consist of two parts.
  1032.                 The first part is the command and if this command is not
  1033.                 one of the specially interpreted commands listed below, it
  1034.                 will be first concatenated with the second part  and then
  1035.                 passed to the rexx processor and "INTERPRETED" thus
  1036.                 allowing the dynamic assignment of variables via the script.
  1037.                 The second part of the command will usually be parameters for
  1038.                 the first part.
  1039.  
  1040.                 The command and parameters will be separated by a comma.
  1041.  
  1042.                 The following command/parameters are specially defined.
  1043.  
  1044.                 unpack, bundlefilespec
  1045.                     Will cause the bundle to be unpacked from the Recovery
  1046.                     path to the Recovered To drive.
  1047.  
  1048.                 unzip, zipfilespec
  1049.                     Will cause the zipfile to be unziped from the Recovery
  1050.                     path to the Recovered To drive.
  1051.  
  1052.                 mkdir, dirspec
  1053.                     Will attempt to create the dirspec directory.
  1054.  
  1055.                 eajoin, dirspec
  1056.                     Will look for a file in the dirspec with the same name as
  1057.                     dirspec and an extension of .eaf and will use EAUTIL to
  1058.                     join them.
  1059.  
  1060.                     or
  1061.                 eajoin, dirspec filespec
  1062.                     Will look for filespec and will use EAUTIL to join it to
  1063.                     dirspec.
  1064.  
  1065.                 sysinstx, driveletter
  1066.                     Will run SYSINSTX on driveletter to make it bootable.
  1067.  
  1068. */
  1069. return
  1070.  
  1071. /*:VRX         MakeSystemDOSBootable
  1072. */
  1073. MakeSystemDOSBootable: procedure expose GV.
  1074.  
  1075.     /*  (126770) Enable a system to boot from DOS
  1076.     */
  1077.     fspec = GV._BootDrive||":\OS2\SYSTEM\*.DOS"
  1078.     say translatestring(GV._UnLockAFileMsg,GV._Separator||fspec)
  1079.     GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||fspec||" -R -H -S"
  1080.     if QueryFileExists( fspec ) then do
  1081.          say translatestring(GV._EraseAFileMsg,GV._Separator||fspec)
  1082.         "erase "fspec
  1083.     end
  1084.     fspec = GV._BootDrive||":\OS2\SYSTEM\*.OS2"
  1085.     say translatestring(GV._UnLockAFileMsg,GV._Separator||fspec)
  1086.     GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||fspec||" -R -H -S"
  1087.     if QueryFileExists( fspec ) then do
  1088.          say translatestring(GV._EraseAFileMsg,GV._Separator||fspec)
  1089.         "erase "fspec
  1090.     end
  1091.     "SysInstX "GV._BootDrive":"
  1092.     cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.OS2 "||,
  1093.              GV._Separator||GV._BootDrive||":\AUTOEXEC.BAT"
  1094.     say translatestring(GV._CopyAFileMsg,cpystr)
  1095.     "copy "GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.OS2 "||GV._BootDrive||":\AUTOEXEC.BAT"
  1096.     cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\CONFIG.OS2 "||,
  1097.              GV._Separator||GV._BootDrive||":\CONFIG.SYS"
  1098.     say translatestring(GV._CopyAFileMsg,cpystr)
  1099.     "copy "GV._CD||":"||GV._RecoveryDir||"\CONFIG.OS2 "||GV._BootDrive||":\CONFIG.SYS"
  1100.     cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.DOS "||,
  1101.              GV._Separator||GV._BootDrive||":\OS2\SYSTEM\AUTOEXEC.DOS"
  1102.     say translatestring(GV._CopyAFileMsg,cpystr)
  1103.     "copy "GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.DOS "||GV._BootDrive||":\OS2\SYSTEM\AUTOEXEC.DOS"
  1104.     cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\BOOT.DOS "||,
  1105.              GV._Separator||GV._BootDrive||":\OS2\SYSTEM\BOOT.DOS"
  1106.     say translatestring(GV._CopyAFileMsg,cpystr)
  1107.     "copy "GV._CD||":"||GV._RecoveryDir||"\BOOT.DOS "||GV._BootDrive||":\OS2\SYSTEM\BOOT.DOS"
  1108.     cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\COMMAND.DOS "||,
  1109.              GV._Separator||GV._BootDrive||":\OS2\SYSTEM\COMMAND.DOS"
  1110.     say translatestring(GV._CopyAFileMsg,cpystr)
  1111.     "copy "GV._CD||":"||GV._RecoveryDir||"\COMMAND.DOS "||GV._BootDrive||":\OS2\SYSTEM\COMMAND.DOS"
  1112.     cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\CONFIG.DOS "||,
  1113.              GV._Separator||GV._BootDrive||":\OS2\SYSTEM\CONFIG.DOS"
  1114.     say translatestring(GV._CopyAFileMsg,cpystr)
  1115.     "copy "GV._CD||":"||GV._RecoveryDir||"\CONFIG.DOS "||GV._BootDrive||":\OS2\SYSTEM\CONFIG.DOS"
  1116.     say translatestring(GV._LockAFileMsg,GV._Separator||GV._BootDrive||":\OS2\SYSTEM\*.DOS")
  1117.     GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||GV._BootDrive||":\OS2\SYSTEM\*.DOS +A"
  1118.     say translatestring(GV._LockAFileMsg,GV._Separator||GV._BootDrive||":\OS2\SYSTEM\BOOT.DOS")
  1119.     GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||GV._BootDrive||":\OS2\SYSTEM\BOOT.DOS +R"
  1120.     Call Make_CurrentMessage GV._RemoveDisketteMsg
  1121.     Call WarningMessage "GV._CurrentMessage.", 5,5
  1122.     GV._CD||":"||GV._RecoveryDir||"\BOOT /DOS /QUIET"
  1123.  
  1124. return
  1125.  
  1126. /*:VRX         RequestCmdDisk
  1127. */
  1128. RequestCmdDisk: procedure expose GV.
  1129.     Call CLS
  1130.     Call ErrorBeep
  1131.     Call Make_CurrentMessage translatestring(GV._ReinsertDiskMsg,,
  1132.                                          GV._Separator||GV._CmdDisk||,
  1133.                                          GV._Separator||GV._CmdDrive)
  1134.  
  1135.  
  1136.     Call WriteStemAt 5,5,"GV._CurrentMessage."
  1137.     Pull junk
  1138. return
  1139.  
  1140. /*:VRX         SubstituteParms
  1141. */
  1142. /* Description: Replaces %S with Source Drive and %T with Target Drive.
  1143. *
  1144. */
  1145. SubstituteParms: procedure expose GV.
  1146.  
  1147.     parse arg p
  1148.  
  1149.     /* Make sure the substitute parms have values
  1150.     */
  1151.     if pos("%T",translate(p)) <> 0 then do
  1152.         if GV._BootDrive = "" then do
  1153.             GV._BootDrive = AskForBoot()
  1154.         end
  1155.     end
  1156.  
  1157.     if GV._BootDrive <> "" then do
  1158.         if pos("%S",translate(p)) <> 0 then do
  1159.             if GV._CD = "" then do
  1160.                 GV._CD = AskForCD()
  1161.             end
  1162.         end
  1163.         /* Handle %S %T
  1164.         */
  1165.         p = ReplaceAll("%S",GV._CD,p)
  1166.         p = ReplaceAll("%T",GV._BootDrive,p)
  1167.     end
  1168. return p
  1169.  
  1170. /*:VRX         GatherLockedFiles
  1171. */
  1172. GatherLockedFiles: Procedure Expose GV.
  1173.  
  1174.     parse arg fspec, workfile;
  1175.  
  1176.     /*  We can not use SysFileTree() since PRLDLITE
  1177.     *   does not have this function. So, we will
  1178.     *   process the piped output of ATTRIB.
  1179.     */
  1180.     GV._CD||":"||GV._RecoveryDir||"\ATTRIB "fspec" /S > "workfile
  1181.  
  1182.     /*  Handle Hidden/System/Readonly Files
  1183.     */
  1184.     item = 0
  1185.     do while(Lines(workfile))
  1186.         itemstr = Linein(workfile)
  1187.         colonpos = Pos(":",itemstr)
  1188.         Select
  1189.             when(colonpos == 0) then do
  1190.                 attr = itemstr
  1191.                 if pos("S",attr) \== 0 | pos("H",attr) \== 0 | pos("R",attr) \== 0 then do
  1192.                     item = item + 1
  1193.                     GV._LockedFileList.item._Attributes = attr
  1194.                     GV._LockedFileList.item._File       = Linein(workfile)
  1195.                 end
  1196.                 else junk = Linein(workfile)
  1197.             end
  1198.             when(colonpos >= 3) then do
  1199.                 attr = Strip(SubStr(itemstr,1,colonpos-2))
  1200.                 if pos("S",attr) \== 0 | pos("H",attr) \== 0 | pos("R",attr) \== 0 then do
  1201.                     item = item + 1
  1202.                     GV._LockedFileList.item._File       = Strip(SubStr(itemstr,colonpos-1))
  1203.                     GV._LockedFileList.item._Attributes = attr
  1204.                 end
  1205.             end
  1206.             otherwise do
  1207.                 nop
  1208.             end
  1209.         end
  1210.     end
  1211.     GV._LockedFileList.0 = item
  1212.     call Lineout workfile
  1213.     say translatestring(GV._EraseAFileMsg,GV._Separator||workfile)
  1214.     'erase 'workfile
  1215.  
  1216. return
  1217.  
  1218. /*:VRX         TurnOnAttrString
  1219. */
  1220. TurnOnAttrString: Procedure Expose GV.
  1221.  
  1222.     parse arg str
  1223.     newstr = ""
  1224.     do while(str \== "")
  1225.         parse var str ch 2 str
  1226.         if ch \== " " then do
  1227.             newstr = newstr" +"ch
  1228.         end
  1229.     end
  1230.  
  1231. return newstr
  1232.  
  1233. /*:VRX         TurnOffAttrString
  1234. */
  1235. TurnOffAttrString: Procedure Expose GV.
  1236.  
  1237.     parse arg str
  1238.     newstr = ""
  1239.     do while(str \== "")
  1240.         parse var str ch 2 str
  1241.         if ch \== " " then do
  1242.             newstr = newstr" -"ch
  1243.         end
  1244.     end
  1245.  
  1246. return newstr
  1247.  
  1248. /*:VRX         ProcessPreservedImageAttributes
  1249. */
  1250. /* Description: For each card in the [Image File Attribute] section
  1251. *               of the script file, process the appropriate ATTRIB
  1252. *               command.
  1253. */
  1254. ProcessPreservedImageAttributes: procedure expose GV.
  1255.  
  1256.     /* See if [Image File Attributes] section exists
  1257.     */
  1258.     Section = 0
  1259.     do i = 1 to GV._ScriptSections.0
  1260.         if translate(GV._ScriptSections.i) == "IMAGE FILE ATTRIBUTES" then do
  1261.             Section = i
  1262.             leave
  1263.         end
  1264.     end
  1265.  
  1266.     /* If we found the section
  1267.     */
  1268.     if Section <> 0 then do
  1269.         /* Look for the attribdata= keyword
  1270.         */
  1271.         do i = 1 to GV._Script.Section.0
  1272.             line = GV._Script.Section.i
  1273.             parse var line keyword "=" valuestr
  1274.  
  1275.             /* If we found one, set attributes for specified file
  1276.             */
  1277.             if translate(keyword) = "ATTRIBDATA" then do
  1278.                 parse var valuestr attr file
  1279.                 itemstr = '"'||file||'"'||" "||TurnOnAttrString(Translate(attr," ","-"))
  1280.                 say translatestring(GV._LockAFileMsg,GV._Separator||file)
  1281.                 GV._CD||":"||GV._RecoveryDir||"\ATTRIB "itemstr
  1282.             end
  1283.  
  1284.         end
  1285.         /* Success if we found a section
  1286.         */
  1287.         ExitCode = GV._Success
  1288.     end
  1289.     else do
  1290.         /* Failure if we could not find a section
  1291.         */
  1292.         ExitCode = GV._Fail
  1293.     end
  1294.  
  1295. return ExitCode
  1296.  
  1297. /*:VRX         RestoreConfigFiles
  1298. */
  1299. /* Description: Restore appropriate configuration files for the
  1300. *               OS currently enabled.
  1301. */
  1302. RestoreConfigFiles: procedure expose GV.
  1303.  
  1304.     rcode = 0
  1305.  
  1306.     /*  Determine OS currently active.
  1307.     */
  1308.     GV._CD||":"||GV._RecoveryDir||"\BOOT /QUERY > "GV._BootDataFile
  1309.     bootdata = LineIn(GV._BootDataFile)
  1310.     osid = Word(bootdata,7)
  1311.  
  1312.     /*  Restore appropriate files for active OS.
  1313.     *   (128510) 1. Add unzip command for PS1BOOT files to DOS case.
  1314.     *            2. Fix Access Denied message on Boot.DOS|OS2 files.
  1315.     *            3. Add user messages for copy/attrib/erase commands.
  1316.     */
  1317.     Select
  1318.         when(osid == "DOS") then do
  1319.             fspec = GV._BootDrive||":\OS2\SYSTEM\*.DOS"
  1320.             say translatestring(GV._UnLockAFileMsg,GV._Separator||fspec)
  1321.             GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||fspec||" -R -H -S"
  1322.             if QueryFileExists( fspec ) then do
  1323.                  say translatestring(GV._EraseAFileMsg,GV._Separator||fspec)
  1324.                 "erase "fspec
  1325.             end
  1326.             fspec = GV._BootDrive||":\OS2\SYSTEM\*.OS2"
  1327.             say translatestring(GV._UnLockAFileMsg,GV._Separator||fspec)
  1328.             GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||fspec||" -R -H -S"
  1329.             if QueryFileExists( fspec ) then do
  1330.                  say translatestring(GV._EraseAFileMsg,GV._Separator||fspec)
  1331.                 "erase "fspec
  1332.             end
  1333.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.DOS "||,
  1334.                      GV._Separator||GV._BootDrive||":\AUTOEXEC.BAT"
  1335.             say translatestring(GV._CopyAFileMsg,cpystr)
  1336.             "copy "GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.DOS "||GV._BootDrive||":\AUTOEXEC.BAT"
  1337.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\CONFIG.DOS "||,
  1338.                      GV._Separator||GV._BootDrive||":\CONFIG.SYS"
  1339.             say translatestring(GV._CopyAFileMsg,cpystr)
  1340.             "copy "GV._CD||":"||GV._RecoveryDir||"\CONFIG.DOS "||GV._BootDrive||":\CONFIG.SYS"
  1341.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.OS2 "||,
  1342.                      GV._Separator||GV._BootDrive||":\OS2\SYSTEM\AUTOEXEC.OS2"
  1343.             say translatestring(GV._CopyAFileMsg,cpystr)
  1344.             "copy "GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.OS2 "||GV._BootDrive||":\OS2\SYSTEM\AUTOEXEC.OS2"
  1345.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\BOOT.OS2 "||,
  1346.                      GV._Separator||GV._BootDrive||":\OS2\SYSTEM\BOOT.OS2"
  1347.             say translatestring(GV._CopyAFileMsg,cpystr)
  1348.             "copy "GV._CD||":"||GV._RecoveryDir||"\BOOT.OS2 "||GV._BootDrive||":\OS2\SYSTEM\BOOT.OS2"
  1349.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\CONFIG.OS2 "||,
  1350.                      GV._Separator||GV._BootDrive||":\OS2\SYSTEM\CONFIG.OS2"
  1351.             say translatestring(GV._CopyAFileMsg,cpystr)
  1352.             "copy "GV._CD||":"||GV._RecoveryDir||"\CONFIG.OS2 "||GV._BootDrive||":\OS2\SYSTEM\CONFIG.OS2"
  1353.             say translatestring(GV._LockAFileMsg,GV._Separator||GV._BootDrive||":\OS2\SYSTEM\*.OS2")
  1354.             GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||GV._BootDrive||":\OS2\SYSTEM\*.OS2 +A"
  1355.             say translatestring(GV._LockAFileMsg,GV._Separator||GV._BootDrive||":\OS2\SYSTEM\BOOT.OS2")
  1356.             GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||GV._BootDrive||":\OS2\SYSTEM\BOOT.OS2 +R"
  1357.             GV._CD||":"||GV._RecoveryDir||"\UNZIP -o "||,
  1358.                   GV._CD||":\RECOVERY\SYSTEM.ZIP ps1boot\* -d "||GV._BootDrive||":\"
  1359.         end
  1360.         when(osid == "OS2") then do
  1361.             fspec = GV._BootDrive||":\OS2\SYSTEM\*.DOS"
  1362.             say translatestring(GV._UnLockAFileMsg,GV._Separator||fspec)
  1363.             GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||fspec||" -R -H -S"
  1364.             if QueryFileExists( fspec ) then do
  1365.                  say translatestring(GV._EraseAFileMsg,GV._Separator||fspec)
  1366.                 "erase "fspec
  1367.             end
  1368.             fspec = GV._BootDrive||":\OS2\SYSTEM\*.OS2"
  1369.             say translatestring(GV._UnLockAFileMsg,GV._Separator||fspec)
  1370.             GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||fspec||" -R -H -S"
  1371.             if QueryFileExists( fspec ) then do
  1372.                  say translatestring(GV._EraseAFileMsg,GV._Separator||fspec)
  1373.                 "erase "fspec
  1374.             end
  1375.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.OS2 "||,
  1376.                      GV._Separator||GV._BootDrive||":\AUTOEXEC.BAT"
  1377.             say translatestring(GV._CopyAFileMsg,cpystr)
  1378.             "copy "GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.OS2 "||GV._BootDrive||":\AUTOEXEC.BAT"
  1379.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\CONFIG.OS2 "||,
  1380.                      GV._Separator||GV._BootDrive||":\CONFIG.SYS"
  1381.             say translatestring(GV._CopyAFileMsg,cpystr)
  1382.             "copy "GV._CD||":"||GV._RecoveryDir||"\CONFIG.OS2 "||GV._BootDrive||":\CONFIG.SYS"
  1383.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.DOS "||,
  1384.                      GV._Separator||GV._BootDrive||":\OS2\SYSTEM\AUTOEXEC.DOS"
  1385.             say translatestring(GV._CopyAFileMsg,cpystr)
  1386.             "copy "GV._CD||":"||GV._RecoveryDir||"\AUTOEXEC.DOS "||GV._BootDrive||":\OS2\SYSTEM\AUTOEXEC.DOS"
  1387.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\BOOT.DOS "||,
  1388.                      GV._Separator||GV._BootDrive||":\OS2\SYSTEM\BOOT.DOS"
  1389.             say translatestring(GV._CopyAFileMsg,cpystr)
  1390.             "copy "GV._CD||":"||GV._RecoveryDir||"\BOOT.DOS "||GV._BootDrive||":\OS2\SYSTEM\BOOT.DOS"
  1391.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\COMMAND.DOS "||,
  1392.                      GV._Separator||GV._BootDrive||":\OS2\SYSTEM\COMMAND.DOS"
  1393.             say translatestring(GV._CopyAFileMsg,cpystr)
  1394.             "copy "GV._CD||":"||GV._RecoveryDir||"\COMMAND.DOS "||GV._BootDrive||":\OS2\SYSTEM\COMMAND.DOS"
  1395.             cpystr = GV._Separator||GV._CD||":"||GV._RecoveryDir||"\CONFIG.DOS "||,
  1396.                      GV._Separator||GV._BootDrive||":\OS2\SYSTEM\CONFIG.DOS"
  1397.             say translatestring(GV._CopyAFileMsg,cpystr)
  1398.             "copy "GV._CD||":"||GV._RecoveryDir||"\CONFIG.DOS "||GV._BootDrive||":\OS2\SYSTEM\CONFIG.DOS"
  1399.             say translatestring(GV._LockAFileMsg,GV._Separator||GV._BootDrive||":\OS2\SYSTEM\*.DOS")
  1400.             GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||GV._BootDrive||":\OS2\SYSTEM\*.DOS +A"
  1401.             say translatestring(GV._LockAFileMsg,GV._Separator||GV._BootDrive||":\OS2\SYSTEM\BOOT.DOS")
  1402.             GV._CD||":"||GV._RecoveryDir||"\ATTRIB "||GV._BootDrive||":\OS2\SYSTEM\BOOT.DOS +R"
  1403.         end
  1404.         otherwise do
  1405.             say translatestring(GV._UnknownBootableOS,GV._Separator||osid)
  1406.             rcode = 97
  1407.         end
  1408.     end
  1409.  
  1410.     /*  Cleanup
  1411.     */
  1412.     call Lineout GV._BootDataFile
  1413.     say translatestring(GV._EraseAFileMsg,GV._Separator||GV._BootDataFile)
  1414.     'erase 'GV._BootDataFile
  1415.  
  1416. return rcode
  1417.  
  1418. /*:VRX         QueryFileExists
  1419. */
  1420. /* Description: Return true(1) if file exists, otherwise return false(0)
  1421. */
  1422. QueryFileExists: Procedure expose GV.
  1423.  
  1424.     parse arg fname;
  1425.  
  1426.     if (stream(fname,'c','query exists') \== "") then do
  1427.         fExists = 1
  1428.     end
  1429.     else fExists = 0
  1430.  
  1431. return fExists
  1432.  
  1433. /*:VRX         Translation
  1434. */
  1435. /* Description: All translatable text
  1436. *
  1437. */
  1438. Translation: procedure expose GV.
  1439.  
  1440.     crlf = "0D0A"x
  1441.  
  1442.     GV._MainMenu.0 = 6
  1443.     GV._MainMenu.1 = " Recuperar la imagen de OS/2 Warp de Aptiva"
  1444.     GV._MainMenu.2 = " Recuperar los archivos de configuración"
  1445.     GV._MainMenu.3 = " Editar AUTOEXEC.BAT"
  1446.     GV._MainMenu.4 = " Editar CONFIG.SYS"
  1447.     GV._MainMenu.5 = " Editar STARTUP.CMD"
  1448.     GV._MainMenu.6 = " Ir al indicador de mandatos de OS/2 Warp"
  1449.  
  1450.     GV._MainMenuPrompt = "Seleccione una opción."
  1451.     GV._MainMenuTitle  = "Menú Recuperación de Aptiva"
  1452.  
  1453.     GV._CommandError  = ,
  1454. "El mandato anterior ha indicado una anomalía. Anote el mensaje"||crlf||,
  1455. "de error y comunique este problema al Servicio de OS/2."
  1456.  
  1457.     GV._FatalErrorMsg = "Comunique este error al Servicio de OS/2."
  1458.  
  1459.     GV._CDPromptTitle = "Solicitando la letra de la unidad de CD-Rom"
  1460.     GV._CDPrompt      = "Letra de unidad: "
  1461.  
  1462.     GV._LeaveCDPrompt   = "ABANDONAR"
  1463.     GV._CDPromptMsg = ,
  1464.          "Inserte el CD de Exploración de Multimedia de Aptiva en  "||crlf||,
  1465.          "la unidad de CD-ROM. Seguidamente teclee la letra de unidad de  "||crlf||,
  1466.          "la unidad de CD-ROM. Si no ha modificado la      "||crlf||,
  1467.          "configuración del sistema, es probable que sea la D.        "||crlf||crlf||,
  1468.          "Teclee "||GV._LeaveCDPrompt||" y pulse INTRO para regresar al Menú."
  1469.  
  1470.     GV._BootPromptTitle = "¿Está seguro?"
  1471.     GV._BootPrompt      = "¿Desea continuar? (Sí/No): "
  1472.  
  1473.     GV._BootPromptMsg = ,
  1474. "El programa de Recuperación supone que OS/2 y el software de las aplicaciones de "||crlf||,
  1475. "Aptiva están instalados en la unidad %. Toda la restauración se llevará a cabo en    "||crlf||,
  1476. "la unidad %. Todas las opciones de Editar suponen que los archivos que deben editarse se   "||crlf||,
  1477. "encuentran en la unidad %. Si ésta no es la unidad en la que ha arrancado OS/2 o en "||crlf||,
  1478. "la que reside el software de Aptiva, no debe continuar. "
  1479.  
  1480.  
  1481.     GV._BadCDMsg    = "La siguiente unidad no es una unidad de CD-ROM válida: "
  1482.     GV._WrongCDMsg  = "No se han encontrado los archivos necesarios en la unidad %."
  1483.  
  1484.     GV._RememberExitMsg = "Recuerde que debe teclear EXIT para regresar al menú Recuperación"
  1485.  
  1486.     GV._Prompt      = "Teclee EXIT para volver al Menú"
  1487.  
  1488.     GV._PromptForEditorMsg = "Asegúrese de que el Disquete % de recuperación de Aptiva se encuentra en la unidad A:"
  1489.  
  1490.     GV._EditorNotFoundMsg = "% no se encuentra. "||crlf||,
  1491.                            "Si ha trasladado el Editor a otra unidad/directorio, es"||crlf||,
  1492.                            "probable que pueda invocarlo desde la opción 'Ir al indicador de OS/2'."
  1493.  
  1494.     GV._EditorDriveNotReadyMsg = "¡La unidad con el mandato % no está lista!"||crlf||,
  1495.                                 "Inserte el Disquete o CD correcto."
  1496.  
  1497.  
  1498.     GV._CouldNotReadMsg ="El programa de recuperación no ha podido encontrar los archivos necesarios."||crlf||crlf||,
  1499.                           GV._FatalErrorMsg
  1500.  
  1501.  
  1502.  
  1503.     GV._HelpMsg = ""||,
  1504.     "                AYUDA PARA EL MENU RECUPERACION DE APTIVA                "||crlf||,
  1505.     "                                                                         "||crlf||,
  1506.     " Utilice el Disquete de RECUPERACION de Aptiva como ayuda para solucionar"||crlf||,
  1507.     " problemas (archivos de sistema corruptos o errores de software). Puede ;"||crlf||,
  1508.     "                                                                         "||crlf||,
  1509.     " (1) Instalar el software original de Aptiva y el software original del "||crlf||,
  1510.     "     sistema operativo OS/2 a partir de los disquetes que ha creado y de "||crlf||,
  1511.     "     las imágenes que acompañaban al Aptiva.                             "||crlf||,
  1512.     " (2) Recuperar archivos de Configuración.                                "||crlf||,
  1513.     " (3) Utilizar el editor TEDIT para editar el archivo AUTOEXEC.BAT.       "||crlf||,
  1514.     " (4) Utilizar el editor TEDIT para editar el archivo CONFIG.SYS.         "||crlf||,
  1515.     " (5) Utilizar el editor TEDIT para editar el archivo STARTUP.CMD.        "||crlf||,
  1516.     " (6) Ir a un indicador de mandatos de OS/2. Desde ahí puede acceder a    "||crlf||,
  1517.     "     BACKUP y RESTORE para crear y restaurar un juego de disquetes de    "||crlf||,
  1518.     "     seguridad o usar CHKDSK para buscar errores en el disco duro,       "||crlf||,
  1519.     "     o FORMAT y FDISK para corregir los errores principales de disco. Vea"||crlf||,
  1520.     "     Consulta de mandatos de OS/2 para más detalles sobre los anteriores."||crlf||,
  1521.     "                                                                         "
  1522. /*            111111111122222222223333333333444444444455555555556666666666777*/
  1523. /*   123456789012345678901234567890123456789012345678901234567890123456789012*/
  1524. /* Translators: Keep text within quotes and do not add lines                 */
  1525.  
  1526.     GV._ClearHelpMsg = "Pulse cualquier tecla para volver al menú Recuperación."
  1527.     GV._ReinsertDiskMsg = "Vuelva a insertar el Disquete % de recuperación en la unidad %."
  1528.  
  1529.     /*  (126770) Warning message to remove disktette from drive A:
  1530.     */
  1531.     GV._RemoveDisketteMsg = "El sistema está a punto de rearrancar en la imagen recuperada."||crlf||,
  1532.                             "Por favor, extraiga el Disquete #2 de recuperación de la unidad A:"
  1533.  
  1534.     /*  (127646) PRLDTBLCOPY error messages
  1535.     */
  1536.     GV._PrldZipTblErr = "No se puede copiar el archivo ZipTable precargado."
  1537.     GV._FileExistErr  = "% no existe."
  1538.  
  1539.     /*  (127707 & 128484) Additional error messages
  1540.     */
  1541.     GV._MissingPreserveSection = "El archivo de Scripts de recuperación no contiene "||,
  1542.                                  "una sección [Image File Attributes]."
  1543.     GV._UnlockingFilesMsg = "Preparándose para desbloquear los archivos de destino. ¡Tenga paciencia, por favor!"
  1544.     GV._LockingFilesMsg = "Preparándose para bloquear los archivos de destino. ¡Tenga paciencia, por favor!"
  1545.     GV._UnknownBootableOS = "El sistema operativo % no está soportado para la "||,
  1546.                             "restauración de los archivos de configuración."
  1547.  
  1548.     /*  (128510) Additional error messages
  1549.     */
  1550.     GV._CopyAFileMsg   = "Copiando archivo(s) % en %"
  1551.     GV._LockAFileMsg   = "Bloqueando archivo(s) %"
  1552.     GV._UnLockAFileMsg = "Desbloqueando archivo(s) %"
  1553.     GV._EraseAFileMsg  = "Suprimiendo archivo(s) %"
  1554.     GV._UnzipImageMsg  = "Restaurando datos precargados de imágenes..."
  1555.  
  1556. return
  1557. /* Including file 'ANSIPKG.VRS' */
  1558.  
  1559. /*:VRX         ANSIInit
  1560. */
  1561. /* Description: Initializes ANSI Codes and Variables
  1562. *
  1563. */
  1564. ANSIInit: procedure expose GV.
  1565.  
  1566.     /* ANSI Escape sequences
  1567.     */
  1568.     GV._ANSI._CLS             = ""
  1569.     GV._ANSI._Normal          = ""
  1570.     GV._ANSI._Bold            = ""
  1571.     GV._ANSI._Underscore      = ""
  1572.     GV._ANSI._Blink           = ""
  1573.     GV._ANSI._Reverse         = ""
  1574.     GV._ANSI._Invisible       = ""
  1575.     GV._ANSI._BlackFore       = ""
  1576.     GV._ANSI._RedFore         = ""
  1577.     GV._ANSI._GreenFore       = ""
  1578.     GV._ANSI._YellowFore      = ""
  1579.     GV._ANSI._BlueFore        = ""
  1580.     GV._ANSI._MagentaFore     = ""
  1581.     GV._ANSI._CyanFore        = ""
  1582.     GV._ANSI._WhiteFore       = ""
  1583.     GV._ANSI._BlackBack       = ""
  1584.     GV._ANSI._RedBack         = ""
  1585.     GV._ANSI._GreenBack       = ""
  1586.     GV._ANSI._YellowBack      = ""
  1587.     GV._ANSI._BlueBack        = ""
  1588.     GV._ANSI._MagentaBack     = ""
  1589.     GV._ANSI._CyanBack        = ""
  1590.     GV._ANSI._WhiteBack       = ""
  1591.     GV._ANSI._BlueOnWhite     = ""
  1592.     GV._ANSI._RedOnWhite      = ""
  1593.     GV._ANSI._WhiteOnBlue     = ""
  1594.     GV._ANSI._Shadow          = ""
  1595.     GV._ANSI._NoCursor        = ""
  1596.     GV._ANSI._ClearToEOL      = ""
  1597.     GV._ANSI._BoldOn          = ""
  1598.     GV._ANSI._BoldOff         = ""
  1599.     GV._ANSI._ScreenColor     = GV._ANSI._BlueOnWhite
  1600.     GV._ANSI._ErrorColor      = GV._ANSI._RedOnWhite
  1601.     GV._ANSI._WarningColor      = GV._ANSI._RedOnWhite
  1602.     GV._ANSI._MenuColor       = GV._ANSI._WhiteOnBlue
  1603.     GV._ANSI._SaveCursor      = "s"
  1604.     GV._ANSI._RestoreCursor   = "u"
  1605.     GV._ANSI._CursorUp        = "#A"
  1606.     GV._ANSI._CursorDown      = "#B"
  1607.     GV._ANSI._CursorForward   = "#C"
  1608.     GV._ANSI._CursorBack      = "#D"
  1609.     GV._ANSI._CursorReport    = "#;#R"
  1610.     GV._ANSI._SetMode40x25b   = "=0h"
  1611.     GV._ANSI._SetMode40x25c   = "=1h"
  1612.     GV._ANSI._SetMode80x25b   = "=2h"
  1613.     GV._ANSI._SetMode80x25c   = "=3h"
  1614.     GV._ANSI._SetMode320x200c = "=4h"
  1615.     GV._ANSI._SetMode320x200b = "=5h"
  1616.     GV._ANSI._SetMode640x200b = "=6h"
  1617.     GV._ANSI._WrapAtEnd       = "=7h"
  1618.  
  1619.     /* Menu strings
  1620.     */
  1621.     GV._ANSI._TopBar = "┌"||Copies("─",75)||"┐"
  1622.     GV._ANSI._BottomBar ="└"||Copies("─",75)||"┘"
  1623.     GV._ANSI._RightSide = "│"
  1624.     GV._ANSI._LeftSide = "│"
  1625.  
  1626.     /* KeyCodes
  1627.     */
  1628.     GV._ANSI._Up   = "H"
  1629.     GV._ANSI._Down = "P"
  1630.     GV._ANSI._Help = ";"
  1631.     GV._ANSI._Enter = '0D'x
  1632.  
  1633.  
  1634.     /* Menu escape back door
  1635.     */
  1636.     GV._ANSI._Escape = ""
  1637.  
  1638.     Call ANSITranslation
  1639.  
  1640. return
  1641.  
  1642. /*:VRX         ClearToEOL
  1643. */
  1644. /* Description: Clear from Cursor to end of line
  1645. *
  1646. */
  1647. ClearToEOL: procedure expose GV.
  1648.     Call Charout , GV._ANSI._ClearToEOL
  1649. return
  1650.  
  1651. /*:VRX         CLS
  1652. */
  1653. /* Description: Clear the screen
  1654. *
  1655. */
  1656. CLS: procedure expose GV.
  1657.     Call Charout , GV._ANSI._CLS
  1658. return
  1659.  
  1660. /*:VRX         GoToRowCol
  1661. */
  1662. /* Description: Move cursor to a specified Row and Column
  1663. *
  1664. */
  1665. GoToRowCol: procedure expose GV.
  1666.     Parse arg row, col
  1667.     Call Charout ,""||row||";"||col||"H"
  1668. return
  1669.  
  1670.  
  1671. /*:VRX         WriteAt
  1672. */
  1673. /* Description: Writes text to Stdout, starting at Row, Col
  1674. *  Returns: The next available Row, wraps from 25 to 1
  1675. */
  1676. WriteAt: procedure expose GV.
  1677.     Parse arg Row, Col, String
  1678.     Call GotoRowCol Row, Col
  1679.     Call Charout , String
  1680.     Row = Row + 1
  1681.     if Row = 26 then Row = 1
  1682. return Row
  1683.  
  1684. /*:VRX         WriteStemAt
  1685. */
  1686. /* Description: Writes text to Stdout, starting at Row, Col
  1687. *  Returns: The next available Row, wraps from 25 to 1
  1688. */
  1689. WriteStemAt: procedure expose GV.
  1690.     parse arg Row, Col, Stem
  1691.  
  1692.     if Row = "" then do
  1693.         Row = 5
  1694.     end
  1695.  
  1696.     if Col = "" then do
  1697.         Col = 1
  1698.     end
  1699.  
  1700.     if right(Stem, 1) <> "." then do
  1701.         Stem = Stem||"."
  1702.     end
  1703.  
  1704.     i = 0
  1705.     Do Value(Stem||0)
  1706.         i = i + 1
  1707.         Row = WriteAt( Row, Col, Value(Stem||i) )
  1708.     end
  1709. return Row
  1710.  
  1711.  
  1712. /*:VRX         ErrorMessage
  1713. */
  1714. /* Description:Display a message in GV._ANSI._ErrorColor
  1715. *  Returns:
  1716. */
  1717. ErrorMessage: procedure expose GV.
  1718.     parse arg messagestem, StartRow, StartCol
  1719.  
  1720.     Call MessageAndWait messagestem,,
  1721.                         StartRow, StartCol,,
  1722.                         GV._ANSI._ErrorColor, GV._ANSI._ScreenColor
  1723.  
  1724.  
  1725. return
  1726.  
  1727. /*:VRX         WarningMessage
  1728. */
  1729. /* Description: Display a message in GV._ANSI._WarningColor
  1730. *  Returns: Nothing
  1731. */
  1732. WarningMessage: procedure expose GV.
  1733.  
  1734.     parse arg messagestem, StartRow, StartCol
  1735.  
  1736.     Call MessageAndWait messagestem,,
  1737.                         StartRow, StartCol,,
  1738.                         GV._ANSI._WarningColor, GV._ANSI._ScreenColor
  1739.  
  1740. return
  1741.  
  1742. /*:VRX         PromptMessage
  1743. */
  1744. /* Description: Propt for user input. Allows Title, Message and Prompt
  1745. *  Returns: Response
  1746. *
  1747. *
  1748. */
  1749. PromptMessage: procedure expose GV.
  1750.  
  1751.     /* Get parameters
  1752.     */
  1753.     Parse arg MsgStem, Title, Prompt, MsgRow,,
  1754.               MsgCol, TitleRow, TitleCol, PromptRow, PromptCol
  1755.  
  1756.     /* Assign some defaults
  1757.     */
  1758.     if MsgCol    = "" then MsgCol    = 5
  1759.     if MsgRow    = "" then MsgRow    = 3
  1760.     if TitleRow  = "" then TitleRow  = 1
  1761.     if PromptCol = "" then PromptCol = MsgCol
  1762.  
  1763.     /* Create the Title
  1764.     */
  1765.     If Title <> "" then do
  1766.         If TitleCol = "" then do
  1767.             Title  = Center(Title,80)
  1768.             TitleCol = 1
  1769.         end
  1770.  
  1771.         /* Put up the Title
  1772.         */
  1773.         Call WriteAt TitleRow,TitleCol,Title
  1774.     end
  1775.  
  1776.     /* Put up the message
  1777.     */
  1778.     if MsgStem \== "" then do
  1779.         Call WriteStemAt MsgRow,MsgCol,MsgStem
  1780.     end
  1781.  
  1782.     /* Create the Prompt
  1783.     */
  1784.     If Prompt <> "" then do
  1785.         If PromptRow = "" then do
  1786.             PromptRow  = MsgRow + Value(MsgStem||0) + 1
  1787.         end
  1788.  
  1789.         /* Put up the Prompt
  1790.         */
  1791.         Call WriteAt PromptRow,PromptCol,Prompt
  1792.     end
  1793.  
  1794.     /* Get a response
  1795.     */
  1796.     Pull Response
  1797.  
  1798.     /* Clear the screen
  1799.     */
  1800.     Call CLS
  1801. return Response
  1802.  
  1803. /*:VRX         MessageAndWait
  1804. */
  1805. /* Description: Display a message and wait for a key
  1806. *  Returns: Row after the message
  1807. */
  1808. MessageAndWait: procedure expose GV.
  1809.     parse arg messagestem, StartRow, StartCol, Color, RestoreColor
  1810.  
  1811.  
  1812.     if StartRow = "" then do
  1813.         StartRow = 5
  1814.     end
  1815.  
  1816.     if StartCol = "" then do
  1817.         StartCol = 1
  1818.     end
  1819.  
  1820.     /* Set the Screen Color
  1821.     */
  1822.     if Color <> "" then do
  1823.         Say Color
  1824.     end
  1825.  
  1826.     /* Make the color take hold
  1827.     */
  1828.     Call CLS
  1829.     StartRow = WriteStemAt( StartRow, StartCol, messagestem )
  1830.  
  1831.     Call WriteAt 24,StartCol,GV._ANSI._PauseMsg
  1832.     Call GetResponse
  1833.     if RestoreColor <> '' then do
  1834.         Call Charout RestoreColor
  1835.     end
  1836. return StartRow
  1837.  
  1838. /*:VRX         Menu
  1839. */
  1840. /* Description: Routine to place a Menu on the screen.
  1841. *
  1842. *  Menu Structure: Menuname.Selections : Single Characters for selection.
  1843. *                  MenuName.Functions  : Rexx Routine name coresponding to
  1844. *                                        each above selection.
  1845. *                  MenuName.0          : Number of Selections.
  1846. *                  Menuname.(1 to MenuName.0) : String for each selection.
  1847. *  Note: Menuname must begin with GV.
  1848. *  Note: You Must Provide a routine called Help
  1849. */
  1850. Menu: procedure expose GV.
  1851.     parse arg MenuName, Prompt, Title, HighLight, Clear, EscapeChars
  1852.     option = ""
  1853.     /* Do until we get the Escape sequence
  1854.     */
  1855.     option = ""
  1856.     do while pos(option,EscapeChars) == 0
  1857.         /* Put up the actual menu and get a selection
  1858.         */
  1859.         option = ShowMenu(MenuName, Prompt,,
  1860.                           Title, HighLight, Clear, EscapeChars )
  1861.  
  1862.         /* See if this Selection is in our list of valid selections
  1863.         */
  1864.         position = wordpos(option, Value(MenuName||"_Selections"))
  1865.         options = words(Value(MenuName||"_Selections"))
  1866.  
  1867.         /* By default we Clear the Screen
  1868.         */
  1869.         Clear = 1
  1870.         select
  1871.             /* Handle Help
  1872.             */
  1873.             when length(option) = 2 then do
  1874.             Key = Right(option,1)
  1875.                 Select
  1876.                     /* Up
  1877.                     */
  1878.                     when Key = GV._ANSI._UP then do
  1879.                         HighLight = HighLight - 1
  1880.                         if HighLight < 1 then do
  1881.                             HighLight = options
  1882.                         end
  1883.                         Clear = 0
  1884.                     end
  1885.  
  1886.                     /* Down
  1887.                     */
  1888.                     when Key = GV._ANSI._Down then do
  1889.                         HighLight = HighLight + 1
  1890.                         if HighLight > options then do
  1891.                             HighLight = 1
  1892.                         end
  1893.                         Clear = 0
  1894.                     end
  1895.  
  1896.                     /* F1
  1897.                     */
  1898.                     when Key = GV._ANSI._Help then do
  1899.                         Call Help
  1900.                     end
  1901.                     otherwise do
  1902.                         Nop
  1903.                     end
  1904.                 end
  1905.             end
  1906.  
  1907.             /* Handle hitting Enter on a selected item.
  1908.             */
  1909.             when option = GV._ANSI._Enter then do
  1910.                 option = HighLight
  1911.                 position = wordpos(option, Value(MenuName||"_Selections"))
  1912.                 if position <> 0 then do
  1913.                     /* It is valid, so call the appropriate function
  1914.                     */
  1915.                     Call CLS
  1916.                     interpret "Call "word(Value(MenuName||"_Functions"), position)
  1917.                 end
  1918.             end
  1919.  
  1920.             /* Handle a Number key being selected
  1921.             */
  1922.             when position <> 0 then do
  1923.                 /* It is valid, so call the appropriate function
  1924.                 */
  1925.                 Call CLS
  1926.                 interpret "Call "word(Value(MenuName||"_Functions"), position)
  1927.             end
  1928.             /* Invalid Selection, Beep
  1929.             */
  1930.             otherwise do
  1931.                 call ErrorBeep
  1932.             end
  1933.         end
  1934.     end
  1935. return Option
  1936.  
  1937. /*:VRX         ShowMenu
  1938. */
  1939. /* Description: Displays a Menu on the Screen.
  1940. *
  1941. *  Menu Structure: Menuname.Selections : Single Characters for selection.
  1942. *                  MenuName.Functions  : Rexx Routine name coresponding to
  1943. *                                        each above selection.
  1944. *                  MenuName.0          : Number of Selections.
  1945. *                  Menuname.(1 to MenuName.0) : String for each selection.
  1946. *  Note: Menuname must begin with GV.
  1947. */
  1948. ShowMenu: procedure expose GV.
  1949.     parse arg MenuName, Prompt, Title, HighLight, Clear, EscapeChars
  1950.  
  1951.     /* If no Highlight picked, use 1
  1952.     */
  1953.     if HighLight = "" then do
  1954.         HighLight = 1
  1955.     end
  1956.  
  1957.     /* Menu starts here
  1958.     */
  1959.     Row = 4 ; Col = 2
  1960.  
  1961.     /* Get the menu choice strings
  1962.     */
  1963.     Choices = Value(MenuName||"_Selections")
  1964.  
  1965.     /* Only do this if we are Clearing the screen
  1966.     */
  1967.     if Clear = 1 then do
  1968.         /* Set the Screen Color
  1969.         */
  1970.         Say GV._ANSI._ScreenColor
  1971.  
  1972.         /* Make the color take hold
  1973.         */
  1974.         Call CLS
  1975.  
  1976.         /* Center title in the Top of the Menu and display it.
  1977.         */
  1978.         TopBar = GV._ANSI._TopBar
  1979.         if length(title) <> 0 then do
  1980.             TopBar = overlay(Title,TopBar,(length(TopBar) - length(Title))%2)
  1981.         end
  1982.         Call WriteAt Row,Col, GV._ANSI._BoldOn GV._ANSI._WhiteOnBlue
  1983.         Row = WriteAt(Row, Col,TopBar )
  1984.  
  1985.         /* Add a blank line for readability
  1986.         */
  1987.         Row = WriteAt(Row, Col,GV._ANSI._LeftSide||Copies(" ",75)||GV._ANSI._RightSide||GV._ANSI._Shadow||" ")
  1988.     end
  1989.     else do
  1990.         Row = Row + 2
  1991.     end
  1992.  
  1993.     /* Display the Menu text
  1994.     */
  1995.     do i = 1 to Value(MenuName||"0")
  1996.  
  1997.         /* Handle a HighLighted Item
  1998.         */
  1999.         if i = HighLight then do
  2000.             /* Each row consists of the LeftSide, some space, the selection string
  2001.             *  a close paren, a space, the menu text, some more space, and the
  2002.             *  right side
  2003.             */
  2004.             Row = WriteAt(Row, Col,,
  2005.                       GV._ANSI._MenuColor||,
  2006.                       GV._ANSI._BoldOn||,
  2007.                       GV._ANSI._LeftSide||,
  2008.                       Copies(" ",10)||,
  2009.                       GV._ANSI._BoldOn||,
  2010.                       GV._ANSI._Shadow||,
  2011.                       word(Choices,i)")"||,
  2012.                       GV._ANSI._BoldOff||,
  2013.                       GV._ANSI._Shadow||,
  2014.                       left(Value(MenuName||i),53)||,
  2015.                       GV._ANSI._BoldOn||,
  2016.                       GV._ANSI._MenuColor||,
  2017.                       Copies(" ",10)||GV._ANSI._RightSide||GV._ANSI._Shadow||" " )
  2018.         end
  2019.         /* Handle a non-HighLighted item.
  2020.         */
  2021.         else do
  2022.             /* Each row consists of the LeftSide, some space, the selection string
  2023.             *  a close paren, a space, the menu text, some more space, and the
  2024.             *  right side
  2025.             */
  2026.             Row = WriteAt(Row, Col,,
  2027.                       GV._ANSI._MenuColor||,
  2028.                       GV._ANSI._BoldOn||,
  2029.                       GV._ANSI._LeftSide||,
  2030.                       Copies(" ",10)||,
  2031.                       GV._ANSI._BoldOn||,
  2032.                       word(Choices,i)")"||,
  2033.                       GV._ANSI._BoldOff||,
  2034.                       GV._ANSI._MenuColor||,
  2035.                       left(Value(MenuName||i),53)||,
  2036.                       GV._ANSI._BoldOn||,
  2037.                       Copies(" ",10)||GV._ANSI._RightSide||GV._ANSI._Shadow||" " )
  2038.         end
  2039.     end
  2040.  
  2041.     /* Only do this if clearing the screen
  2042.     */
  2043.     if Clear = 1 then do
  2044.         /* Another blank row for readability
  2045.         */
  2046.         Row = WriteAt(Row, Col, GV._ANSI._BoldOn||GV._ANSI._MenuColor||GV._ANSI._LeftSide||Copies(" ",75)||GV._ANSI._RightSide||GV._ANSI._Shadow||" ")
  2047.  
  2048.         /* And the bottom of the menu box
  2049.         */
  2050.         Row = WriteAt(Row, Col, GV._ANSI._BoldOn||GV._ANSI._MenuColor||GV._ANSI._BottomBar||GV._ANSI._Shadow||" ")
  2051.  
  2052.         /* Add the bottom Shadow
  2053.         */
  2054.         Row = WriteAt(Row, Col+1,GV._ANSI._Shadow||Copies("▄",77))
  2055.  
  2056.         /* Put up Help Message
  2057.         */
  2058.         Call WriteAt 25,70,GV._ANSI._ScreenColor||GV._ANSI._F1ForHelp
  2059.  
  2060.         /* Now the prompt and user response.
  2061.         */
  2062.         Row = WriteAt(Row+1, Col, GV._ANSI._ScreenColor||Prompt||" " )
  2063.     end
  2064.  
  2065.     /* Get the users response
  2066.     */
  2067.     Call WriteAt 25,80,GV._ANSI._NoCursor
  2068.     Option=GetResponse()
  2069.  
  2070.     Call WriteAt 1,1,GV._ANSI._ScreenColor
  2071. return Option
  2072.  
  2073.  
  2074. /*:VRX         GetResponse
  2075. */
  2076. /* Description: Get a Key and handle Extended key sequences
  2077. *
  2078. */
  2079. GetResponse: procedure expose GV.
  2080.     /* Get a key
  2081.     */
  2082.     key = PrldGetKey("NOECHO")
  2083.  
  2084.     /* If it is extended, get the next key
  2085.     */
  2086.     if key = '00'x | key = 'E0'x then do
  2087.         key ='0'||PrldGetKey("NOECHO")
  2088.      end
  2089. return key
  2090.  
  2091. /*:VRX         Pause
  2092. */
  2093. /* Description: Simulate system Pause message.
  2094. *
  2095. */
  2096. Pause: procedure expose GV.
  2097.     Call Charout , GV._ANSI._PauseMsg
  2098.     Call GetResponse
  2099. return
  2100.  
  2101.  
  2102. /*:VRX         ErrorBeep
  2103. */
  2104. /* Description: Beep on an error
  2105. *
  2106. */
  2107. ErrorBeep: procedure expose GV.
  2108.     Call Beep 880,400
  2109. return
  2110.  
  2111.  
  2112.  
  2113. /*:VRX         ANSITranslation
  2114. */
  2115. /* Description: Initializes ANSI Package Messages
  2116. *
  2117. */
  2118. ANSITranslation: procedure expose GV.
  2119.  
  2120.     /* Pause Message
  2121.     */
  2122.     GV._ANSI._PauseMsg    = "Press any key when ready . . ."
  2123.  
  2124.     /* Help Prompt Message
  2125.     */
  2126.     GV._ANSI._F1ForHelp   = "F1=Help"
  2127.  
  2128. return
  2129.  
  2130. /* End of included file */
  2131.  
  2132. /* Including file 'makecmsg.vrs' */
  2133.  
  2134. /*:VRX         Make_CurrentMessage
  2135. */
  2136. /* Description: Break up the Message into separate lines (crlf delimted)
  2137. *               Returns with GV._CurrentMessage.0 = # or lines
  2138. *                            GV._CurrentMessage.n = line n
  2139. */
  2140. Make_CurrentMessage: procedure expose GV.
  2141.     Parse arg message
  2142.     j=0
  2143.  
  2144.     /* Break up the long string message into an array of CRLF separated lines
  2145.     */
  2146.     do while message <> ""
  2147.        j = j + 1
  2148.        parse var message l "0D0A"x message
  2149.        GV._CurrentMessage.j = l
  2150.     end
  2151.     /* Set the array count
  2152.     */
  2153.     GV._CurrentMessage.0 = j
  2154. return j
  2155.  
  2156. /* End of included file */
  2157.  
  2158. /* Including file 'REPL-ALL.VRS' */
  2159.  
  2160. /*:VRX */
  2161. /*
  2162. *
  2163. * ReplaceAll: replaces all occurances of from with to in string.
  2164. * returns: changed string
  2165. *
  2166. */
  2167. ReplaceAll: procedure
  2168.     parse arg from, to, string, case
  2169.  
  2170.     accum = ""
  2171.     left = string
  2172.  
  2173.     do while length(left) > 0
  2174.         if case = "" then do
  2175.             p = pos(translate(from), translate(left))
  2176.         end
  2177.         else do
  2178.             p = pos(from, left)
  2179.         end
  2180.         if p = 0 then do
  2181.             accum = accum||left
  2182.             left = ""
  2183.         end
  2184.         else do
  2185.             accum = accum||left(left,p-1)||to
  2186.             if p < length(left) then do
  2187.                 left = substr(left, p+length(from))
  2188.             end
  2189.             else do
  2190.                 left = ""
  2191.             end
  2192.         end
  2193.     end
  2194. return accum
  2195.  
  2196. /* End of included file */
  2197.  
  2198. /* Including file 'TRANSSTR.VRS' */
  2199.  
  2200. /*:VRX         TranslateString
  2201. */
  2202. TranslateString: Procedure
  2203.  
  2204.    /*
  2205.    *  This routine takes a MRI string and replaces all occurances
  2206.    *  of a separator char with a filler string. The separator char
  2207.    *  is the first char of the "insertItems" parameter.
  2208.    *
  2209.    *  Where:  str = some MRI string with a unique separator character
  2210.    *
  2211.    *          insertItems = a string of filler items separated by the
  2212.    *                        separator char defined in position 1.
  2213.    *
  2214.    *  Examples: str = "The days of the weekend are ! and !"
  2215.    *            insertItems = "!Sat!Sun"
  2216.    *            RESULT = "The days of the weekend are Sat and Sun"
  2217.    *
  2218.    *            str = "The days of the weekend are # and #"
  2219.    *            insertItems = "!Sat!Sun"
  2220.    *            RESULT = "The days of the weekend are # and #"
  2221.    *
  2222.    */
  2223.  
  2224.     Parse Arg str, insertItems;
  2225.  
  2226.     new_str = str
  2227.  
  2228.     /* Determine Filler List
  2229.     */
  2230.     FillerList. = ""
  2231.     i = 0
  2232.     Replacement_Char_Identifier = LEFT(insertItems,1)
  2233.     next_identifier = POS(Replacement_Char_Identifier,insertItems)
  2234.     do while(next_identifier \= 0)
  2235.         i = i + 1
  2236.         insertItems = Substr(insertItems,next_identifier+1)
  2237.         next_identifier = POS(Replacement_Char_Identifier,insertItems)
  2238.         if (next_identifier \= 0) then do
  2239.             FillerList.i = Substr(insertItems,1,next_identifier-1)
  2240.         end
  2241.         else do
  2242.             FillerList.i = Substr(insertItems,1)
  2243.         end
  2244.     end
  2245.     FillerList.0 = i
  2246.  
  2247.     /* Insert filler list items into input string
  2248.     */
  2249.     cnt = 1
  2250.     next_identifier = POS(Replacement_Char_Identifier,new_str)
  2251.     do while((next_identifier \= 0) & (cnt <= FillerList.0))
  2252.         Select
  2253.             when(next_identifier == 0) then do
  2254.                 nop
  2255.             end
  2256.             when(next_identifier == 1) then do
  2257.                 frontpart = ""
  2258.                 backpart = Substr(new_str,2)
  2259.             end
  2260.             when(next_identifier == LENGTH(new_str)) then do
  2261.                 frontpart = Substr(new_str,1,LENGTH(new_str)-1)
  2262.                 backpart = ""
  2263.             end
  2264.             otherwise do
  2265.                 frontpart = Substr(new_str,1,next_identifier -1)
  2266.                 backpart = Substr(new_str,next_identifier+1)
  2267.             end
  2268.         end
  2269.         new_str = frontpart||FillerList.cnt||backpart
  2270.         next_identifier = POS(Replacement_Char_Identifier,new_str)
  2271.         cnt = cnt + 1
  2272.     end
  2273.  
  2274. return new_str
  2275.  
  2276.  
  2277. /* End of included file */
  2278.  
  2279. /* Including file 'LOADFNCS.VRS' */
  2280.  
  2281. /*:VRX         BuildExternalFuncsList
  2282. */
  2283. BuildExternalFuncsList: Procedure Expose GV.
  2284.  
  2285.     /* External Libraries Definitions
  2286.     *   - Modification to the List field is minimal required Change.
  2287.     *   - The syntax for the List field is that of a SPACE delimited
  2288.     *     string of indices into the GV.ExternalFuncs array.
  2289.     *   - This format is used by the LoadExternalFuncs routine
  2290.     */
  2291.  
  2292.     GV._ExternalFuncs._List = '1 2 3 4 5 6 7'
  2293.     GV._ExternalFuncs._Name.1         = "SysLoadFuncs"
  2294.     GV._ExternalFuncs._Module.1       = "RexxUtil"
  2295.     GV._ExternalFuncs._Procedure.1    = "SysLoadFuncs"
  2296.     GV._ExternalFuncs._ProcParamStr.1 = ""
  2297.     GV._ExternalFuncs._Name.2         = "RxLoadFuncs"
  2298.     GV._ExternalFuncs._Module.2       = "RxUtils"
  2299.     GV._ExternalFuncs._Procedure.2    = "RxLoadFuncs"
  2300.     GV._ExternalFuncs._ProcParamStr.2 = "QUIET"
  2301.     GV._ExternalFuncs._Name.3         = "RexxLibRegister"
  2302.     GV._ExternalFuncs._Module.3       = "RexxLib"
  2303.     GV._ExternalFuncs._Procedure.3    = "RexxLibRegister"
  2304.     GV._ExternalFuncs._ProcParamStr.3 = ""
  2305.     GV._ExternalFuncs._Name.4         = "W_Register"
  2306.     GV._ExternalFuncs._Module.4       = "RxWin30"
  2307.     GV._ExternalFuncs._Procedure.4    = "RxWindow"
  2308.     GV._ExternalFuncs._ProcParamStr.4 = ""
  2309.     GV._ExternalFuncs._Name.5         = "mciRxInit"
  2310.     GV._ExternalFuncs._Module.5       = "MCIAPI"
  2311.     GV._ExternalFuncs._Procedure.5    = "mciRxInit"
  2312.     GV._ExternalFuncs._ProcParamStr.5 = ""
  2313.     GV._ExternalFuncs._Name.6         = "PrldLoadFuncs"
  2314.     GV._ExternalFuncs._Module.6       = "PrldUtil"
  2315.     GV._ExternalFuncs._Procedure.6    = "PrldLoadFuncs"
  2316.     GV._ExternalFuncs._ProcParamStr.6 = ""
  2317.     GV._ExternalFuncs._Name.7         = "PrldLoadFuncs"
  2318.     GV._ExternalFuncs._Module.7       = "PrldLite"
  2319.     GV._ExternalFuncs._Procedure.7    = "PrldLoadFuncs"
  2320.     GV._ExternalFuncs._ProcParamStr.7 = ""
  2321.     
  2322. return
  2323.     
  2324. /*:VRX         LoadExternalFuncs
  2325. */
  2326. LoadExternalFuncs: Procedure Expose GV.
  2327.  
  2328.     parse arg lefstr;
  2329.  
  2330.     call BuildExternalFuncsList 
  2331.     if (lefstr <> "") then do
  2332.         GV._ExternalFuncs._List = lefstr
  2333.     end
  2334.  
  2335.     indexlst = GV._ExternalFuncs._List
  2336.     do while( indexlst <> "")
  2337.         parse var indexlst z indexlst
  2338.         if (rxfuncquery( GV._ExternalFuncs._Name.z )) then do
  2339.             if (rxfuncadd( GV._ExternalFuncs._Name.z,,
  2340.                            GV._ExternalFuncs._Module.z,,
  2341.                            GV._ExternalFuncs._Procedure.z) > 0) then do
  2342.                 InsertItems = GV._Separator||GV._ExternalFuncs._Name.z
  2343.                 ErrMsg = TranslateString( GV._MissingDlls, InsertItems )
  2344.                 call DisplayError GV._ErrorTitle, ErrMsg, 0
  2345.             end
  2346.             else Interpret 'call '||GV._ExternalFuncs._Name.z GV._ExternalFuncs._ProcParamStr.z
  2347.         end
  2348.         else Interpret 'call '||GV._ExternalFuncs._Name.z GV._ExternalFuncs._ProcParamStr.z
  2349.     end
  2350.  
  2351. return
  2352.  
  2353.  
  2354. /* End of included file */
  2355.  
  2356.