Code: Select all
Global stringstart.s
stringstart = "1"
Dim astring.s (9) ; String lengths are totally managed by PB. Strings only grow...
; ...the ram use doesn't seem to shrink.
astring(1) = "2"
Global bstring.s
bstring = "3"
Global endstring.s
endstring = "4"
Debug "Start at " + Str(@stringstart)
Debug "Array at " + Str(@astring)
Debug "next at " + Str(@bstring)
Debug "end at " + Str(@endstring)
Debug StringByteLength(bstring)
Debug "1:"
Debug "astring(0) Length" + Str(StringByteLength(astring(1)))
Debug "element 0 bytes " + Str(@astring(1) - @astring(0)) ;no initializing...size = 0
Debug @astring(0)
Debug @astring(1)
Debug @astring(2)
Debug @astring(3)
Debug ""
Debug "2"
astring(0) = "1" ;changing does NOT effect size.
astring(1) = "a"
astring(2) = "b"
astring(3) = "c"
Debug "astring(0) Length " + Str(StringByteLength(astring(1)))
Debug "element 0 bytes " + Str(@astring(1) - @astring(0)) ;no initializing...size = 0
Debug @astring(0) ;first init; size = 16 bytes
Debug @astring(1) ;first init; size = 16 bytes
Debug @astring(2)
Debug @astring(3)
Debug ""
Debug "3"
astring(0) = "d"
astring(1) = "e"
astring(2) = "f"
astring(3) = "g"
Debug "astring(0) Length " + Str(StringByteLength(astring(1)))
Debug "element 0 bytes " + Str(@astring(1) - @astring(0)) ;no initializing...size = 0
Debug @astring(0) ;first change...still 16 bytes at original location
Debug @astring(1) ;first change...still 16 bytes at original location
Debug @astring(2)
Debug @astring(3)
Debug ""
Debug "4"
astring(0) = "d234"
astring(1) = "e234" ;4 causes increase (3 does not)
astring(2) = "f234"
astring(3) = "g234"
Debug "astring(0) Length " + Str(StringByteLength(astring(1)))
Debug "element 1 bytes " + Str(@astring(2) - @astring(1)) ;no initializing...size = 0 (Use 1 because 0 is "managed" into previous location.)
Debug @astring(0) ; now size is 24
Debug @astring(1) ; now size is 24
Debug @astring(2)
Debug @astring(3)
Debug ""
Debug "5"
astring(0) = "d12345678902"
astring(1) = "a12345678902" ;more than 11 and it increases
astring(2) = "b12345678902"
astring(3) = "c12345678902"
Debug "astring(0) Length " + Str(StringByteLength(astring(1)))
Debug "element 0 bytes " + Str(@astring(1) - @astring(0)) ;no initializing...size = 0
Debug @astring(0) ;...size is 32
Debug @astring(1) ;...size is 32
Debug @astring(2)
Debug @astring(3)
I'm not set to use Unicode (I'm on Windows). Why does each character take more than one byte? (Heck, why more than TWO???)
How do I set it to one byte/char as default? This seems grossly wasteful to use a full 64-bits for an 8-bit character. I could even sort of understand 32-bits, if you want to make it unicode compatible...
But! The manual says :
This certainly does not hold true.Name: extension: Memory Consuption:
String .s string length + 1
Fixed String .s{Length} string length
The biggest reason people boast about PB is its small compact size, but if you are dealing with very large strings, 25% memory efficiency is intolerable. Any help would be appreciated.
Thanks.