How come...

Everything else that doesn't fall into one of the other PB categories.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

How come...

Post by SFSxOI »

This was a discussion somewhere else in the forum in the past, in a different aspect, but I can't find it now so i'll re-ask the question in a more direct manner then what i remember that other discussion being:

How come PB string functions like FindString, StringByteLength, etc....exclude the terminating null of a string in their returns?

a string "123456" - Len("123456") = 6 - StringByteLength("123456") = 6 - FindString("123456", Chr(0), 1) = 0 (or FindString("123456", #Null$, 1) = 0)

strings in PB consume memory at "string length + 1" (so I assume strings in PB automatically include a terminating null)
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: How come...

Post by luis »

Because a PB string it's a particular kind of memory buffer, cannot contain a $00 by definition.
$00 is the termination char. It something beyond the string. It's not part of the string.
It's simply a convention.
"Have you tried turning it off and on again ?"
User avatar
skywalk
Addict
Addict
Posts: 4318
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: How come...

Post by skywalk »

SizeOf(Character) is your friend. :wink:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: How come...

Post by luis »

skywalk wrote:SizeOf(Character) is your friend. :wink:
PrintN is nice. The sky is blue.
"Have you tried turning it off and on again ?"
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: How come...

Post by SFSxOI »

skywalk wrote:SizeOf(Character) is your friend. :wink:
yeah, I use SizeOf(Character) a lot :)
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: How come...

Post by SFSxOI »

luis wrote:Because a PB string it's a particular kind of memory buffer, cannot contain a $00 by definition.
$00 is the termination char. It something beyond the string. It's not part of the string.
It's simply a convention.
Yep, thats it, just could not remember. Thanks luis :)
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
Post Reply