[Implemented] bStr, fixed length strings, lost the plot.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

[Implemented] bStr, fixed length strings, lost the plot.

Post by Dare2 »

I know there are numerous posts on this, but I have lost the plot here.

Are bStr (or whatever the name - can contain binary including binary zero) strings on the "to do" list or the "forget it" list?

Ditto for fixed length strings?

Thanks.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

i think they are more or less the same, and i seem to vaguely recall that fred was the point and was seriously considering it, my hope is we will have them one day (4.0 perhaps? or earlier? oh...)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi blueznl.

My rough understanding of strings in general (not PB) is that they have some "hidden" attributes or properties.

One is type. With PB-type strings, chr(0) terminates, whilst with "blobs" - for want of a better word - the strings can contain anything from chr(0) to chr(255).

Another is the maxLen, which determines the maximum size of the string. If maxLen is zero, the string size is limited only by some hardware or software constraint like memory or unsigned long. Otherwise the string is a fixed length of maxLen.

And another is the VLI, or actLen, which advises the current size of the string within the maxLen attribute. A blob with actLen less than maxLen is right filled with chr(0) and these are significant.

When moved around or stored in a file, blobs use maxLen, PB-type strings use actLen.


Thanks for the response. I am encouraged to hear that providing some or all of these capabilities has not been shelved. :)

[EDIT]
PS:

With a dynamically sizeable "blob" you can almost do away with memory allocations altogether, the declarations or redecs do the job. You can deal with them exactly as you would normal strings, eg use FindString, replaceString, etc, and still Peek/Poke within them.

Mind you a findString/replaceString for a chunk of allocated memory would go a long way, as would a way to include a chunk in a structure and write a chunk to a file. Or a structure to a file, for that matter, ah-la random records.

End of digression. :)
[/EDIT]
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

yeah, i know, memory allocation would be sweet, but best of all would be the string being part of a struct, you have no idea how many times i've been going 'grrrrrrr' at peeks() / pokes() constructions while fixed length strings are soooooooo nice...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply