LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

STRINGS AND FILE I/O

Good Morning Motivators,

                                        I was trying to write a VI  which involves representing numbers in coded format, but I have no idea. Please help me if you can.

This is the question:

Suppose we want to represent numbers in coded format. Consider the following code:

            1 = lv, 2 = ma, 3 = po, 4 = ni, 5 = be, 6 = ut, 7 = ke, 8 = su, 9 = lu, and 0 = ha

            For example, the number 987 is written in coded form as lusuke. Create a VI that takes a string as an input and outputs the equivalent number on a numeric indicator. Display the number -1 if the input code does not translate.

0 Kudos
Message 1 of 17
(3,982 Views)

You will need Search/Split Sting to get 2 characters at a time.  From there, use a lookup table to convert your two characters into a number (hint: use Search 1D Array which will give you the index of the match or -1 if there was no match).

 

Give it a try.  We will not do your homework for you.  If you have specific questions, ask away.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 17
(3,958 Views)

Hello everyone!

Here is my solution. I need to work more in my discipline of programming. 

 

If It works, It ain't stupid!

Regards!

0 Kudos
Message 3 of 17
(3,939 Views)

General comment:

If you know how many times a loop will iterate, use a FOR loop.  In this case, you can use an autoindexing input tunnel to tell the loop how many times to iterate.  That would save you quite a bit of code in there (for FOR loop would just contain the Search 1D Array).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 17
(3,934 Views)

Define an enum that has your encodings, then use it to scan from string.dec.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 17
(3,910 Views)

@paul_cardinale wrote:

Define an enum that has your encodings, then use it to scan from string.dec.png


There was a discussion a while back where I remember where this can lead to false matches.  I can't remember why.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 17
(3,894 Views)

@billko wrote:

@paul_cardinale wrote:

Define an enum that has your encodings, then use it to scan from string.dec.png


There was a discussion a while back where I remember where this can lead to false matches.  I can't remember why.


If there is not a match, you will still get a 0, so this will not meet the requirement of a -1 when there is an invalid code.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 17
(3,889 Views)

dec.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 8 of 17
(3,884 Views)

@paul_cardinale wrote:

dec.png


Who'd have known I'd be using this very code today?  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 17
(3,856 Views)

Hi Jimbe,

              I was looking at your snapshot and I had a quick question for you. How did you create the two tables ( One in pink and the other in blue)? Are they linked or something. I have trying to figure but no luck.

Thanks.

Vincent

0 Kudos
Message 10 of 17
(3,829 Views)