Check whether the file exists by using EXIST and use the error code liberally to debug the code. Also put a DEBUG ON into the first line of your code, this will allow you to step through code. Finally, please post code in between [CODE] tags.
_________________________
There are two types of vessels, submarines and targets.
anna, you obviously are not giving us the whole script. although shawns solution works on many cases, that is not the ultimate way.
if you can't post your whole code... I can say that check out every file you open before this piece with filehandle "1" and close them before calling this piece.
Registered: 2001-08-21
Posts: 71
Loc: Los Angeles, cA
guys,
I've changed the file number to 4 and it works perfectly. We have a login.kix that runs for every user, in that script we are using file number 1. I didn't notice it. thank you so much, you guys are the best!
Howard BullockHoward Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
anna, you may want to look into using my OpenFile() UDF. It would have avoided the error entirely. Although it does not yet use FreeFileHandle() is does find a free file handle and is backward compatible to 4.02.
Anna: I would highly recommend to replace all hardcoded file handles with the FREEFILEHANDLE(). The script fragment below will loop until a free filehandle has been received, thus up to ten files can be opened at the same time.
code:
$handle=freefilehandle() while not $handle $handle=freefilehandle() sleep 0.1 loop $rc = Open($handle,"c:\templog.txt",2) IF $rc = 0 ? "file open" $result = ReadLine($handle) $x = SUBSTR("$result",20,15) ? "substr = " + $x $ = Close($handle) ELSE ? "File not open: Return code = " + $rc ? "Hit any key to continue" Get $ EndIf
_________________________
There are two types of vessels, submarines and targets.