Page 1 of 1

Is there command to do reverse of Chr()?

Posted: Tue May 24, 2022 7:57 pm
by Bugala
I can do:

Code: Select all

Var = 65
debugprint(chr(var))
and it will print A

However, I would need the reverse of this, is there something like:

Code: Select all

Var = "A"
Debugprint(ReverseofChr(var)
Which would then return 65.

Does that exist?

I can only see Val() command that looks like it, but that looks like it makes a whole string into a table, and therefore won't work in my case where I have a number as a string, and I try to check if next one is "." or not, as in:

Code: Select all

If t_sum[n] = 0 And HaveItem(t_sum, n+1) = True And t_sum[n+1] <> "." Then zeroestoremove = zeroestoremove + 1
Problem here is that at the point when it is checking t_sum[n+1] <> ".", it will be attempting to compare a number with "." and throws an error.

I could do it some other way of course, but then it wouldn't fit into one line anymore, making the code messier to read, which it is enough already even now.

Re: Is there command to do reverse of Chr()?

Posted: Tue May 24, 2022 8:32 pm
by emeck
Hello,

could ByteChr() be what you need?

Re: Is there command to do reverse of Chr()?

Posted: Tue May 24, 2022 8:32 pm
by plouf
its Asc()

Code: Select all

DebugPrint (Chr(65)) 
DebugPrint(Asc("A"))

Re: Is there command to do reverse of Chr()?

Posted: Wed May 25, 2022 8:37 am
by Bugala
Thanks! Didn't realize that one when I was looking through the String Library.