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!
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
Member
<< Comment Retracted >>
Message Edited by RandyP on 03-02-2010 11:59 AM
-Randy
-=--=-=-=-=-=-=-
Nothing like a good dose of LabVIEW to cure what ails ya'.
Member

I'm not trying to say that a default data function might not be useful, but in your example there are other answers.

 

Indexing an array out of range will return default data. This means that by changing your constant 0 to -1, the need for the node is removed. This is shown in the image below.

 

However even that is unnecessary if you use Reshape Array (second diagram snippet). This shows using reshape then append. Performance could be better if you add one to the size for the reshape and use Replace Array Subset on the new data. I'm assuming you are doing that in the false frame of your case structure, so that could be pulled out as common code after the structure.

 

diagram.png

Trusted Enthusiast

Also, keep in mind that once View Cluster Constant as Icon is shipped, it is going to be much, MUCH less painful to drop typedef'd constants. (That's clever use of the disable structure I've never seen. You could drop the Index Array inside the Disabled case to gain just a miniscule bit more performance and BD space.)

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Member

Thanks. I guess this is just a case of me needing to code smarter. I didn't realize indexing out of bounds returned default data (though it certainly makes sense), but reshape array is definitely the tool I should've used. I haven't made a habit of using much up to this point; I should consider using it more.

 

I do now seem to remember hearing something about the View Cluster Constant as Icon change. That would be great! I do still wonder if there might be other good uses for a "default data" function, but maybe an iconized cluster constant would solve any such issue. If this function existed, can anyone speculate on its performance as compared to using a typedef'd cluster constant?

-Randy
-=--=-=-=-=-=-=-
Nothing like a good dose of LabVIEW to cure what ails ya'.
Trusted Enthusiast

View Cluster Constant as Icon is In Beta. I would speculate that the compiler could interpret the Default Data function as just a constant, so it would be the performance equivalent of dropping a constant. I would have voted for this idea if it were not for the View Cluster Constant as Icon, just to get cleaner BD's, but that idea has covered probably 90% of the instances where I would want to use the Default Data function. This idea is intriguing, but I can't think of a good way to use it yet.

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Trusted Enthusiast

Consider the following. What would you expect the Default Data function to return... 0 or -1?? This function may actually be useful, and provide a way of doing something that we currently can't do. While you chew on that, chew on this: Add a Terminal that Defines Default Data for Reshape Array.

 

DefaultData.png

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Member

-1 would never make sense for the same reason that the other usages return 0. The actual question is 0 or 1, but the answer is definitely 0. If you were going to use the source control's default as the return value of the node, this would return the 4 element array from the constant. That would mean that the index array is indexing the 0th element which is 1.

 

There are too many cases where the node couldn't trace back to a control or it would be inappropriate to do that so that would never be the implementation.

Trusted Enthusiast

GregR wrote:

There are too many cases where the node couldn't trace back to a control...


Yes, you are right - this could be dangerous unless you can certainly trace all the way back to a control or constant. The question I was asking above is whether you would expect the "Default Data" function to return a zero-element array with "fill value" of 0 or -1.

 

The same question would have applied to a FP terminal, say a Numeric DBL where you specified "Data Operation > Make Current Value Default" as -1. If you called the "Default Data" function, would it return -1 or 0 for that terminal?

 

 Either question, the answer really doesn't matter because of potentially unexpected behavior you pointed out.

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Member

Yes. I agree that default array values should always be constrained to the constant or control in which they exist. I think default data should remain "untouchable", in the sense that the default data for a given datatype shouldn't be changeable. I can see maybe making it an environment variable, but even that just seems too dangerous.

 

That said, I really like your idea, JackD, for the array reshape function--to have the option to use something other than default data to fill the empty array spots. In your idea, the definition of the default data itself isn't changed.

-Randy
-=--=-=-=-=-=-=-
Nothing like a good dose of LabVIEW to cure what ails ya'.
Member

(Off-topic) - As I've been thinking about Jack's idea that default data might be linked to a parent array, a somewhat related question came to mind. Is it possible to rename data? If so, feel free to point me to a forum link explaining how. I'm debating posting that as an idea, but I don't know if people would care enough/it would really help that much.  Come to think of it, I want it to easily name cluster elements, and View Cluster Constant as Icon would do that for me (since it wouldn't be ugly to have an initialization cluster).

 

Still, if it's possibly to re-name data, let me know. Thanks!

-Randy
-=--=-=-=-=-=-=-
Nothing like a good dose of LabVIEW to cure what ails ya'.