LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fixed (Default) Array Lengths in Typedefs

We are working with some proprietary subVIs (i.e. password-protected) that require a cluster of various elements going into them. One of the possible cluster element types is an array, which must contain the exact size (array length) that is necessary for the application in order for the subVI to work.

 

The problem is that the array lengths for many of these arrays have been changing as our project continues to progress. We have developed code to automatically generate a new typedef based upon a struct file, and it initializes arrays to the correct lengths, however the array lengths do not update in any of the typedefs that currently exist in the project. The only way I've been able to figure out how to do update the array sizes in the typedefs, is to delete and re-add every instance of the affected typedef in the project (which kind of defeats the whole purpose of using a typedef). This is becoming very cumbersome as we now have 100+ typedefs, and each one is used 5+ times in our code.

 

Anybody have any work arounds? Can I reinitialize all typedefs in a project to default values?


Note: I'm ideally looking for something that doesn't execute at run-time because this is code that is running on a RT target running Linux x64 which has various limitations.

0 Kudos
Message 1 of 9
(4,038 Views)

VI Scripting is probably your best bet here. You can create a script which traverse your VIs looking for the typedef, then update the value with a new default value. Here's a quick and dirty example:

typedef_script.PNG

Edit: VI Scripting is enabled under Tools -> Options -> VI Server -> Show VI Scripting functions and methods




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 2 of 9
(4,001 Views)

Thanks, that is what I figured, but I'm pretty new when it comes to VI scripting. Going to give it a go tomorrow.

0 Kudos
Message 3 of 9
(3,986 Views)

@ajf200 wrote:

Thanks, that is what I figured, but I'm pretty new when it comes to VI scripting. Going to give it a go tomorrow.


That's the spirit!  I had a situation where I needed to construct a huge Cluster TypeDef based (I kid you not) on an Excel WorkSheet (the Cluster was going to correspond to the data in each Excel Row, with the Element Name being given by the Column Headers (e.g. "Run Number", "X Position", etc.) and the types deduced from the values found in Row 2 (e.g. an I32 if the element was numeric only with no decimal point, Dbl if numeric with decimal point, Boolean if "True" or "False", otherwise "String").  The Cluster had >50 elements, and the Excel WorkSheet structure kept evolving, so doing this "by hand" was very painful.  So I (trial and error) learned how to write a simple LabVIEW script.  Have done a few more, but go back to this example to "refresh my memory" ...

 

Bob Schor

0 Kudos
Message 4 of 9
(3,949 Views)

Yeah we are basically doing that right now using VI scripting to create the typedef, although it’s not a spreadsheet file so parsing is a little more in-depth. That being said I didn’t write those VIs.

 

I think I got something working yesterday in a small prototype VI. Going to scale it up today.

0 Kudos
Message 5 of 9
(3,936 Views)

I wrote about the issue of the default values of type def's changing when edited in This Nugget about Type defs (more thatn 12 years ago. How time flies!).

 

(skip to the bottom of the Nugget to see the images I included)

 

I suggested creating sub-VIs that explicitly set the values when ever default values are desired.

 

I think that is worth investigating.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 9
(3,918 Views)

@Ben wrote:

I suggested creating sub-VIs that explicitly set the values when ever default values are desired.


Either create VIs that contain the constants with the correct sizes, or wrap the PW protected VIs. The wrapper could force the correct size.

 

Of course if the library is a class, you can make child. But most libraries are not that convenient Smiley Sad.

0 Kudos
Message 7 of 9
(3,892 Views)

wiebe@CARYA wrote:

@Ben wrote:

I suggested creating sub-VIs that explicitly set the values when ever default values are desired.


Either create VIs that contain the constants with the correct sizes, or wrap the PW protected VIs. The wrapper could force the correct size.

 

Of course if the library is a class, you can make child. But most libraries are not that convenient Smiley Sad.


And I BELIEVE you can save defaults to a class constant and they will stick.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 9
(3,884 Views)

@Ben wrote:

wiebe@CARYA wrote:

@Ben wrote:

I suggested creating sub-VIs that explicitly set the values when ever default values are desired.


Either create VIs that contain the constants with the correct sizes, or wrap the PW protected VIs. The wrapper could force the correct size.

 

Of course if the library is a class, you can make child. But most libraries are not that convenient Smiley Sad.


And I BELIEVE you can save defaults to a class constant and they will stick.

 

Ben



@Ben wrote:

wiebe@CARYA wrote:

@Ben wrote:

I suggested creating sub-VIs that explicitly set the values when ever default values are desired.


Either create VIs that contain the constants with the correct sizes, or wrap the PW protected VIs. The wrapper could force the correct size.

 

Of course if the library is a class, you can make child. But most libraries are not that convenient Smiley Sad.


And I BELIEVE you can save defaults to a class constant and they will stick.

 

Ben


That is correct.

Message 9 of 9
(3,880 Views)