Reputation: 127
I'm writing a program in GW-BASIC. For some reasons, I have the following error :
"Numéro de fichier illégal en 4712"
which can be translated in english by,
" illegal file number in 4712"
Here is a part of my code :
51 Chemin$ = "T:\Basic\Calculs\" + NF$
52 ON ERROR GOTO 60
53 MKDIR Chemin$
54 END
... ( a lot of code not important to solve this problem :) )
4711 CHDIR Chemin$
4712 OPEN "Intdrcrc.doc" FOR APPEND AS #3
4712 PRINT #3, "*---------------------------------------------------------------------------------------------------------------*"
4713 PRINT #3, USING "* Centre ##### \ \#######.### #######.### Intersect Droite Cercler *";IC,NC$,XC#,YC#
4714 PRINT #3, USING "* Point ##### \ \#######.### #######.### R=#######.### *";IP,NP$,XP#,YP#,R#
4715 PRINT #3, USING "* 1er Intersection M1 ##### \ \ #######.### #######.### *";I1,N1$,XM1#,YM1#
4716 PRINT #3, USING "* 2e Intersection M2 ##### \ \ #######.### #######.### *";I2,N2$,XM2#,YM2#
4717 PRINT #3, "*---------------------------------------------------------------------------------------------------------------*"
4718 CLOSE #3
4719 CHDIR "T:\Basic"
I had the same problem in previous lines, so I changed the # after "APPEND"
, but here, at the line 4712
, changing the # doesn't solve the problem..
I hope I'm clear enough,
thank you very much for your suggestions !
:)
Upvotes: 2
Views: 249
Reputation: 13855
Is that 2nd line numbered as 4712 replacing the first one? If so, the program will try to print into file number #3 which was not opened.
4712 OPEN "Intdrcrc.doc" FOR APPEND AS #3
4712 PRINT #3, "*---------------------------------------------------------------------------------------------------------------*"
Upvotes: 1
Reputation: 1165
Why not try:
4702 CHDIR Chemin$
4703 OPEN "Intdrcrc.doc" FOR OUTPUT AS #3
4712 PRINT #3, "*---------------------------------------------------------------------------------------------------------------*"
4713 PRINT #3, USING "* Centre ##### \ \#######.### #######.### Intersect Droite Cercler *"; IC, NC$, XC#, YC#
4714 PRINT #3, USING "* Point ##### \ \#######.### #######.### R=#######.### *"; IP, NP$, XP#, YP#, R#
4715 PRINT #3, USING "* 1er Intersection M1 ##### \ \ #######.### #######.### *"; I1, N1$, XM1#, YM1#
4716 PRINT #3, USING "* 2e Intersection M2 ##### \ \ #######.### #######.### *"; I2, N2$, XM2#, YM2#
4717 PRINT #3, "*---------------------------------------------------------------------------------------------------------------*"
4718 CLOSE #3
Upvotes: 0
Reputation: 127
So i wrote this :
4702 CHDIR Chemin$
4703 OPEN "Intdrcrc.doc" FOR APPEND AS 3
4704 IF errorflag <> 0 THEN
4705 errorflag = 0
4706 CLOSE
4707 PRINT "File not found - press return to continue"
4708 INPUT "", a$
4709 EXIT SUB
4710 END IF
4712 PRINT 3, "*---------------------------------------------------------------------------------------------------------------*"
4713 PRINT 3, USING "* Centre ##### \ \#######.### #######.### Intersect Droite Cercler *";IC,NC$,XC#,YC#
4714 PRINT 3, USING "* Point ##### \ \#######.### #######.### R=#######.### *";IP,NP$,XP#,YP#,R#
4715 PRINT 3, USING "* 1er Intersection M1 ##### \ \ #######.### #######.### *";I1,N1$,XM1#,YM1#
4716 PRINT 3, USING "* 2e Intersection M2 ##### \ \ #######.### #######.### *";I2,N2$,XM2#,YM2#
4717 PRINT 3, "*---------------------------------------------------------------------------------------------------------------*"
4718 CLOSE 3
4719 CHDIR "T:\Basic"
Result : in gwbasic cmd window it is written : "File not found - press return to continue"
And then the file "intdrcrc.doc" is created. But it is empty, as if "PRINT 3" didn't work
Upvotes: -1
Reputation: 3461
It seems the Intdrcrc.doc
file does not exist (although I can't be sure about that without looking at the rest of your code).
What you can try is,
OPEN "Intdrcrc.doc" FOR APPEND AS #3
with OPEN "Intdrcrc.doc" FOR OUTPUT AS 3
and try if it gives an error. This is just to test of course. You should revert back to APPEND
later. We want to see if the error is gone with OUTPUT
. If so, it probably means, the file does not exist, as you expected it to.Secondly, you need to implement some error-handling after the OPEN
command.
What you can do is something like this,
4710 ...
4711 SHARED errorflag
4712 OPEN "Intdrcrc.doc" FOR APPEND AS 1
4713 IF errorflag <> 0 THEN
4714 errorflag = 0
4715 CLOSE
4716 PRINT "File not found - press return to continue."
4717 INPUT "", a$
4718 EXIT SUB
4719 END IF
4720 PRINT #3, "*------------------------------------------*"
4721 ...
So that we may know, something more if an error happens.
Upvotes: 0