LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Not case sensitive string comparison

No Lynn,

 

My strings consist with printable characters only.

 

A bit of explanation why I do need more clever comparison function.

 

The strings I'm comparing are commands I send to the subsystem. I'm comparing the strings/commands against the dictionary for the syntax correctness. To do that my colleague converted everything to the upper-case and then he did comparison. He took the converted strings and since this moment rest of the system works using these upper-case style strings/commands.

 

The syntax is correct. But toghether with the syntax the rest of the string got converted as well. It was not the problem untill one with the measurement devices we use makes the distinction between upper an lower cases. The keyword "POWER' is not recognised because for the device words 'POWER' and "Power' are completly different.

 

For my case the best would be to relax the comparasion policy to 'a' = 'A' level. But unfortunatelly there is no this quite straighforward option in LabVIEW.

 

0 Kudos
Message 11 of 23
(2,099 Views)

If POWER and Power mean different things for your device, then you don't want a case insensitive comparison.  You want to know that the two are different.  So I don't really understand what you are asking for here.

 

0 Kudos
Message 12 of 23
(2,095 Views)

Ravens Fan,

 

There is a bit of history behind.

 

Before I send the command to the device the command syntax is checked. This operation is based on string comparasion. To  do the comparison the string is converted to the upper case. It is only one reason why the string is converted. To make the comparision in LV.

 

Converted in this matter string is upper-case. Toghether with all its elements.

 

And because the crucial keyword is converted as well (it's not demanded, side effect from the syntax check operation) it

makes problems for me.

 

If I could have case insensitive comparison operator I wouldn't need to do uppercase conversion and the same my caps lock sensitive keyword would be saved.

 

That's why.

0 Kudos
Message 13 of 23
(2,089 Views)

DO not change the string that is passed only check the upper case and then pass the orginal command. You can use what I gave you and see if it is the same then pass the orgianl command if it is.

Tim
GHSP
0 Kudos
Message 14 of 23
(2,079 Views)

Yes, I thought about this.

 

The whole project is big enough to to that.

 

The case insesitive coprarison would be great for it.

0 Kudos
Message 15 of 23
(2,076 Views)

You can do it this way and you get waht you want. If you get a match then you just pass on the matched value and you do not have to worry about case

 

Example_VI.png

Tim
GHSP
0 Kudos
Message 16 of 23
(2,074 Views)

It seems to me you have a two part string, a command and some parameters.  You want to check the command ignoring case but leave the case alone for the remainder of the string.  I (surprise, surprise) would use a variant in this case such as the following snippet:

 

CommandDictionary.png

 

On the first call, I build a dictionary using the list of commands in the Commands array.  The variant attribute name is changed to all caps while the value is the original string from the Array.  Next, the Command is extracted from the string, I assume that space is the separator, change as needed.  This command string is converted to All Caps to search the attribute names for a match.  If found, the properly capitalized version is returned (ie. POwer could be changed to Power) and the rest of the string is appended.  Commands which do not match are simply passed through as is.  The Boolean is used to indicate a valid command.

Message 17 of 23
(2,061 Views)

My solution for this is to convert the string to be searched to all lower case and then search that string with lowercase keyword/regex

----------------------------------------------------
Studying for CLA.
LabVIEW, inherit from social media habits!
0 Kudos
Message 18 of 23
(1,468 Views)

Here is my solution for the problem. I'm using arrays and convert all letters to lower case. The matching results are shown as they were before converted to lower case. Hope it helps to someone.

 

BlackSupra_1-1689078402622.png

 

 

BlackSupra_0-1689078375384.png

 

0 Kudos
Message 19 of 23
(787 Views)

@BlackSupra wrote:

BlackSupra_0-1689078375384.png


1. Why the Index Array inside of the loop?  Just use the autoindexed tunnel.

2. If using a newer version (2014?), you can use the conditional indexed output tunnel instead of the shift register, case structure, and build array.

3. Why in Input List using a local variable instead of the terminal?


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 20 of 23
(778 Views)