Post Reply 
71b creating strings with binary data
12-20-2022, 09:50 AM
Post: #2
RE: 71b creating strings with binary data
Using strings with binary data is usually no problem. I did it a lot of time.
However, the BASIC string type is not an array of bytes, but a string of characters associated with a length.

When you set the value of a character before setting the preceding bytes, these ones are not replaced by spaces, they are, by default, initialized as spaces.
Doing NUM beyond the current length of the string returns 0, not the (default) value of the character that is at this point outside the string.

If you don't set the value of each byte of the string, it means that they are don't care for you, so it shouldn't matter if there are spaces or nulls.
If it really matters for you, then you should initialize the string:
DIM P1$[10]
P1$=RPT$(CHR$(0),10)
or a loop if you don't have a LEX with the RPT$ keyword.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: 71b creating strings with binary data - J-F Garnier - 12-20-2022 09:50 AM



User(s) browsing this thread: 4 Guest(s)