Is there command to do reverse of Chr()?

Find quick help here to get you started with Hollywood
Post Reply
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Is there command to do reverse of Chr()?

Post 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.
User avatar
emeck
Posts: 169
Joined: Fri Apr 03, 2015 3:17 pm

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

Post by emeck »

Hello,

could ByteChr() be what you need?
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

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

Post by plouf »

its Asc()

Code: Select all

DebugPrint (Chr(65)) 
DebugPrint(Asc("A"))
Christos
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

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

Post by Bugala »

Thanks! Didn't realize that one when I was looking through the String Library.
Post Reply