How can i check if a file is open

Previous topic - Next topic

okee

If i do

Code (glbasic) Select
IF OPENFILE(1, WordFile$, 1)
     print "Open",1,1
else
      print "Couldnt open" + WordFile$, 1,10
endif


This tries to open a file and returns a message if it can't
If the file opens succesfully, is there any way later on to
check that the file is open, say something like ISFILEOPEN(1)
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

MrTAToad

You shouldn't really need to check to see if a file is opened later on

However, you could either use a flag variable (set it to TRUE if its open), and set it to FALSE when the file is closed

or

you can use a TRY/CATCH/THROW block

okee

Ok i just thought i'd overlooked a command.
Just on another note is there any reason why you cannot assign
a channel number greater than 7 to a file, while i was debugging
i put in a channel number 8 which caused an error.
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

MrTAToad

Quote from: okee on 2011-Feb-06
Ok i just thought i'd overlooked a command.
Just on another note is there any reason why you cannot assign
a channel number greater than 7 to a file, while i was debugging
i put in a channel number 8 which caused an error.
Gernot has limited the file handle numbers to between 0 and 7

MrTAToad

Quotedepends on the environment.  An app wants to open a server based file, one that potentially was opened by another user already, might find it useful to do some checking first
Good point there!  I dont know how Sqlite does it, but Pervasive would set various bytes within the database file to a certain value...