LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Translating a string into a number (Homework Help)

Hello Everyone, 

Just looking to be pointed in the right direction, not looking for the specific answer as I am still trying to learn LV. 

 

I'm still pretty new to using LV and was wondering if anyone could help me when it comes to converting a string into a number. What I want to do is ultimately "decode" a word and translate it into a number. 

It would follow this code for the translation: 

1=a, 2=b, 3=c, 4=d, 5=e, 6 =f, 7=g, 8=h, 9=i, 0=g and -1 otherwise. 

 

Example would be the number 365 is written as cfe. 

 

TIA!!

0 Kudos
Message 1 of 6
(91 Views)

This smells like homework. What have you tried?

 

Once you describe what you tried and where you got stuck and show us you attempt, we'd be happy to comment.

0 Kudos
Message 2 of 6
(87 Views)

Hi yes this is a homework problem! I am not looking for the answering just rather trying to figure out how to go about this. I used 2 array constants where I dragged the string and numbers into them. Then for the string input for the user I connected it to a string length then connected it quotient and remainder to see if length mod 2 ==0. 

 

Im now planning on using a for loop with a string subset where I will connect the user string input to it. This is as far as I have gotten 

0 Kudos
Message 3 of 6
(81 Views)

You have a string (word), not an array of strings as input.

 

You can convert your string to a byte array and use it to index into a lookup table, (or suitable map), iterating over all characters of the input.

 

Your problem is actually not clear, especially the "-1 otherwise". For example if the word input is zzzzz, would the result be -1-1-1-1 or just -1?

How long can the word be?

 

Can you explain why 7 and 0 are both "g"?

 

 

0 Kudos
Message 4 of 6
(58 Views)

Assuming "0" is actually "j", here's a quick draft. See if you can figure it out.... 😄

 

altenbach_1-1741052547551.png

 

 

0 Kudos
Message 5 of 6
(33 Views)

My bad, you are right it would just be -1. 

 

0 should be j, I mistyped by accident. 

0 Kudos
Message 6 of 6
(13 Views)