LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you write a VI that changes letters in a string?

Solved!
Go to solution

I need to write a programm that changes every letter in a string with the next letter in the alphabet. ('a' changes to 'b' and so on) Can anyone help? (Labview 14.0)

0 Kudos
Message 1 of 9
(5,486 Views)

z becomes a ?

Same for capitals ?

Numbers and other signs remain unchanged ? 

0 Kudos
Message 2 of 9
(5,479 Views)

yes, z become a, same for capitals and there are no numbers and symbols in the text file. 

0 Kudos
Message 3 of 9
(5,471 Views)
Convert the letter to ascii code, add 1 than convert back to letter
0 Kudos
Message 4 of 9
(5,469 Views)

Hi daiana,

 

convert the string to an U8 array and add 1. Then convert back to string…

 

yes, z become a, same for capitals and there are no numbers and symbols in the text file.

This becomes a different problem. Now I would use a lookup table (but still work with conversion to U8 array).

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(5,466 Views)
Check if the number is greater than "z" code then change the number to the ascii number equivalnt to a
0 Kudos
Message 6 of 9
(5,459 Views)
Solution
Accepted by topic author iam_daiana

Use String To Byte Array to make an array of characters.  Then use a FOR loop (autoindexing) to do the conversion.  You will want a case structure to handle the z cases differently from the default and leave punctuation alone.  Autoindex the results out of the loop and then use Byte Array To String.


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 9
(5,456 Views)

This will work with any characters in the text.

 

Change characters.png

 

PS : Am I to generous by providing a code ?

 

 

Message 8 of 9
(5,430 Views)

Congratulations crossrulz for being faster !

0 Kudos
Message 9 of 9
(5,419 Views)