NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Announcements
The NI Idea Exchange is a product feedback forum where NI R&D and users work together to submit ideas, collaborate on their development, and vote for the ones they like best. View all of the NI Idea Exchanges to post an idea or add your opinion on an existing one today!
Jorge_C

"Variable" constant and Strict Type Def behaviour

Status: New
by Active Participant Jorge_C on ‎07-26-2012 04:51 AM

Hi all!

 

I know the title doesn't make sense, so I will try to explain.

 

I think it would be a good idea to have a way to define values similar to the C instruction #define. In C code, you can define constants and change its values all over the code during development time.

 

Right now, there is nothing like this in LabVIEW. You can use controls and variables, or controls and property nodes.

 

(Strict) Type Defs for controls have kind of the same philosophy, you change things on a single file, while all the instances are updated (but there is no way to define a single value for all the instances of a control). I guess in LV it would make sense if we could define a constant file, and place it in every block diagram that we want to get that value.

 

Don't you think it would be a good idea?

 

I tried to define a Strict Type Def with a range where only one value is possible, and the coercing options. Anyway, the behaviour is not what I expected, as it seems that the control doesn't look at its own properties until you try to change its value. If the control has a default value of 4, and you change the valid range to [5,5], the control will have the 4 value until you try to change it (and then the value will be coerced to 5).

 

I don't think that is a good behaviour, do you agree?

 

PS: I think it would be great to have a "User Defined Type Def", in which you could define the things that stay the same and the thing that doesn't, but I know that idea is not mine :smileyvery-happy:.

 

Regards!

Comments
by Member V._Alonso on ‎07-26-2012 05:43 AM

I think it's very useful, almost necessary, to define CONSTANT (e.g. number of channels, times, ...) that are known at compile time.

This is somewhat similar to "# define" as used in C.

by Knight of NI on ‎07-26-2012 06:09 AM
by Member rgvdh@rdf on ‎07-26-2012 08:04 AM

Create "constants.vi" consisting of nothing but a bunch of meanigfully-named indicators wired to the connector pane and set to the constants you need to use elsewhere.  Paste it in wherever you need to reference a constant, and inline it for speed.  Change it in one place and it instantly changes everwhere else.

 

Is there any funtionality or use case you need to address that the above doesn't satisfy?

by Active Participant Jorge_C on ‎07-26-2012 08:12 AM

Yes tst, that's kind of the same idea (I have already kudoed yours :smileyvery-happy:)

 

And yes rgvdh@rdf, that would be a workaround, but, as discussed in the link tst provided, or up here, I am not saying you can't have that functionality (variables, property nodes, files...), I just think it would be a good idea to include something like this.

by Member rgvdh@rdf ‎07-27-2012 03:53 PM - edited ‎07-27-2012 03:54 PM

I just don't see the point of creating a whole new type of object when an existing object (subVI) does the job (of having you be able to change a constant and have the change propagate.) The term "workaround" only applies if your method would be less effort to program with than mine, and I don't really see how it would be. 

 

With the subvi approach, you can even make the values of your constants be environment dependent by embedding different constant VIs in a conditional disable structure.  I'm having trouble figuring out how to do that with typedefs.

 

What is the advantage you anticipate in using a special kind of typedef rather than a subVI? 

 

Latest LabVIEW Idea Exchange Blog Posts
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!
Idea Statuses
Top Kudoed Authors
User Kudos Count
137
86
71
67
62
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page