Returns the character associated with the given ASCII value.
Example :
Debug Chr(33) ; Will display "!"
Does the example from the docs become "33,00"? When I use it in the replacestring function in a unicode app is that supported? does it do anything with the zeros?
ASC() seems to work okay but I figure it's easier to ask then write lots of test code to make up for sparse documentation on CHR()
Paul Dwyer
“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Trond wrote:MyString + Chr(0) returns the original string, because strings are zero terminated.
that's definitely correct...
but he asked how much it adds, not what much it returns...
Chr(Nr) should add two byte in a Unicode exe.
No, it will add 0 bytes.
Let's say Chr(0) returns four bytes: 0, 0, 0, 0. The string concatenation function will treat the first two zeros as the string end. And since there is nothing before the string end nothing will get added.
It's nonesense if it adds a wide zero as that will just terminate the string. the docs are vague though and specifically mention ascii so if it only added one byte (not a word) then the string wouldn't terminate in unicode and the string would be one zero byte longer.
In powerbasic I had to add two myself as it didn't have unicode compile.
Paul Dwyer
“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
pdwyer wrote:It's nonesense if it adds a wide zero as that will just terminate the string. the docs are vague though and specifically mention ascii so if it only added one byte (not a word) then the string wouldn't terminate in unicode and the string would be one zero byte longer.
In powerbasic I had to add two myself as it didn't have unicode compile.
Let's say Chr() returns just one byte, as you want. It would still have the same effect. Chr(0) would return 0, 0, 0. The string will terminate with the two first null bytes.
I wonder if you can run the PB chm file with a -v?
Paul Dwyer
“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein