Readbyte and ReadLine issues?

Previous topic - Next topic

spacefractal

I tried this code:

Code (glbasic) Select

LOCAL tem, ok
ok=OPENFILE(1,"test.ini", 1)
WHILE ENDOFFILE(1) = FALSE
READBYTE 1, tem
WEND


but I just got compile error:
Code (glbasic) Select

_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.7.861 SN:a001d9df - 3D, NET
Wordcount:5 commands
compiling:
C:\Users\SPACEF~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Users\SPACEF~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp:41: error: invalid initialization of reference of type 'DGNat&' from expression of type 'DGInt'
D:/Programmer/GLBasic/Compiler/platform/Include/glb.h:1022: error: in passing argument 2 of `void __GLBASIC__::READBYTE(DGNat, DGNat&)'
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 1.2 sec. Time: 19:40
Build: 0 succeeded.
*** 1 FAILED ***


Also why is the readline limit to around 1024 chars? This cause xml hard to do with (this cause XMLParser not wokring (code snippet found in this forum), and that about LEN LINE=1023 didden't work quite well.... And even harder when ReadByte diddent work at all.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Moru

I think "tem" needs to be an integer, not a float. Declare it like this:

global tem%

spacefractal

#2
checking later, its somewhere a bad error, sints its should been integer I actuelly use?

Howover the limited ReadLine function can been done same as this:

(Just edited to use as a function)
Code (glbasic) Select

FUNCTION LINEREAD$: FileNr
LOCAL chda$, L$=""
REPEAT
IF ENDOFFILE(FileNr) THEN BREAK
READSTR FileNr, chda$, 1
L$=L$+chda$
UNTIL ASC(chda$)=10
L$=TRIM$(L$)
RETURN L$
ENDFUNCTION


This read the whole line, not just the first kb of it. Mightbeen somewhere slowere, but its works.

PS. The thread can mightbeen move to code snippets (since its more a limit on the readline, not a bug)?
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrTAToad

A variable without a % or $ is always defined as floating-point.  The READ/WRITE commands are somewhat unusual in that you can't use a float for the handle number and possibly for storing/writing values...

spacefractal

ah, this due most other language I use allways use integer as standard, not floats. This can been a little bit of confuction.

Anyway, readline didden't work fully, but have a 1kb limit. I checked about the LEN(L$)=1023 as pointed in a another thread, but diddent work, and just add some garbages chars instead.

Instead I edited the post and then using READSTR instead. I not sure it was posted here, since I saw that, but fell free to move it out of bug thread (even ReadLine have a limit, but not a real bug).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrTAToad

Yes, Gernot has mentioned before that READLINE has a limit of 1023 bytes