From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Coding with a simple If else statement using text file values

Solved!
Go to solution

Hi there Labview Professionals,

 

I have an issue with coding some simple if else statements using text file data.

As attached from the text file I have provided. (When you open the text file, there are 3 long columns of data, variables C G and D respectively.) I have to check the C and G values if they are larger than 0.65.... if one of the values are larger than 0.65, I have to increment a count and the boolean button would light up indicating there is one. The entire process continues throughout the data.

 

So far, I have only managed to create the if else statement with fixed numeric points. Does any of the professionals know how to replace the fixed numeric points through the text file?

 

Much appreciated! 

Download All
0 Kudos
Message 1 of 21
(3,463 Views)
I got a bit confused what you really want but
I think you have to work with In Range and Coerce Function vi
and also Boolean function
0 Kudos
Message 2 of 21
(3,453 Views)

@Hatef.fouladi wrote:
I got a bit confused what you really want but
I think you have to work with In Range and Coerce Function vi
and also Boolean function

Apologies if its too confusing for you.

Basicially, when I load the data file, the if else statement will scan the 3 columns and check individually if any value is larger than 0.65, if it is larger than 0.65 I have to make a output stating that 1 of the data has a value larger than 0.65 for which I have to make use of the boolean button to act as some kind of "LED" to light up if there is a value larger than 0.65.

 

Only the third column is not affected by the if else statement and data will be continued to be read. 

0 Kudos
Message 3 of 21
(3,451 Views)
now what is your problem to solve?
0 Kudos
Message 4 of 21
(3,443 Views)

@Hatef.fouladi wrote:
now what is your problem to solve?

I couldn't link the text file path to the entire if else statement.... am I short of something or what do I need to add it so that the text file data can be read and data can be scanned for values larger than 0.65? 

0 Kudos
Message 5 of 21
(3,433 Views)

Hi

I could not open your file since I am having LV2014. But from your ques i suppose you can open the text file and read the first 2 columns and compare whether its >0.65. i.e read first column and compare. then read second colum and compare.

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 21
(3,423 Views)

@Nghtcrwlr wrote:

you can open the text file and read the first 2 columns and compare whether its >0.65. i.e read first column and compare. then read second colum and compare.


How do you do this part? This is what I couldn't do. I have only managed to create the "greater than" portion.... 

0 Kudos
Message 7 of 21
(3,419 Views)

Hi Lexen,

 

I have to check the C and G values if they are larger than 0.65.... if one of the values are larger than 0.65, I have to increment a count and the boolean button would light up indicating there is one. The entire process continues throughout the data.

Trying to translate your text "word by word" into LabVIEW:

check.png

Read the file, index the columns, compare with your threshold value, "light" a boolean indicator, increment a "count"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 21
(3,418 Views)

GerdW was a bit faster than me 😛

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 9 of 21
(3,413 Views)
and also me 🙂
0 Kudos
Message 10 of 21
(3,410 Views)