home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / d / d009_2 / 1.ddi / SAMPLES / TRAPS / SAVEUAE2.MS$ / SAVEUAE2.bin
Encoding:
Text File  |  1992-02-26  |  3.7 KB  |  109 lines

  1. '************************** SAVEUAE2.MST ********************************
  2. 'Demonstrates:  Trapping a Windows UAE from a MSTest script
  3. '
  4. 'Required Files: NP.EXE, TOOLHELP.DLL
  5. '
  6. 'Uses: TESTDRVR.EXE built in UAETrap
  7. '
  8. 'Complexity Level: ADVANCED
  9. '
  10. 'Notes: This script runs an invalid version of Windows NotePad, NP.EXE
  11. '       (which is provided with MSTest for use with this sample and
  12. '       should be in the current directory) to demonstrate that this
  13. '       application causes a UAE, and that the UAE can be TRAPed using
  14. '       the built in UAETrap from TESTDRVR.EXE.
  15. '
  16. '       NOTE!: This script requires SHELL.DLL from Windows 3.1 to run.  
  17. '
  18. '************************************************************************
  19.  
  20. '$define W_MENU
  21. '$define W_BUTTON
  22. '$define TESTEVNT
  23. '$Include 'MSTEST.INC'
  24.  
  25. '******************** CODE THAT RUNS WHEN UAE OCCURS ********************
  26.  
  27. TRAP UAETrap From "TESTDRVR.EXE"
  28.     'Tell demo user that UAE occurred.
  29.     DT$ = Mid$(DateTime$,9)
  30.     Print "UAE occurred                          @ " + DT$
  31.     Pause "Entered Trap..." + CRLF + "UAE occurred @ " + DT$ + CRLF + "I'll now save the file as ""Error.txt"""+ CRLF + "       (hit ok)"
  32.  
  33.     'Kill save file if it already exists
  34.     If Exists("Error.Txt") Then
  35.         Kill "Error.Txt"
  36.         End If
  37.  
  38.     'Save the file as ERROR.TXT
  39.     DoKeys "%FSError.Txt{Enter}"
  40.  
  41.     'Log the time of the UAE save
  42.     Print """Error.Txt"" saved                     @ " + Mid$(DateTime$,9)
  43.  
  44. 'Return from TRAP and allow NotePad to be terminated.
  45. End Trap
  46.  
  47.  
  48. '************************* MAIN CODE ************************************
  49.  
  50.     'Turn on and initialize the viewport.
  51.     ViewPort On
  52.     Viewport Clear
  53.  
  54.     'Slow DoKeys down so you can watch.
  55.     QueSetSpeed 10
  56.  
  57.     'Run invalid version of NotePad.
  58.     Print "Starting Note Pad                     @ " + Mid$(DateTime$,9)
  59.     Run "NP.EXE" ,NOWAIT
  60.  
  61.     'Send test to NP.EXE
  62.     DoKeys "Hello Again.{Enter 2}"
  63.     DoKeys "This time when NP.EXE UAEs, you Will not see a UAE dialog.{Enter 2}"
  64.     DoKeys "Before NP.EXE terminates, we will make it save this test as ""Error.Txt""{Enter 2}"
  65.     DoKeys "(Note the current Time to verify the file later){Enter 2}"
  66.     DoKeys "Time Stamp: " + Mid$(DateTime$,9) + "{Enter 2}"
  67.  
  68.     'Cause UAE via HELP-ABOUT
  69.     Print "Causing UAE via HELP-ABOUT            @ " + Mid$(DateTime$,9)
  70.     WMenu "&Help"
  71.     WMenu "&About Notepad..."
  72.     WButtonClick "OK"            'Cause UAE
  73.  
  74.     'TRAP code will execute now
  75.  
  76.     'Exectution resumes here after returning from the TRAP.
  77.     'NP.EXE will have terminated.
  78.  
  79.     'Log termination of NP.EXE
  80.     Print "NP.EXE has termninated due to a UAE   @ " + Mid$(DateTime$,9)
  81.  
  82.     'Check if file was saved
  83.     If Exists("Error.Txt") Then
  84.         Print """Error.Txt"" successfully found        @ " + Mid$(DateTime$,9)
  85.         Pause "NP.EXE has terminated, but the file was saved first." + CRLF + "I'll REstart NotePad and load ""Error.Txt"" to prove it..." + CRLF + CRLF + "           (hit ok)"
  86.     Else
  87.         Pause "It Failed - UAE may not have occurred!" + CRLF + "    (hit ok)"
  88.         End If
  89.  
  90.     'Restart NP.EXE
  91.     Run "NP.EXE", NoWait
  92.  
  93.     'OPEN ERROR.TXT
  94.     WMenu "&File"
  95.     WMenu "&Open..."
  96.     DoKeys "Error.Txt{Enter}"
  97.  
  98.     'Prove that file was saved
  99.     Pause "Note TimeStamp in file as the Proof that it was saved before dying..." + CRLF + CRLF + "Current Time " + Mid$(DateTime$,9) + CRLF + "       (hit ok)"
  100.     Pause "Look at VIEWPORT window for log of events..."
  101.     Pause "End Of Demo!" + CRLF + "NP.EXE will close" + CRLF +"after clicking ok to this dialog..." + CRLF
  102.  
  103.     'Close NP.EXE
  104.     WMenu "&File"
  105.     WMenu "E&xit"
  106.  
  107. END
  108.  
  109.