Menu

#351 ERR not retained

open
nobody
None
2012-10-09
2008-02-23
Andy Hughes
No

According to documentation, ERR is 'reset by Resume or Resume Next', however it is not available in a Print Statement.

(I am submitting bug #2 from this program under another bug report)

type x128Type
a as integer
b as integer
c(125) as integer
end Type
Type x127Type
a as integer
b as integer
c(124) as Integer
end Type

Dim x128 as x128Type, x127 as x127Type, fName as String, fNum as Integer, iRec as Integer, iErrNo as Integer

fName = "BugTest"
fNum = FreeFile

Print "Bug #1 - documentation says ERR is reset by Resume or Resume Next, however value is not accessible in a Print statement."
Print "Bug #2 - opened file as 128 (512 bytes), same size as variable x128, but get IO error during put."

Open fName For Random As #fNum Len=128
If ERR<>0 Then Error(ERR)

Print "LOF(fNum):"; LOF(fNum);" sizeOf(x128):"; sizeOf(x128)

for iRec = 1 to 1
Put #fNum, iRec, x128
If ERR<>0 then
iErrNo = ERR
Print "ERR: "; ERR; " iErrNo:"; iErrNo
End If
Next

Close #fNum
fNum = 0
fNum = FreeFile
Kill fname
if ERR<>0 then Error(ERR)

Discussion

  • Yeti Foot

    Yeti Foot - 2008-04-08

    Logged In: YES
    user_id=1223492
    Originator: NO

    Hi, the problem that is happening, is that FB's print string routine resets the ERR. When you do

    Print "ERR: "; ERR; " iErrNo:"; iErrNo

    It kind of does this

    Print "ERR: ";
    Print ERR;
    Print " iErrNo:";
    Print iErrNo

    So by the time you call Print ERR, ERR has been reset by the previous line. This behaviour is noted at
    http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgErr and although a little unfortunate, I do not see it as possible to fix, nor a bug as such.

    I am unsure about the PUT problem, will look into that more

     
  • Yeti Foot

    Yeti Foot - 2008-04-08

    Logged In: YES
    user_id=1223492
    Originator: NO

    OK, I see the PUT problem is closed elsewhere

     
  • Ruben

    Ruben - 2008-08-17

    Logged In: YES
    user_id=1399002
    Originator: NO

    Should we not set ERR when print is writing to the screen? (as opposed to a file)

    I can't think off hand how print (to screen) could fail, as opposed to into a file...

     

Log in to post a comment.

MongoDB Logo MongoDB