LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

finding ascii value

Hi All,
 
Although I think this is a silly question, I would still like to know how can I find the ascii value of a particular character entered in a string control.
e.g. the Ascii value for 0 is 48, a is 97 and A is 65
 
Thanks in advance.
0 Kudos
Message 1 of 13
(4,518 Views)
Here you are
 
 
The type Cast function can be found in the "Advanced > Data manipulation" subpalette

Message Edité par chilly charly le 12-27-2005 10:02 AM

Chilly Charly    (aka CC)
Message 2 of 13
(4,517 Views)
Hi CC,
 
I tried doing the same, but I couldn't get the proper answer. Find attached the vi.
0 Kudos
Message 3 of 13
(4,513 Views)

Sreedar,

You have represented type as I32, change it to U8

Regards

Dev

 

Message 4 of 13
(4,510 Views)
Just change the representation of your constant to a U8 since the ASCII value is coded on a single byte. Otherwise LV pads the additionnal bytes with zeroes, leading to a wrong value
Chilly Charly    (aka CC)
Message 5 of 13
(4,514 Views)
Thanks Dev and CC for your help.
0 Kudos
Message 6 of 13
(4,502 Views)
Hi CC
 
What is the major advantage in using type cast for any string to ASCII U8.Other than Using thiz LV function
Converts a string into an array of unsigned bytes. Each byte in the array has the ASCII value of the corresponding character in the string.

0 Kudos
Message 7 of 13
(4,466 Views)

Hi,

There is no  'Major Advantage' as such, of using 'type cast' over 'string to byte array' function.

The requirement in this case was to display a single string's ascii equivalent, hence typecast( which only converts first element in the string) was used.

If finding the 'Ascii equivalent' of a each element in a set of string characters was the requirement, then 'string to byte array' function would be a better choice.

regards

Dev

 

 

Message 8 of 13
(4,462 Views)

Hi guys

I'd use the "string to byte array" function, because I think it is not such a good coding, if you cast a string to a single U8. If you could enter a single character - ok, but as this is not provided, I'd suggest to use the mentioned function.

Thomas

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 9 of 13
(4,455 Views)


becktho a écrit: ...it is not such a good coding, if you cast a string to a single U8. If you could enter a single character - ok, but as this is not provided...

I'm curious. Is there a technical reason behind, or is this just a personal opinion ?..
Chilly Charly    (aka CC)
Message 10 of 13
(4,428 Views)