Can anybody help.
I seem to be struggling.
I need a string that contains only the ascii value 13 (a CR)
so I dimension a string - say CR_str
then I try CR_str=chr(13)
but I get an 'incompatibe types' error.
Obviously I'm mis understanding the use of 'chr'.
It seems the type expected is a byte.
so if I dimension X1 as byte
x1=chr(13) compiles ok, leaving x1=13
interesting but not what I need, and it does seem to make 'chr' a rather useless instruction, x1=13 would be a little easier so I must be missing something.
So what am I doing wrong here?
What is the easiest way to get a string containing a control characters or a combination of printable and control characters?
Ascii control charaters in string variables
Re: Ascii control charaters in string variables
Indeed, the 'chr' function returns a character (the one with ascii code 13), not a string.so I dimension a string - say CR_str
then I try CR_str=chr(13)
Yes, bytes and characters are interchangeable in mB. The byte takes the ascii code of the character (as if the 'ord' function was used), the character takes the character with the ascii code of the byte (as if the 'chr' function was used).so if I dimension X1 as byte
x1=chr(13) compiles ok, leaving x1=13
Use e.g.What is the easiest way to get a string containing a control characters or a combination of printable and control characters?
Code: Select all
S = "abc"
StrAppend(S, chr(13))
Code: Select all
S = "abc" + chr(13) + chr(10) + ...
Last edited by Dany on 24 Aug 2023 16:06, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Re: Ascii control charaters in string variables
Thanks for taking to time to look at that for me.
I should be able work around the issue I was having and move forward with that information.
I should be able work around the issue I was having and move forward with that information.