[futurebasic] Re: [FB] ON ERROR FN

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1999 : Group Archive : Group : All Groups

From: Mel & Carol Patrick <mel@...>
Date: Sat, 1 May 1999 11:31:25 -0700
>It would seem that FB should always resume processing at the line of
>code immediately following the offending statement (in this case OPEN
>"R".....), but it doesn't .
>
>Anyone know where FB resumes processing after a disk error is
>encountered & handled with ON ERROR FN?

After a lot of testing in trying to find this out myself, I managed to get
a solid routine working that I use for my programs prefs (and it handles
any disk errors, like file not found). I snipped the two functions that do
the magic and you can read the comments to see where things go before and
after.


LOCAL FN HandleDiskError:'          handles the disk errors we can encounter
  SELECT ERROR AND 255:'                      mask out the error code itself
    CASE _fileNotFound
      FN LoadDefaultPrefs:'                           load the default prefs
      OSErr=FN fndPrefFile(prefVol):'     find the preferences volume for us
      FN PrefsWrite:'                               go create the prefs file
  END SELECT
  ERROR=_noErr:'                                   reset the error condition
END FN
'
LOCAL FN PrefsRead
  ON ERROR GOSUB 65535:'                          enable our own error testing
  ON ERROR FN HandleDiskError:'       use my routine for handling a disk error
  DEF OPEN "PrefWPRO":'                                       type and creator
  OPEN "I",#1,prefsName$,,prefVol:'                         read our pref file
  fileSize=LOF(1,1):'                               get the file size in bytes
  LONG IF fileSize<>_prefSize:'      did we change the size of the prefs file?
    CLOSE #1:'                                              close the file now
    FN LoadDefaultPrefs:'                               load the default prefs
    OSErr=FN fndPrefFile(prefVol):'         find the preferences volume for us
    FN PrefsWrite:'                                   go create the prefs file
    OPEN "I",#1,prefsName$,,prefVol:'                       read our pref file
  END IF
  READ FILE #1,@ListWindow,varPrefSize:'             read in  simple variables
  READ FILE #1,@appStrings&(0),76:'                           read this in now
  READ FILE #1,@monthTime&(0),52:'                       and then read this in
  CLOSE #1:'                          it resumes here from the error condition
  ON ERROR RETURN:'                                turn off the error checking
END FN

Hope this helps.

Mel Patrick
mel@...