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 / Dedicate a static string size in the field of a user defined type.

Author
Message
pdq
19
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 6th Aug 2013 20:11
Is there a way to define the size of a string in a user type?

I want to dedicate a predefined size.

for example, something like:


So the above dedicates a 32 byte block of memory.

Thanks
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 6th Aug 2013 20:12
I don't believe so in DBPro, but you could I suppose in GDK.

pdq
19
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 6th Aug 2013 20:18
The reason I am asking is because I am using MatrixUtilities peek and poke commands to read and write to the fields of a user defined type. I use an offset value added to the memory address of the user type. The field size is determined by the data type. The problem, of course, are strings. So I was hoping I could dedicate a block of memory to these string fields.
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 7th Aug 2013 01:47


Like that you mean?
A normal c-string is just an array of chars (which is the same thing as a byte unless you're using a unicode compiler setting), so you could use byte array with a fixed size and then convert those into strings on-the-go if you require this behaviour too. Probably won't be the fastest or most readable solution however.


"Why do programmers get Halloween and Christmas mixed up?"
pdq
19
Years of Service
User Offline
Joined: 20th Jul 2006
Location:
Posted: 7th Aug 2013 05:19
Thanks. I'll play around with it

Login to post a reply

Server time is: 2026-07-07 06:02:20
Your offset time is: 2026-07-07 06:02:20