10-31-2002, 03:52 PM
Quote:ok, i used the code you suggested and now it creates the new file! :rotfl:
however, a new problem has popped up. it creates the file, then it opens the file and for some reason it goes to the errorhandler and freezes there.
here is the sub where the problem occurs:
Code:SUB SELECTSTUDENT
'THIS SUB WILL PROMPT THE USER FOR THE STUDENTS NAME, WHICH DOUBLES AS A FILE NAME IN WHICH THE DATA IS STORED
ON ERROR GOTO ERRORHANDLER
PRINT "PLEASE ENTER THE STUDENTS NAME"
INPUT N$
OPEN (N$) + ".SDN" FOR INPUT AS #1
STUDENTINFO
END SUB
i also modified the error handler to comply with my requirements:
i am really lost and so any help is apreciated! :???:Code:ERRORHANDLER:
SELECT CASE ERR
CASE 53
PRINT "File not found."
PRINT "Creating file:"; N$
OPEN N$ + ".SDN" FOR OUTPUT AS #1
CLOSE #1
SELECTSTUDENT
CASE 64
PRINT "The file name you entered was incorrect."
CASE 76
PRINT "Path not found."
END SELECT
RESUME
I think you're having some problems with the scope the N$ variable. Look: the errortrap must be in the main module, while the error occured in a sub, with a variable N$, in the main module there is no N$. I think you could solve this problem with:
Code:
SUB SELECTSTUDENT
'THIS SUB WILL PROMPT THE USER FOR THE STUDENTS NAME, WHICH DOUBLES AS A FILE NAME IN WHICH THE DATA IS STORED
ON ERROR GOTO ERRORHANDLER
PRINT "PLEASE ENTER THE STUDENTS NAME"
INPUT N$
OPEN (N$) + ".SDN" FOR INPUT AS #1
STUDENTINFO
END SUB
Main Module:
Code:
'$DYNAMIC
DEFINT A-Z
DIM SHARED N$
CALL SELECTSTUDENT
ERRORHANDLER:
SELECT CASE ERR
CASE 53
PRINT "File not found."
PRINT "Creating file:"; N$
OPEN N$ + ".SDN" FOR OUTPUT AS #1
CLOSE #1
SELECTSTUDENT
CASE 64
PRINT "The file name you entered was incorrect."
CASE 76
PRINT "Path not found."
END SELECT
RESUME