Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / read/write dword into file

Author
Message
Tartopom
20
Years of Service
User Offline
Joined: 27th Jun 2004
Location:
Posted: 11th Aug 2006 18:47
Hello,

I'm looking for a way to read/write a dword into a file.

Is it possible to make a function such as "write dword" ?
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 11th Aug 2006 18:51
READ LONG and WRITE LONG are your friends.

Boo!
Tartopom
20
Years of Service
User Offline
Joined: 27th Jun 2004
Location:
Posted: 11th Aug 2006 18:54 Edited at: 11th Aug 2006 18:55
isn't long's range : -2,147,483,648 -> +2,147,483,647, whereas dword is 0 -> +4,294,967,295 ?
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 11th Aug 2006 18:58
Try logical ANDing it into an in, like

a as long
a = 12345557876
upper as integer
lower as integer

upper = a && 0xFFFF0000
lower = a && 0x0000FFFF

spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 11th Aug 2006 19:04
Seems to work quite happily for large positive numbers that are DWORD compatible. I think maybe the term LONG in DBPro's file commands actually equate to DWORD values.



Boo!
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 11th Aug 2006 19:14
With Long you write a 4 byte integer value. Whether it comes out as signed or unsigned depends on the variable you put it to.


Play Nice! Play Basic! -- Styx PlugIn- Coming Soon!
Tartopom
20
Years of Service
User Offline
Joined: 27th Jun 2004
Location:
Posted: 11th Aug 2006 21:59
I didn't know that, empty

Thanks to all of you.

Login to post a reply

Server time is: 2025-05-17 06:07:44
Your offset time is: 2025-05-17 06:07:44