GLBasic forum

Main forum => GLBasic - en => Topic started by: FutureCow on 2009-Oct-12

Title: Why doesn't writing RGB data to a file with writeulong work?
Post by: FutureCow on 2009-Oct-12
I have gotten this to work by using READ/WRITESHORTIEEE, but I'd be interested to know why this doesn't work (as I thought the typecast would be done automatically)

This was my original code that fails (but I thought would work as it would typecast)
Code (glbasic) Select
...
PixelColour=GETPIXEL(XLoop,YLoop)
WRITEULONG FileHandle, PixelColour
...
READULONG FileHandle, PixelColour
...


It fails on the "READULONG" line. Error :-
QuoteC:\DOCUME~1\Shane\LOCALS~1\Temp\glbasic\gpc_temp1.cpp: In function `DGInt __GLBASIC__::Designer_LoadSet()':
C:\DOCUME~1\Shane\LOCALS~1\Temp\glbasic\gpc_temp1.cpp:539: error: invalid initialization of reference of type 'DGNat&' from expression of type 'DGInt'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:907: error: in passing argument 2 of `void __GLBASIC__::READULONG(DGNat, DGNat&)'

Using READSHORTIEEE and WRITESHORTIEEE works though.

Why isn't the DGInt (ie. ulong) converting to a DGNat? (Sorry, my C++ is VERY rusty!  =D )
Title: Re: Why doesn't writing RGB data to a file with writeulong work?
Post by: MrTAToad on 2009-Oct-12
PixelColour is not an integer, and WRITEULONG/READULONG need one.
Title: Re: Why doesn't writing RGB data to a file with writeulong work?
Post by: Kitty Hello on 2009-Oct-12
DGInt = "Dings Gamebasic Internal" (YUCK!!!) = floating point.
DGNat = natural = integer.

But I'll extend these functions to be able to use both. It's a true pain.
Title: Re: Why doesn't writing RGB data to a file with writeulong work?
Post by: FutureCow on 2009-Oct-13
Thanks as always Gernot! (and MrTAToad!)