Code: Select all
a.s="a"
b.s="b"
c.s=Chr(0)
d.s=#Null$
MessageRequester("",a+c+b,0)
MessageRequester("",a+d+b,0)
The correct value should be output only 'a
PUB is not truncated Chr (0)
'
Code: Select all
a.s="a"
b.s="b"
c.s=Chr(0)
d.s=#Null$
MessageRequester("",a+c+b,0)
MessageRequester("",a+d+b,0)
A #Null$ or Chr(0) is not part of a string, it is the end of a string.zgneng wrote:The correct value should be output only 'a
PUB is not truncated Chr (0)
'
Not so. If that were true, then anything following c.s would still be shown:User_Russian wrote:c.s=Chr(0) similarly c.s=""
Code: Select all
a.s="a"
b.s="b"
c.s=""
d.s="d"
Debug a+b+c+d ; abd
Find a difference.Dude wrote:Chr(0) means "end of string", not "empty string".
Code: Select all
c.s=""
ShowMemoryViewer(@c, SizeOf(Character))
Code: Select all
c.s=Chr(0)
ShowMemoryViewer(@c, SizeOf(Character))
Code: Select all
string$="a"+"b"+Chr(0)+"d"
Debug string$ ; abd
Code: Select all
string$="a"+"b"+Chr(0)+"d"
Debug string$ ; ab with PureBasic v4.61
Code: Select all
Structure TEST
StructureUnion
st.s{#MAXPNAMELEN * 2}
io.s{#MAXPNAMELEN}[2]
EndStructureUnion
EndStructure
Global d.TEST, s.s{#MAXPNAMELEN}
;s="a string shorter then 32" ;s doesn't help while s => s.s{#MAXPNAMELEN}
;d\io[0]=s
;d\io[0]="a string exact length of 32 byte"
d\io[0]="a string shorter then 32"
d\io[1]="added to a string longer then 32.."
Debug d\io[0]
Debug d\io[1]
Debug d\st ;both io are only kept if io[0] is at least 32 bytes long
d\st="a string shorter then 32 added to a string longer then 32.."
Debug d\io[0]
Debug d\io[1]
Code: Select all
EnableExplicit
OpenConsole()
Structure TEST
StructureUnion
st.s[2]
io.s[2]
EndStructureUnion
EndStructure
Global d.TEST, s.s
d\io[0]="a string shorter then 32|"
d\io[1]="added to a string longer then 32.."
PrintN("")
PrintN("d\io[0] = " + d\io[0])
PrintN("d\io[1] = " + d\io[1])
PrintN("")
d\st=d\io[0] + d\io[1]
PrintN("d\st = " + d\st) ;both io are only kept if io[0] is at least 32 bytes long
Input()
CloseConsole()
End