I've been stepping though all the function calls and I have discovered the following.
the readbytes (and writebytes) have a duplicate identifier in different scope.
In The above code taken from stream.bmx
there are 2 n variables. one is in scope the whole method the other just in the while loop, the n in the while gets updated, with the characters actually read from the file, this decrements count with those characters read and updates the pointer to the buf
there is only one check to see if the returned number of read characters is not zero, if it is zero then a error is thrown, other wise it will happily read from a empty stream.
So I add the following line
to the read function in TCStream
the new line being
but this still does not throw an error. I am using assert correctly?
i.e Assert <comparison> Else <Message>
Help would be appricated.
Cheers.
the readbytes (and writebytes) have a duplicate identifier in different scope.
Method ReadBytes( buf:Byte Ptr,count ) Local n=count While count>0 And Not Eof() Local n=Read( buf,count ) If Not n Throw New TStreamReadException count:-n buf:+n Wend Return n End Method
In The above code taken from stream.bmx
there are 2 n variables. one is in scope the whole method the other just in the while loop, the n in the while gets updated, with the characters actually read from the file, this decrements count with those characters read and updates the pointer to the buf
there is only one check to see if the returned number of read characters is not zero, if it is zero then a error is thrown, other wise it will happily read from a empty stream.
So I add the following line
to the read function in TCStream
Method Read( buf:Byte Ptr,count ) Assert _cstream Else "Attempt to read from closed stream" Assert _mode & MODE_READ Else "Attempt to read from write-only stream" Assert _pos <> _size Else "End of File Reached" ' new line count=fread_( buf,1,count,_cstream ) _pos:+count Return count End Method
the new line being
Assert _pos <> _size Else "End of File Reached" ' new line
but this still does not throw an error. I am using assert correctly?
i.e Assert <comparison> Else <Message>
Help would be appricated.
Cheers.