LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview Encode or Decode VI

This is the problem I am working on:
Develop a VI to encode or decode words using a secret code. To encode a word in this code, first separate the word into two substrings – one with the first half of the original word, and one containing the second half. If there is an odd number of letters in the word, then split it so that the first substring has one more letter than the second one.
Create the encoded word by concatenating the first half of the word onto the end of the second half of the word, inserting the second letter of the original word in between these two halves. For example, the word “gravity” would be encoded as “ityrgrav” and the word “master” would be encoded as “teramas.”
Place a string control on the front panel and a Boolean switch allowing the user to select whether the input is to be decoded or encoded. Display the output on a string indicator.

I am stuck on a problem I was given. I specifically am having trouble with dividing the words unevenly. For some reason the way I went about it causes a mix up that does not give me the correct output as requested. Any help would be appreciated!

0 Kudos
Message 1 of 7
(3,843 Views)

@Momoko3 wrote:

For some reason the way I went about it causes a mix up that does not give me the correct output as requested.

We cannot tell what you are doing wrong unless you show us what you are doing (attach a simplified VI). Also, what should happen if the word has e.g. only one letter? 

0 Kudos
Message 2 of 7
(3,838 Views)

Hi momoko,

 

this is a nice example task for learning LabVIEW! (Do you know this?)

 

You should use the functions StringLength, StringSubset and ConcatenateStrings to solve that task…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 7
(3,834 Views)

A useful tools that could be used to solve the division problem is quotient&remainder.

0 Kudos
Message 4 of 7
(3,822 Views)

Perhaps you should show us your code so we can figure out what you are doing wrong.

 


Momoko3 wrote: I specifically am having trouble with dividing the words unevenly.

Get the string length and divide by 2.  Then use the Round To +Infinity.  This at least works for the encoding.

 

Fun little exercise.  I recommend learning the Search/Split String and the String Subset functions.


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 5 of 7
(3,815 Views)

@crossrulz wrote:

Get the string length and divide by 2.  Then use the Round To +Infinity.  This at least works for the encoding.

 


Uee quotient&remainder to divide by two and add the two outputs. Keeps it all blue. No need to go orange!

0 Kudos
Message 6 of 7
(3,800 Views)

Did you ever get a solution? Im still really stuck.

0 Kudos
Message 7 of 7
(3,249 Views)