LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

changing a char-string into decimal

i have a problem:
over my serial connection i just get strings in char but i need decimal numbers!
can you help me!

thx wiesi
0 Kudos
Message 1 of 7
(3,205 Views)
Look in the string palette. You didn't mention what kind of string you're getting, but if you get "123" use decimal (or any other number system) string to number. If you get "9F" use string to byte array. If this doesn't help, post some more details about the string you recieve.

___________________
Try to take over the world!
0 Kudos
Message 2 of 7
(3,192 Views)
Are you getting characters like "3", ".", "5" and need to translate to the number 3.5? If so, just run your string through the Scan From String function. Use a format string of %f. If your characters are something else, please provide a few more details such as the actual characters you're seeing and what they are supposed to represent.
0 Kudos
Message 3 of 7
(3,191 Views)


@wiesi wrote:
i have a problem:
over my serial connection i just get strings in char but i need decimal numbers!
can you help me!

thx wiesi


my string is with char:
so for example "a" for 61; they are all special characters, letters and numbers.
0 Kudos
Message 4 of 7
(3,184 Views)
"a" is ASCII 97, which in hexadecimal is 61. If you use the String to Byte Array VI (in one of the string subpalettes) on your string, you will get an array of these numbers. If you want the numbers to appear as hex, right click one of the indicators in the array and select Visible Items>>Radix. Then, change the radix to X.

___________________
Try to take over the world!
0 Kudos
Message 5 of 7
(3,177 Views)
o.k. thanks!

now i have the number in the first field of an 1-D Array
is there a way to change this into a normal number
0 Kudos
Message 6 of 7
(3,165 Views)

What do you mean "a normal number"? This is a number, 97, and it's inside an array. What do you expect this number to be? To extract it from the array you have various options, from using an index array function to using an auto indexed for loop.

If your problem is with using the array, I suggest you read the LabVIEW user manual. Also, try searching this site and google for LabVIEW tutorials. Here is one you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide.


___________________
Try to take over the world!
0 Kudos
Message 7 of 7
(3,156 Views)