LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Static arrays

Solved!
Go to solution

Eric: that’s where I will get to in the future as the app does require that approach - there are other elements that can be defined externally in the same manner - but at the moment, I.e. V1, I was keeping it simple.

 

Bill: that’s a great idea (cluster), thanks. And actually it will work very well for what I need right now, I don’t know why I didn’t think of it.

0 Kudos
Message 11 of 26
(716 Views)

You could have the best of both worlds.  Define a tag with default values that you can use now.  Later, you can read values into that tag from a file, instead, and not have to do anything to your code..

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 12 of 26
(712 Views)

That is another option as well. I had not considered that. Good catch.

0 Kudos
Message 13 of 26
(711 Views)

 


@andrewDJ wrote:

Eric: that’s where I will get to in the future as the app does require that approach - there are other elements that can be defined externally in the same manner - but at the moment, I.e. V1, I was keeping it simple.

 

Bill: that’s a great idea (cluster), thanks. And actually it will work very well for what I need right now, I don’t know why I didn’t think of it.


It may be worth the effort to do it now and get it out of the way. It's pretty easy to do assuming NXG and classic LabVIEW behave the same.

0 Kudos
Message 14 of 26
(707 Views)

I had considered using a Tag as a way to maintain the values across launches - given it’s a constant - but I think I’d got hung up on it being an Array data type!  I’ll have a think about cluster with defaults vs tag this evening.  Thanks for the great input guys.

0 Kudos
Message 15 of 26
(699 Views)

@andrewDJ wrote:

Unfortunately, when you set a value as default for the array, it means that every entry is that default value so that won't work unfortunately.  [EDITED this sentence to make it clearer.  Basically, Set As Default on an array applies to every entry in that array]

 


In classic LV, it will set an element default if you right-click the element but it will set an array default if you right click the border/edge of the array.

0 Kudos
Message 16 of 26
(690 Views)

Maybe I did it incorrectly - I’ll double check in the morning.  Thanks for letting me know.

0 Kudos
Message 17 of 26
(685 Views)

Bert: I checked this morning and in NXG, there is no default setting for the array as a whole (clicking on the array outline.)  Clicking on a cell in the array gives the option of entering a default value but it then applies to every cell in the array.  So NXG doesn't work the same way as CG in this respect unfortunately.

 

I think the best approach at the moment is to use a Cluster and turn it into an array when needed.  This will allow me to use Cluster Properties to select a specific value that I need to use but also iterate through all values when I need that.

 

These values will never change.  Obviously, never say never right!?  If the values do change then there will be more work to implement the implication of that so irrespective of how I implement this - hard-coded in a cluster or tag, or loading via file - there will be more work to do.  Because I've not fully implemented my app right now, I don't want to go with a file-based approach; when I move onto V2, which I intend will allow users to externally configure and run this through spreadsheet entries (but they can't change these values as they aren't user modifiable,) I may look at implementing file loading then.

0 Kudos
Message 18 of 26
(602 Views)

Not sure what you are experiencing, but when I create a gtype array with default values and save it that way, then create a tag based on it, I always get those values out, even after closing NXG and re-opening.  It behaves exactly like a LV Classic global.

 

This is also true when I drop the gtype right on a front panel.

 

Edit:

That's actually a pretty ugly solution, isn't it?  You don't really want to have your gtype need to have default values in most cases, do you?  You can probably strike this off the list of ways to accomplish your goal.  Oh, well, sometimes my ideas are good, sometimes... not so much.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 19 of 26
(596 Views)

I can only say that the array on my gtype behaves as I describe above: clicking on the array itself gives me no default option; selecting a cell and entering a default value copies that value to all 'potential' cells, by which I mean, those that appear greyed out until I actually type a value in.

 

I understand what you say about the Tag, and I thought about doing it that way at one point.  I've even tried using the built in data type enumerator - drop a 'Check for contained data type' function from the data parsing function in the Variant palette and use the 'data type to find' connector to pull out a default control) but that doesn't work either.

 

For what I intend, your idea about using a Cluster is perfect so thanks for that.  I also think it's good to explore other ideas because I invariably pick up something I didn't know it could do.  I've only been playing with NXG for a few weeks and not used classic at all so I'm always discovering new things!

 

The bugs are killing me though 😞  Surely this is still a beta??

0 Kudos
Message 20 of 26
(586 Views)