home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1996 February / PCPRO_FEB96.ISO / 3rdparty / tools / library / tooltip2.exe / TIP_SF.CLW < prev    next >
Encoding:
Text File  |  1995-06-01  |  10.9 KB  |  249 lines

  1.                   MEMBER('TIP.clw')
  2. CheckOpen         PROCEDURE(File,OverrideCreate,OverrideOpenMode)
  3.  
  4.   CODE
  5.   IF OMITTED(3)
  6.     OPEN(File,42h)                                !Attempt to open the file
  7.   ELSE
  8.     OPEN(File,OverrideOpenMode)
  9.   END
  10.   CASE ERRORCODE()                                ! and check for errors
  11.   OF NoError                                      !Return if no error
  12.   OROF IsOpenErr                                  ! or if already open.
  13.     DO ProcedureReturn
  14.   OF NoFileErr                                    !If file was not found
  15.     IF OMITTED(2)
  16.     ELSIF OverrideCreate = TRUE
  17.       DO CreateFile
  18.     ELSE
  19.       IF StandardWarning(Warn:CreateError,NAME(File)).
  20.     END
  21.   OF InvalidFileErr                               !Invalid Record Declaration
  22.     IF StandardWarning(Warn:InvalidFile,NAME(File)).
  23.   OF BadKeyErr                                    !Key Files must be rebuilt
  24.     IF StandardWarning(Warn:InvalidKey,NAME(File))
  25.       BUILD(File)                              !Rebuild the key files
  26.     END
  27.     IF ERRORCODE()
  28.       IF StandardWarning(Warn:RebuildError,NAME(File)).
  29.     ELSE
  30.       IF OMITTED(3)
  31.         OPEN(File,42h)                            !Attempt to open the file
  32.       ELSE
  33.         OPEN(File,OverrideOpenMode)
  34.       END
  35.     END
  36.   END                                             !End of Case Structure
  37.   IF ERRORCODE()
  38.     IF StandardWarning(Warn:DiskError,NAME(File)) THEN HALT(0,'Disk Error').
  39.   END
  40.   DO ProcedureReturn
  41. ProcedureReturn ROUTINE
  42.   RETURN
  43. CreateFile ROUTINE
  44.   CREATE(File)                                    !Create the file
  45.   IF ERRORCODE()
  46.     IF ERRORCODE() = 90
  47.       IF StandardWarning(Warn:CreateError,NAME(File)).
  48.     ELSE
  49.       IF StandardWarning(Warn:CreateError,NAME(File)).
  50.     END
  51.   END
  52.   IF OMITTED(3)
  53.     OPEN(File,42h)                                !Attempt to open the file
  54.   ELSE
  55.     OPEN(File,OverrideOpenMode)
  56.   END
  57.   IF ~ERRORCODE()                                 !  And return if it opened
  58.     DO ProcedureReturn
  59.   ELSE
  60.     IF StandardWarning(Warn:CreateOpenError,NAME(File)).
  61.   END
  62.  
  63.  
  64. StandardWarning      FUNCTION(WarningID,WarningText1,WarningText2,WarningText3,WarningText4)
  65. ErrorText            STRING(150),AUTO
  66. ReturnValue          LONG
  67.   CODE
  68.   IF ERRORCODE() <> 90
  69.     ErrorText = CLIP(ERROR()) & ' (' & ERRORCODE() & ')'
  70.   ELSE
  71.     ErrorText = CLIP(FILEERROR()) & ' (' & CLIP(FILEERRORCODE()) & ')'
  72.   END
  73.   CASE WarningID
  74.   OF Warn:InvalidFile
  75.     IF MESSAGE('Error: (' & CLIP(ErrorText) & ') accessing ' |
  76.     & CLIP(WarningText1) & '.  Press OK to end this application.'|
  77.     ,'Invalid File',ICON:Exclamation,Button:OK,BUTTON:OK,0).
  78.     HALT(0,'Invalid File!')
  79.   OF Warn:InvalidKey     
  80.     IF MESSAGE(CLIP(WarningText1) & ' key file is invalid.  Do you '|
  81.     &'want to rebuild the key?','Invalid Key',Icon:Question,|
  82.     Button:Yes+Button:No,Button:Yes,0)=Button:No
  83.       HALT(0,'Invalid Key!')
  84.     ELSE
  85.       RETURN(Button:Yes)
  86.     END
  87.   OF Warn:RebuildError   
  88.     IF MESSAGE('Error: (' & CLIP(ErrorText) & ') repairing key for ' |
  89.     & CLIP(WarningText1) & '.  Press OK to end this application.',|
  90.     'Key Rebuild Error',ICON:Exclamation,Button:OK,BUTTON:OK,0).
  91.     HALT(0,'Error Rebuilding Key!')
  92.   OF Warn:CreateError    
  93.     IF MESSAGE('Error: (' & CLIP(ErrorText) & ') creating ' |
  94.     & CLIP(WarningText1) & '.  Press OK to end this application.',|
  95.     'File Creation Error',ICON:Exclamation,Button:OK,BUTTON:OK,0).
  96.     HALT(0,'File Creation Error!')
  97.   OF Warn:CreateOpenError
  98.     IF MESSAGE('Error: (' & CLIP(ErrorText) & ') opening created ' |
  99.     & 'file:' & CLIP(WarningText1) & '.  Press OK to end this application.',|
  100.     'File Creation Error',ICON:Exclamation,Button:OK,BUTTON:OK,0).
  101.     HALT(0,'File Creation Error!')
  102.   OF Warn:ProcedureToDo  
  103.     RETURN(MESSAGE('The Procedure ' & CLIP(WarningText1) & ' has not '|
  104.     &'been defined.','Procedure not defined',ICON:Exclamation,|
  105.     Button:OK,BUTTON:OK,0))
  106.   OF Warn:BadKeyedRec
  107.     RETURN(MESSAGE('Unable to read keyed record.  Error: ' |
  108.     & CLIP(ErrorText) & '.  Insert Aborted',ICON:Exclamation,|
  109.     Button:OK,Button:OK,0))
  110.   OF Warn:OutOfRangeHigh
  111.     RETURN(MESSAGE('The value of ' & CLIP(WarningText1) & ' must'|
  112.     &' be lower than ' & CLIP(WarningText2) & '.','Range Error',|
  113.     ICON:Exclamation,Button:OK,Button:OK,0))
  114.   OF Warn:OutOfRangeLow  
  115.     RETURN(MESSAGE('The value of ' & CLIP(WarningText1) & ' must be'|
  116.     &' higher than ' & CLIP(WarningText2) & '.','Range Error',|
  117.     ICON:Exclamation,Button:OK,Button:OK,0))
  118.   OF Warn:OutOfRange     
  119.     RETURN(MESSAGE('The value of ' & CLIP(WarningText1) & ' must be '|
  120.     &'between ' & CLIP(WarningText2) & ' and ' & CLIP(WarningText3) |
  121.     & '.','Range Error',ICON:Exclamation,Button:OK,Button:OK,0))
  122.   OF Warn:NotInFile
  123.     RETURN(MESSAGE('The value for ' & CLIP(WarningText1) & ' must be '|
  124.     &'found in the ' & CLIP(WarningText2) & ' file.','Field Contents '|
  125.     &'Error',ICON:Exclamation,Button:OK,Button:OK,0))
  126.   OF Warn:RestrictUpdate 
  127.     RETURN(MESSAGE('This record is referenced from the file '|
  128.     & CLIP(WarningText1) & '.  Linking field(s) have been restricted'|
  129.     & ' from change and have been reset to original values.',|
  130.     'Referential Integrity Update Error',ICON:Exclamation,|
  131.     Button:OK,Button:OK,0))
  132.   OF Warn:RestrictDelete 
  133.     RETURN(MESSAGE('This record is referenced from the file '|
  134.     & CLIP(WarningText1) & '.  This record cannot be deleted while'|
  135.     & ' these references exist.','Referential Integrity Delete Error'|
  136.     ,ICON:Exclamation,Button:OK,Button:OK,0))
  137.   OF Warn:InsertError
  138.     RETURN(MESSAGE('An error was experienced during the update of'|
  139.     & ' record.  Error: ' & CLIP(ErrorText) & '.'|
  140.     ,'Record Insert Error'|
  141.     ,ICON:Exclamation,Button:OK,Button:OK,0))
  142.   OF Warn:RIUpdateError
  143.     IF ERRORCODE()
  144.       RETURN(MESSAGE('An error (' & CLIP(ErrorText) & ') was experienced'|
  145.       &' when attempting to update a record from the file.  Probable Cause: ' |
  146.       & CLIP(WarningText1) & '.','Update Operation Error',Icon:Exclamation,|
  147.       Button:OK,Button:OK,0))
  148.     ELSE
  149.       RETURN(MESSAGE('This record was changed by another station.'|
  150.       ,'Update Operation Error',Icon:Exclamation,|
  151.       Button:OK,Button:OK,0))
  152.     END
  153.   OF Warn:UpdateError
  154.     RETURN(MESSAGE('An error was experienced changing this record.  '|
  155.     &'Do you want to try to save again?','Record Update Error',|
  156.     Icon:Exclamation,Button:Yes+Button:No+Button:Cancel,Button:Cancel,0))
  157.   OF Warn:RIDeleteError
  158.     RETURN(MESSAGE('An error (' & CLIP(ErrorText) & ') was experienced'|
  159.     &' when attempting to delete a record from the file ' |
  160.     & CLIP(WarningText1) & '.','Delete Operation Error',Icon:Exclamation,|
  161.     Button:OK,Button:OK,0))
  162.   OF Warn:DeleteError    
  163.     RETURN(MESSAGE('An error was experienced deleting this record.  '|
  164.     &'Do you want to try to save again?','Record Update Error',|
  165.     Icon:Exclamation,Button:Yes+Button:No+Button:Cancel,Button:Cancel,0))
  166.   OF Warn:InsertDisabled 
  167.     RETURN(MESSAGE('This procedure was called to insert a record, '|
  168.     & 'however inserts are not allowed for this procedure.  Press OK '|
  169.     & 'to return to the calling procedure','Invalid Request',|
  170.     Icon:Exclamation,Button:OK,Button:OK,0))
  171.   OF Warn:UpdateDisabled
  172.     RETURN(MESSAGE('This procedure was called to change a record, '|
  173.     & 'however changes are not allowed for this procedure.  Press OK '|
  174.     & 'to return to the calling procedure','Invalid Request',|
  175.     ICON:Exclamation,Button:OK,Button:OK,0))
  176.   OF Warn:DeleteDisabled 
  177.     RETURN(MESSAGE('This procedure was called to delete a record, '|
  178.     & 'however deletions are not allowed for this procedure.  Press OK '|
  179.     & 'to return to the calling procedure','Invalid Request',|
  180.     ICON:Exclamation,Button:OK,Button:OK,0))
  181.   OF Warn:NoCreate       
  182.     IF MESSAGE('The File ' & CLIP(WarningText1) & 'was not found, '|
  183.     &'and creation of the file is not allowed.  Press OK to end '|
  184.     &'this application.','File Creation Not Allowed',ICON:Exclamation,|
  185.     Button:OK,BUTTON:OK,0)
  186.       HALT(0,'File Creation Error!')
  187.     END
  188.   OF Warn:ConfirmCancel  
  189.     RETURN(MESSAGE('Are you sure you want to cancel?'|
  190.     ,'Update Cancelled',ICON:Question,Button:Yes+Button:No,|
  191.     Button:No,0))
  192.   OF Warn:DuplicateKey
  193.     RETURN(MESSAGE('Adding this record creates a duplicate entry '|
  194.     &'for the key:' & CLIP(WarningText1),'Duplicate Key Error',|
  195.     ICON:Exclamation,Button:OK,Button:OK,0))
  196.   OF Warn:AutoIncError
  197.     RETURN(MESSAGE('Attempts to automatically number this record have '|
  198.     &'failed.  Error: ' & CLIP(ErrorText) & '.',|
  199.     'Auto Increment Error',Icon:Exclamation,Button:Cancel+Button:Retry,|
  200.     Button:Cancel,0))
  201.   OF Warn:FileLoadError
  202.     RETURN(MESSAGE(CLIP(WarningText1) & ' File Load Error.  '|
  203.     &'Error: ' & CLIP(ErrorText) & '.','File Load Error',ICON:Exclamation,|
  204.     Button:OK,Button:OK,0))
  205.   OF Warn:ConfirmCancelLoad
  206.     RETURN(MESSAGE('Are you certain you want to stop loading ' |
  207.     & CLIP(WarningText1) & '?','Cancel Request',|
  208.     ICON:Question,Button:OK+Button:Cancel,Button:Cancel,0))
  209.   OF Warn:FileZeroLength
  210.     RETURN(MESSAGE(CLIP(WarningText1) & ' File Load Error.  '|
  211.     &'The file you''ve requested contains no text.','File Load Error',|
  212.     ICON:Exclamation,Button:OK,Button:OK,0))
  213.   OF Warn:EndOfASCIIQueue
  214.     IF WarningText1 = 'Down'
  215.       RETURN(MESSAGE('The end of the viewed file was encountered.  '|
  216.       & 'Do you want to start again from the beginning?',|
  217.       'End of File Error',ICON:Question,Button:Yes+Button:No,Button:Yes,0))
  218.     ELSE
  219.       RETURN(MESSAGE('The beginning of the viewed file was encountered.  '|
  220.       & 'Do you want to start again from the end of the file?',|
  221.       'Beginning of File Error',ICON:Question,Button:Yes+Button:No,|
  222.       Button:Yes,0))
  223.     END
  224.   OF Warn:DiskError
  225.     RETURN(MESSAGE('File (' & CLIP(WarningText1) & ') could not be '|
  226.     & 'opened.  Error: ' & CLIP(ErrorText) & '.','File Access Error'|
  227.     ,Icon:Exclamation,Button:OK,Button:OK,0))
  228.   OF Warn:ProcessActionError
  229.     IF WarningText1 = 'Put'
  230.       RETURN(MESSAGE('An error was experienced when making changes'|
  231.       & ' to the ' & CLIP(WarningText2) & ' file.  Error: '|
  232.       & CLIP(ErrorText),'Process PUT Error',Icon:Exclamation|
  233.       ,Button:OK,Button:OK,0))
  234.     ELSE
  235.       RETURN(MESSAGE('An error was experienced when deleting a record'|
  236.       & ' from the ' & CLIP(WarningText2) & ' file.  Error: '|
  237.       & CLIP(ErrorText),'Process DELETE Error',Icon:Exclamation|
  238.       ,Button:OK,Button:OK,0))
  239.     END
  240.   OF Warn:StandardDelete
  241.     RETURN(MESSAGE('You''ve selected to delete the highlighted record.  '|
  242.     &'Press OK to confirm deletion of this record.',|
  243.     'Confirm Delete',Icon:Question,Button:OK+Button:Cancel,Button:Cancel,0))
  244.   OF Warn:SaveOnCancel
  245.     RETURN(MESSAGE('Do you want to save the changes to this record?'|
  246.     ,'Update Cancelled',ICON:Question,Button:Yes+Button:No+Button:Cancel,|
  247.     Button:No,0))
  248.   END
  249.