Error Opening/Closing file
Blitz3D Forums/Blitz3D Programming/Error Opening/Closing file
| ||
Hello everyone, I'm trying to write a bot for a game I play but am having an odd problem, probably due to my lack of familiarity with file opening/etc. Most of the code you can ignore, I just have it there. The way it works (generally, its partially unfinished) is it opens the errors.log file, parses it, and then writes something to the mytext.txt file (which gets picked up by the game). The odd part is that after the 507th time (shown by the count var) it runs, I get the "Stream does not exist" error message. I'm pulling my hair out over this, so if anyone could help that'd be great!While Not KeyHit(1) starttime# = MilliSecs() myfile = WriteFile("C:\Program Files\Vendetta Online\myfile.txt") errors = ReadFile("C:\Program Files\Vendetta Online\errors.log") While Eof(errors) <> 1 lastline$ = ReadLine$(errors) If Eof(errors) = 1 Then Print lastline : Print count : count = count + 1 Wend If lastline$ = pastline$ Then Else If Right$(lastline,22) = " has entered the room." Then End greeting$ = "Hello " + Mid$(lastline,20,Len(lastline) - 42) + "!" WriteLine(myfile,"alias VOidResponse \" + Chr$(34) + "msg Smittens \'" + greeting + "\'\" + Chr$(34) + "\n") End If End If pastline$ = lastline CloseFile errors Wend |
| ||
CloseFile myfile? |
| ||
Ack thanks! I should've thought of that lol |
| ||
Move your writefile and readfile commands outside of the loop |
| ||
year, else it will be a BIG slowdown! :P myfile = WriteFile("C:\Program Files\Vendetta Online\myfile.txt") errors = ReadFile("C:\Program Files\Vendetta Online\errors.log") While Not KeyHit(1) SeekFile myfile,0: SeekFile errors,0 ; <-- to start from the beginning of the files starttime# = MilliSecs() While Eof(errors) <> 1 lastline$ = ReadLine$(errors) If Eof(errors) = 1 Then Print lastline : Print count : count = count + 1 Wend If lastline$ = pastline$ Then Else If Right$(lastline,22) = " has entered the room." Then End greeting$ = "Hello " + Mid$(lastline,20,Len(lastline) - 42) + "!" WriteLine(myfile,"alias VOidResponse \" + Chr$(34) + "msg Smittens \'" + greeting + "\'\" + Chr$(34) + "\n") End If End If pastline$ = lastline Wend CloseFile errors CloseFile myfile |