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: 

Display message after reaching array's last element

Hello everyone, I have designed a simulation loop and I want to display a message when I take my arrays last element. For example if we have 60 elements, after taking the element num.60 I want to show a message. I attach my try so you can see where I have a problem. 

 

Please respond as fast as possible. It is urgent !

 

Thank you all

0 Kudos
Message 1 of 6
(2,655 Views)

Hi Loukask,

 

use an autoindexing FOR loop to index each element in your array. As the loop will automatically finish you can display a message after the loop has finished…

 

Other solution if you insist of using a while loop and IndexArray in the loop:

IF iteration count >= arraysize THEN display message


 

Please respond as fast as possible. It is urgent !

Keep in mind: It's maybe urgent for you, but not for us! Maybe you should learn better planning of your tasks?

I also recommend to take the basic LabVIEW lessons offered for free by NI. It will surely help you to create better LabVIEW VIs…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,649 Views)

I don't know if you checked my file, but the problem is that the "array size" generates a 1D array output and when I make a comparison with iteration loop the boolean output can't be given as input to message (enabling). check screenshot. 

0 Kudos
Message 3 of 6
(2,627 Views)

Hi Loukask,

 

I don't know if you checked my file,

Yes, I did!

 

the problem is that the "array size" generates a 1D array output

The problem is you seem to be unable to read the two elements from this 1D array.

Did you heard of the IndexArray function before? Did I mention the LabVIEW basics courses before?

 

(Other solution: use the MatrixSize function on your 2D array…)

 

Btw. is there a special reason to make your index counter a DBL? IndexArray expects I32 values for indices…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(2,618 Views)

If you want it to run after the main While loop, then you should place it outside of the While loop (as GerdW's first suggestion suggested) and you can enforce data dependency by using the Stop boolean as an Enable switch.

 

Capture.PNG


GCentral
0 Kudos
Message 5 of 6
(2,597 Views)

You are only reading the first element of each row, so instead of working with a 2D array, slice out the first column (using index array) right after reading the file. Now you have a 1D array and the size is a scalar, not an array.

0 Kudos
Message 6 of 6
(2,574 Views)