0

I am trying to take the readout from an instrument and if the readout matches certain strings (from the instrument programming manual) I want to set an indicator to a specific value, different for each possible string. A case structure seems like the best option, with all the possible readouts as the cases. I did this and added "" as the default case to send out a value for the no-match case. The trouble is that if I wire the readout string to the case structure it always executes the default case no matter what the readout (and yes, before anyone asks, I verified that the readout strings match my cases exactly). To check that the case structure was working I wired a constant to the case structure and it works fine, even when I copy and paste the value from the readout string to the constant. Also, I made sure that case insensitive matching was selected so that's not the issue. Anyone have an idea why this is happening? I can post sample VI's if necessary.

  • Update: actually comparison of any form (case, equality, etc.) always fails when I use anything other than constants.. Not very useful. – Diggy Doggit Jun 06 '13 at 20:48

2 Answers2

1

Found the problem. Converted the strings into byte arrays and looked at the ascii values. Apparently one had a new line character at the end even though there was no new line on the indicator. Fixed comparison by trimming white space on strings. Look out for that.

1

To check exactly what's in your string you can wire it to an indicator, right-click on that indicator and choose '\'Codes Display. This will then show codes such as \n for newline, \00 for ASCII 0, \FF for ASCII 255, etc.

nekomatic
  • 5,988
  • 1
  • 20
  • 27