correct place for closefile
BlitzPlus Forums/BlitzPlus Programming/correct place for closefile
| ||
Hmmmm...Which is the correct place for closefile: myfile=openfile("filename") if myfile<>0 load some stuff endif closefile myfile OR: myfile=openfile("filename") if myfile<>0 load some stuff closefile myfile endif I'm thinking that if the file was unable to be opened then there's no need to close it (sounds obvious I know) so the second option is right, but I'm not completely certain - any help welcome ..Thanks. |
| ||
Before EndIf. If the file didn't open, then there's no need to close it, as it never opened in the first place. |
| ||
btw, minor detail: In your IF statement: "<>0" can be left out. "If <value>" means "If True", and True is "<>0". |
| ||
The first example (with the closefile outside of the if..then construct) will result in a MAV if the file didn't exist in the first place. |
| ||
Thanks for the help - much appreciated... Timjo. (p.s. - it's probably something obvious - but what does MAV stand for ?) |
| ||
memory access violation |