ASCII value of a CHAR
Bigsquatch
Posts: 216
Is there a function in Netlinx world to return the ASCII value of a CHAR? Most languages I've used have a built in function for this but I don't find an equivalent in the help file.
I am trying to parse some RDS Radio text and the manufacturer has a ridiculous command format where several "control characters" are reserved and so if you want to use one you have to bitwise OR the value with 64 and use the result instead of the actual value.
Needless to say, when feedback comes from the tuner I have to XOR certain characters to get the intended value.
So I can get the character just fine but now I need to get it's ASCII value (from within my code) to do the manipulation.
PS: I've tried type casting the char to an integer value but oddly enough it doesn't return the ASCII code.
I am trying to parse some RDS Radio text and the manufacturer has a ridiculous command format where several "control characters" are reserved and so if you want to use one you have to bitwise OR the value with 64 and use the result instead of the actual value.
Needless to say, when feedback comes from the tuner I have to XOR certain characters to get the intended value.
So I can get the character just fine but now I need to get it's ASCII value (from within my code) to do the manipulation.
PS: I've tried type casting the char to an integer value but oddly enough it doesn't return the ASCII code.
0
Comments
Select{
Active(nChar[x] == "13"):
Active(nChar[x] == "14"):
Active(nChar[x] == "21"):
Active(nChar[x] == "25"):
Active(nChar[x] == "29"):
{
nChar[x] = nChar[x] BXOR $FF //Or whatever you need to XOR it with
}
}
Obviously, you would need a loop to traverse the data, and I just pulled the ASCII values out of my butt, but I think this will work for what you need.
Jeff
What I need is a function that returns the ASCII value of any specific character.
Hypothetical example:
In the example let's say aCharacter is 'A' , I need a function that returns 65, the ASCII value of 'A'
If you watch the variables in debug and control the channel ON/OFF, you will see that the nASCII value is updated correctly. 65 for A and so forth.
Jeff
The output when button 1 is pushed:
You are right, it does just what i needed.
I had tried TYPE_CAST earlier but I must have had some other issue in my code because it didn't look like it was working.
Unfortunately my approach to parsing the feedback was overly optimistic and I'm going to have to delve into checksums and all sorts of bitwise manipulation if I'm going to get it to work.
Here's a quote from the protocol description:
Unbelievable that someone had the nerve to put the word 'simply' in that paragraph.
Thanks for the help folks.
create another variable that is an integer.
Then do this statement
nInteger=cCharactor[1]
You might get a warning on compile. but it might work.
I gave up on this problem however after I was getting usable text from several stations and then noticed that another station's data was different and contained incorrect codes according to NAD's formatting info.
I hate the old NAD junk, the new models have a very simple ascii protocol that works well.
Well has not been simple for my I am having issues with the data sent back for volume, bass, and trebel levels. I know that when I get 241 for the volume it means it is at -15 but I can not for the life of me get that to happen in the code. Even using tech note 457 I can not get the checksums to pan out.
Take the examples in the protocol to query the device 1,20,20,2,215. I try to get the compliment for 40 and get six thousands something using this instead of the 215.