LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set array element focus programmatically

Solved!
Go to solution

Hi Guys,

I created a program which gets value from array via reference.
My problem is this method starts to get value the last element because that is on focus.
If I click another element (for example second) and run the program it starts to get value the second element.

I would like to set programmatically the focus on the zero element.

Is there any property to set the focus or other method to get the values?

 

Thanks a lot!

 

Best regard,

Roland

0 Kudos
Message 1 of 8
(5,045 Views)

Hi Roland,

 

what's the whole point of your VI?

Why don't you read the array value?

Why don't you parse the serialized string completely/correctly (as you already try to read the number of elements in the array)?

(Don't get upset by these questions as sometimes it will be easier to answer the general question instead of focusing on another workaround for obscure algorithms.)

 

I think in the OpenG library (found using VIPM) you will find functions to parse "generic" data as you seem to try here…

Best regards,
GerdW


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

I can't open your VI as i'm on Lv2011 today, but from your description i tried this:

ArrayElementRef.png

Hmm, the snippet lost the event type, i used Mouse Up in this case.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 8
(5,017 Views)

This doesn't work properly unless there is only a single element of the Array visible at the time of the event being raised.

 

So the workaround is clear, limit the view to the element you want and then and only then are you guaranteed that the "ArrayElem" is actually pointing to the element you want.

 

Horrible stuff but hey, it's been that way so long we can call it tradition now.

 

Shane

0 Kudos
Message 4 of 8
(5,003 Views)

Hi all,

 

I saved the VI a previous 8.0 version and a made a picture which show my problem.

If I click into the zero element and after I run the VI the program will start to read with zero element (Good result.jpg)

But I click into the second element and after I run the VI the program will start to read with second element (Bad result.jpg)

I'd like to set the focus on the zero element programmatically. In the original program this array is generated by program so the focus is on the last element.

In the original program I've got one reference input that's why I used this way to solve the problem.

This VI just shows my problem.

 

I'm sorry for my bad English. I hope I can describe well my problem.

 

Thanks a lot.

 

Best regard,

Roland

0 Kudos
Message 5 of 8
(4,971 Views)

Yes, this is exactly the problem.  What you want to do will only work (and I'm repeating myself here) if you have a SINGLE visible element of your FP array control (or indicator).

 

The property "ArrayElem" returns a reference to the last active FP cell (UI-wise) which is not the same thing as the last Array element (data-wise).  You can only do what you want if you programmatically reduce the size of your array so that one cell is visible.  Then LV has no choice but to point to whichever cell is addressed by your array control indices.  Otherwise you can hope and pray it works, but more often than not it won't.

0 Kudos
Message 6 of 8
(4,965 Views)
Solution
Accepted by topic author Pető

ArrayElementFocusUnRGd.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 7 of 8
(4,962 Views)
Try this (note: it's very kludgey; and it uses a private property).
"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 8 of 8
(4,953 Views)