READSTR error

Previous topic - Next topic

Neurox

Hi,

I've used the Readstr command :
Code (glbasic) Select
READSTR 1,wRiffID$,4but the compiler tell me :
Code (glbasic) Select
GPC - GLBasic Precompiler V.2007.159 - 3D, NET
"GP2XInitSound.gbas"(178) error : wrong number or aguments : "READSTR" called with 3 args. Required: 2
Why ??? :-(
Well I removed the last parameters,
and code is  :
Code (glbasic) Select
READSTR 1,wRiffID$but the result is :
Code (glbasic) Select
_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.2007.159 - 3D, NET
Wordcount:256 commands

compiling:
C:/Programmi/GLBasic/Compiler/platform/Include/glb.h: In function `DGInt __GLBASIC__::LeggiInfo(__GLBASIC__::DGStr)':
C:/Programmi/GLBasic/Compiler/platform/Include/glb.h:499: error: too few arguments to function `void __GLBASIC__::READSTR(DGInt, __GLBASIC__::DGStr&, DGInt)'
C:/DOCUME~1/PAOLOB~1/IMPOST~1/Temp/glbasic/gpc_temp0.cpp:220: error: at this point in file
C:/Programmi/GLBasic/Compiler/platform/Include/glb.h:499: error: too few arguments to function `void __GLBASIC__::READSTR(DGInt, __GLBASIC__::DGStr&, DGInt)'
C:/DOCUME~1/PAOLOB~1/IMPOST~1/Temp/glbasic/gpc_temp0.cpp:222: error: at this point in file
C:/Programmi/GLBasic/Compiler/platform/Include/glb.h:499: error: too few arguments to function `void __GLBASIC__::READSTR(DGInt, __GLBASIC__::DGStr&, DGInt)'
C:/DOCUME~1/PAOLOB~1/IMPOST~1/Temp/glbasic/gpc_temp0.cpp:223: error: at this point in file
C:/Programmi/GLBasic/Compiler/platform/Include/glb.h:499: error: too few arguments to function `void __GLBASIC__::READSTR(DGInt, __GLBASIC__::DGStr&, DGInt)'
C:/DOCUME~1/PAOLOB~1/IMPOST~1/Temp/glbasic/gpc_temp0.cpp:231: error: at this point in file
C:/Programmi/GLBasic/Compiler/platform/Include/glb.h:499: error: too few arguments to function `void __GLBASIC__::READSTR(DGInt, __GLBASIC__::DGStr&, DGInt)'
C:/DOCUME~1/PAOLOB~1/IMPOST~1/Temp/glbasic/gpc_temp0.cpp:232: error: at this point in file
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Any Hints ???

Paolo
Paolo Borzini | paolo@borzini.it
The WhiteFly Software | www.thewhitefly.it
Service on line for screen printers | www.4pellicole.it

Quentin

This problem is still present in the current version of the compiler. I'm facing the same problem now :(

But there's another way to save and read strings from files. It is also shown in the example for OPENFILE in the GLBasic help.

You can use READLINE instead of READSTR. Therefor you will have to add a newline command at the end of every string to be saved.

Here's a short example on how to use it:

Code (glbasic) Select
// store some data into the test file
OPENFILE(1, "test.dat", FALSE)
WRITELONG 1, 1230
WRITESTR 1, "a test line\n"
WRITESTR 1, "two lines\nat a time\n"
WRITELONG 1, 578
CLOSEFILE 1


// open testfile and show the data
OPENFILE(1, "test.dat", TRUE)

READLONG 1, num1   // will read 1230
READLINE 1, s1$    // will read "a test line"
READLINE 1, s2$    // will read "tow lines"
READLINE 1, s3$    // will read "at a time"
READLONG 1, num2   // will read 578

PRINT num1, 0, 20
PRINT s1$, 0, 30
PRINT s2$, 0, 40
PRINT s3$, 0, 50
PRINT num2, 0, 60
SHOWSCREEN
MOUSEWAIT
Hope this will help you