Error Handler problem

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Error Handler problem

Post by Seb McClouth »

Hey

I'm using NOVIX error handler, which uses the following code in my QBinux.BI-file:

Code: Select all

'CODE STUFF HERE

ON ERROR GOTO OnError
Which runs the following in Handle.BI:

Code: Select all

DEFINT A-Z
'$DYNAMIC
OnError:
IF ERR <> 0 THEN
    IF ERR = 53 THEN
    FileFound = "0"

  ELSEIF ERR = 64 THEN
    FileFound = "0"
    
  ELSEIF ERR = 75 THEN
    PathAccess = "0"
    
  ELSEIF ERR = 76 THEN
    DirFound = "0"
    
  ELSE
    CLOSE
    PRINT "QBinux encounterd an unrecoverable error"
    PRINT "  Error code:"; ERR; " (h"; HEX$(ERR); " b"'; NUM2BITS(ERR, 8); ")"
    PRINT
    PRINT 'cTask
    PRINT 'ErrorMessage
    PRINT
    SYSTEM
  END IF
  PRINT "RESUME":RESUME NEXT
END IF
For some odd reason it doesn't RESUME NEXT...

It occures when I try to create a new dir in the NoViXFileSystem. The code to make a directory is a following:

Code: Select all

SUB MakDir (dir AS STRING)
odir$ = CurDir
dirn$ = WorkPath(dir)
IF dirn$ = "DNF" THEN CurDir = odir$: EXIT SUB
IF GetID(dirn$, 1) <> 0 THEN CurDir = odir$: EXIT SUB
IF INSTR(dirn$, ">") THEN CurDir = odir$: EXIT SUB
IF INSTR(dirn$, "<") THEN CurDir = odir$: EXIT SUB
IF INSTR(dirn$, "|") THEN CurDir = odir$: EXIT SUB
IF dirn$ = "FNF" THEN CurDir = odir$: EXIT SUB
IF INSTR(dirn$, CHR$(34)) THEN CurDir = odir$: EXIT SUB
DO
did$ = RHEX(8)
LOOP UNTIL FindFATFile ("NVXFS/" + did$ + ".nfd") = 0 AND VAL("&H" + did$) <> 0
ff = FREEFILE
OPEN "NVXFS/DirList.nfd" FOR BINARY AS #ff
IF LOF(ff) = 0 THEN g$ = MKI$(0): PUT #ff, 1, g$
t$ = "  "
GET #ff, 1, t$
offs& = CVI(t$) * 272& + 3&
dirdate$ = SPACE$(271)
MID$(dirdata$, 1, 256) = CHR$(LEN(dirn$)) + dirn$
MID$(dirdata$, 257, 4) = CurDrive
MID$(dirdata$, 261, 4) = CurDir
MID$(dirdata$, 265, 4) = MKL$(VAL("&H" + did$))
MID$(dirdata$, 269, 1) = PriPub
MID$(dirdata$, 270, 1) = CurUser
MID$(dirdata$, 271, 1) = IsSystem
PUT #ff, offs&, dirdata$
t$ = "  "
GET #ff, 1, t$
g$ = MKI$(CVI(t$) + 1): PUT #ff, 1, g$
CLOSE #ff
OPEN "NVXFS/" + did$ + ".nfd" FOR APPEND AS #ff
PRINT #ff, CHR$(2) + CHR$(5) + CHR$(1) + CHR$(1);
PRINT #ff, MKL$(VAL("&H" + did$));
PRINT #ff, CurDir;
PRINT #ff, CurDrive;
PRINT #ff, dirn$;
CLOSE #ff
CurDir = odir$
END SUB
Things appear to go wrong around:

Code: Select all

DO
did$ = RHEX(8)
LOOP UNTIL FindFATFile ("NVXFS/" + did$ + ".nfd") = 0 AND VAL("&H" + did$) <> 0
THE RHEX-function is okay so it isn't that and the FindFATFile works fine before that.

did$ is the name for the file to be written, and FindFATFile must find out of it exists or not.

For some odd reason the program stops running here and just quits.

Grtz
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows »

Maybe something at the NOVIX level is clearing the error before it gets a chance to get back to your level of code?
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Post by Seb McClouth »

That's what I thought a couple of months back as I had the same problem with previous versions... Z!re couldn't help me out... and I still can't locate the exact problem...
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Try eliminating the PRINT "Resume". I think the error quits on any subsequent code before RESUME NEXT. Just a guess?

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Post by Seb McClouth »

Eey Burger! Well I just wrote it there so that I knew that if actually gets there, I'd see the message. But I'll try to see what happens if I take it out.

Thx & grtz
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
Anonymous

Post by Anonymous »

are you using vista?
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Post by Seb McClouth »

I'm using DosBox under XP...
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
roy
Veteran
Posts: 55
Joined: Sun Jul 29, 2007 2:39 pm
Location: London

Post by roy »

This is a shot in the dark but with this section of code:-

Code: Select all

SUB MakDir (dir AS STRING) 
odir$ = CurDir 
dirn$ = WorkPath(dir) 
IF dirn$ = "DNF" THEN CurDir = odir$: EXIT SUB 
IF GetID(dirn$, 1) <> 0 THEN CurDir = odir$: EXIT SUB 
IF INSTR(dirn$, ">") THEN CurDir = odir$: EXIT SUB 
IF INSTR(dirn$, "<") THEN CurDir = odir$: EXIT SUB 
IF INSTR(dirn$, "|") THEN CurDir = odir$: EXIT SUB 
IF dirn$ = "FNF" THEN CurDir = odir$: EXIT SUB 
IF INSTR(dirn$, CHR$(34)) THEN CurDir = odir$: EXIT SUB 
odir$ = CurDir and then you make CurDir = odir$ but surely CurDir already = odir$.
As I say, it is a wild guess.
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Post by Seb McClouth »

That code is written be Z!re and proved to have no problems in NOVIX.

From what some PRINT-statements I've added, the farest it gets is to

Code: Select all

DO
did$ = RHEX(8)
LOOP UNTIL FindFATFile ("NVXFS/" + did$ + ".nfd") = 0 AND VAL("&H" + did$) <> 0 
Somehow the FindFATFile hangs here and quits.

FindFATFile works with the error handler and if a certain file error occurs and it's in the error handler, the error handler will give the proper assigment e.g. a file doesn't exist, resulting in a return to FindFATFile = 0.

Thx for helping!

grtz
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
Post Reply