home *** CD-ROM | disk | FTP | other *** search
/ Total C++ 2 / TOTALCTWO.iso / vfp5.0 / vfp / samples / solution / main.prg < prev    next >
Encoding:
Text File  |  1996-08-21  |  2.0 KB  |  74 lines

  1. *****************************************************
  2. * Main Program for Solution.APP
  3. * Sample Application
  4. *
  5. * Copyright (c) 1990 - 1996 Microsoft Corp.
  6. * 1 Microsoft Way
  7. * Redmond, WA 98052
  8. *
  9. ******************************************************
  10.  
  11. * Change the default directory if run from the Project manager
  12. * and solution.scx cannot be found
  13.  
  14. IF !FILE('solution.scx')
  15.     cCurrentProcedure = SYS(16,1)
  16.     nPathStart = AT(":",cCurrentProcedure)- 1
  17.     nLenOfPath = RAT("\", cCurrentProcedure) - (nPathStart)
  18.      SET DEFAULT TO (SUBSTR(cCurrentProcedure, nPathStart, nLenofPath))
  19. ENDIF
  20.  
  21. * Establish a global error handler.
  22. * The error events associated with objects
  23. * take precedence over ON ERROR routines.
  24.  
  25. cOldError = ON("ERROR")
  26. ON ERROR DO SolutionErrHandle
  27.  
  28. * Run the main form and establish the event loop
  29.  
  30. DO FORM solution
  31. READ EVENTS
  32.  
  33. * Reset the global error handler
  34. ON ERROR &cOldError
  35.  
  36.  
  37. PROCEDURE SolutionErrHandle
  38. LOCAL lnChoice
  39.     #DEFINE ERR_LOC "Error: "
  40.     #DEFINE FILEINUSE_LOC "A form cannot simultaneously be open in design mode and running."
  41.     #DEFINE FILEREADONLY_LOC "One of the necessary files is marked as read-only." + CHR(13) + "Please make sure you have read and write access to the file."
  42.  
  43.     DO CASE
  44.         CASE ERROR() = 3 && File is in use
  45.             =MESSAGEBOX( ERR_LOC + MESSAGE() + CHR(13) + ;
  46.                 FILEINUSE_LOC, 0 + 48)
  47.                 
  48.         CASE ERROR() = 1718 && File is read-only
  49.             =MESSAGEBOX( ERR_LOC + MESSAGE() + CHR(13) + ;
  50.                  FILEREADONLY_LOC, 0 + 48)
  51.             RETRY
  52.         CASE ERROR() = 1881 && Trying to load DE of solution.scx when table is already open
  53.             CLOSE DATA ALL
  54.             DO FORM solution
  55.         OTHERWISE
  56.             lnChoice = MESSAGEBOX(ERR_LOC + ALLTRIM(STR(ERROR())) + CHR(13) + ;
  57.                 MESSAGE(), 1 + 48)
  58.             IF lnChoice = 2 && Cancel
  59.                 ON ERROR &cOldError
  60.                 CLEAR EVENTS
  61.                 CLOSE ALL
  62.                 RELEASE ALL
  63.                 CLEAR ALL
  64.             ENDIF    
  65.     ENDCASE
  66. ENDPROC
  67.  
  68. * Project resolution markers for API functions
  69.  
  70. Procedure MAINHWND
  71. Procedure  _WHTOHWND
  72. Procedure  _WONTOP
  73. Procedure  GetFileVersion
  74.