stream does not exist error

Blitz3D Forums/Blitz3D Beginners Area/stream does not exist error

DropTherapy(Posted 2016) [#1]
when i got my hands on the source code of a game made in blitz max with the blitz3d SDK, i tried to run it and an error popped up that said "stream does not exist"
and highlighted "while not eof (f)"
is there a way to fix it?


Floyd(Posted 2016) [#2]
f is the previously opened stream, probably a file. Make sure it does indeed exist.


DropTherapy(Posted 2016) [#3]
Function GetINIString$(file$, section$, parameter$)
Local TemporaryString$ = ""
Local f = ReadFile(file)

While Not Eof(f)
If Lower(ReadLine(f)) = "[" + Lower(section) + "]" Then
Repeat
TemporaryString = ReadLine(f)
If Lower(Trim(Left(TemporaryString, max(Instr(TemporaryString, "=") - 1, 0)))) = Lower(parameter) Then
CloseFile f
Return Trim( Right(TemporaryString,Len(TemporaryString)-Instr(TemporaryString,"=")) )
EndIf
Until Left(TemporaryString, 1) = "[" Or Eof(f)
CloseFile f
Return ""
EndIf
Wend

CloseFile f
End Function

this is the function it was in.


DropTherapy(Posted 2016) [#4]
Function GetINIInt$(file$, section$, parameter$)
Local Stri$= Trim(GetINIString(file$, section$, parameter$))
If Lower(Stri) = "true" Then
Return 1
ElseIf Lower(Stri) = "false"
Return 0
Else
Return Int(Stri)
EndIf
End Function

Function GetINIFloat$(file$, section$, parameter$)
Return Float(GetINIString(file$, section$, parameter$))
End Function

this is the one after it.


xlsior(Posted 2016) [#5]
You'd need to see where getinistring$() gets called, and what filename gets passed to it. Then make sure that file actually exists.


Matty(Posted 2016) [#6]
If must have returned '0' from f= readfile(file). This means the file cannot be read because most likely it does not exist, or does not have the path you expect it to. debuglog the value of 'file' before running the f = readfile(file) command and check that the file exists and that the path exists. If it does not your problem lies further up in the code wherever the value for file is specified.