LabVIEW Idea Exchange

About LabVIEW Idea Exchange

Have a LabVIEW Idea?

  1. Browse by label or search in the LabVIEW Idea Exchange to see if your idea has previously been submitted. If your idea exists be sure to vote for the idea by giving it kudos to indicate your approval!
  2. If your idea has not been submitted click Post New Idea to submit a product idea to the LabVIEW Idea Exchange. Be sure to submit a separate post for each idea.
  3. Watch as the community gives your idea kudos and adds their input.
  4. As NI R&D considers the idea, they will change the idea status.
  5. Give kudos to other ideas that you would like to see in a future version of LabVIEW!
Top Authors
cancel
Showing results for 
Search instead for 
Did you mean: 

Default Data Function

Status: New

I'd like to see a function that provides default data for any given data type. I think there could be multiple uses for this; I've detailed mine below.

 

In this example, I have a test results array that is indexed by test number. If I run tests out of order, I want be able to fill in the results of the array at the desired index. To do this, I have to add empty rows to the results array up to the current test's index. To do get the default data I used a diagram disable structrue with an empty "Enabled" case, with the output set to "Use Default if unwired. This is obviously a kludge.

 

default_data_disable_struct.PNG

I'd like to see a function that takes in any data type and returns the default data for that type:

default_data_function.PNG

 

 

Message Edited by RandyP on 03-02-2010 11:42 AM
Message Edited by RandyP on 03-02-2010 11:45 AM
-Randy
-=--=-=-=-=-=-=-
Nothing like a good dose of LabVIEW to cure what ails ya'.
20 Comments
Trusted Enthusiast

On basically any constant, you can go to "Visible Item > Label" and "rename" the constant. Another way to rename data on a wire is to run the wire through a Typecast, typecasting to the exact same type, except that the constant has a label. This is especially handy for registering dynamic events so that your Event Structure has descriptive event names.

 

DataNaming.png

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Member
Doing this conversion with typecast is dangerous. It will let you do conversions that will completely misinterpret your data. I built a node a few years ago that will coerce data to a type you provide. This only allows conversions that would be allowed by coercion dots. So it can still lead to loss of precision between numeric types but it will not treat the bits of your double as an integer. This is useful to typing non-typedefed data into a typedef type. It can also be used to change the data name on a wire. Check this post to get the node. All you need to do is create a constant compatible with your data, change its name to what you want and wire it to the middle terminal.
Message Edited by GregR on 03-05-2010 08:58 AM
Knight of NI

Greg,

 

Something is wrong with your link.  It points to the Beta forums.  As a result, it takes me back to the main NI Discussion forums page.

Trusted Enthusiast
GregR, so the node does basically the same thing I illustrated, it just protects you? By all means, that sounds useful to include in the base package.
Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Member

Sorry for the link to the beta forum. That was my workaround to this forum not letting my update an arbitrary file. Let's try a different approach. Below is an image with an embedded diagram. You should be able to drag this image to your LabVIEW 2009 diagram and get the node. If it doesn't work from the browser, try saving the image locally and dragging the png file to your diagram.

coerce to type.png 

Message Edited by GregR on 03-05-2010 10:38 AM
Trusted Enthusiast

Bingo. Would you consider including this in the LV Base Package under the Conversion or Data Manipulation palette? This function has strong overtones as a solution to altenbach's A universal conversion bullet. For that solution, rather than the input, maybe a polymorphic selector?

 

 

SafeCoerce.png

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Member
Personally, yes I would like to see it exposed in the palettes. I'll see if I can get it in the next release.
Trusted Enthusiast
Make it an idea, I'll vote. That is much safer than my current method that I have used numerous times.
Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Knight of NI

I really like GregR's Coerce to Type function.  I've saved a Snippet of it on my desktop so I can paste it into my code where needed.  Is it possible to post instructions to tell us how to add it to the Function Palette (as a User Function or AddOn), and/or how to make it accessible with QuickDrop?  This is much too useful to leave "flopping in the breeze" -- it needs to be made an (optional, perhaps) part of the LabVIEW Function palette.

 

Bob Schor

Trusted Enthusiast

1. Create a New Sub VI

2. Drag the snippet to the BD

3. Select the node and copy to clipboard

4. Edit the Icon, clear the default icon and then paste the node image

5.  Save the VI with the name 'Coerce to Type'  This could be in user.lib if you like so it just shows up.

6.  Edit the palettes, add the VI if you did not save it to user.lib

7.  Go to the VI in the palettes, right-click and select option to place VI contents.

8.  Save changes.

 

There is a QD shortcut to add selected code to the palettes, but I would go the long way to get the cool icon.

 

QD CoerceToType.png