09-22-2021 05:03 AM
Dear fellow Labview enthusiasts,
My question is to put it simply: Can I add predefined numeric constants into my Functions Palette?
What do I mean by that, lets say you use quite often the number 27 with data type u32 as a constant in your programming. To do this you have to drop a numeric constant then type in the number 27 then right-click and changing the data type to what you want. Can I create a custom sub-palette in my Functions Pallete where I have "commonly used constants"? I know I can add VI`s to my Functions pallet, so I guess I can make a subvi that spits out the number 27 as a u32 and whack that into my sub-palette, but that looks ugly and not visually appealing. A subvi is a massive square with an icon I have to draw.
Soo... yeah... is there a way to add custom constants into my palette? Any ideas? The same way I have Pi as a DBL constant in my Maths palette by default (or under "Numeric", I don't remember but you get the point).
Solved! Go to Solution.
09-22-2021 05:27 AM
Vi icons can be small. See the attached example. Hint: select and cut the whole icon, then make a small box.
Making a vi for one constant seems overkilling. It's possible that the compiler optimizer converts it to the actual constant, I'm not sure. In any case, you can enforce this behaviour making the vi inline.
09-22-2021 06:46 AM
If you create a VI containing the constant and place it in the palette there is an right-click option 'Place VI Contents' in the palette editor. This will place the constant on the BD instead of the VI, if you choose the item in the palette.
UliB
09-22-2021 06:59 AM
Make a "Place VI Contents" VI as was previously suggested. VIPM is by far the easiest way to get functions into the palettes IMO. You can do it without VIPM but it has a nice interface that makes things easy.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
09-22-2021 08:54 AM
We already have the right answers.
I am backing the same idea, create VI for each constant, add these VIs to the palette, configure the palette to place VI contents instead of SubVI.
Secret - this is how some of LabVIEW's palettes work too!
09-22-2021 09:41 AM
genius! I didn't know you can configure it so it places the vi contents rather than just a vi.
09-22-2021 09:42 AM
thanks for the suggestion. I will make it into a package.
09-22-2021 11:23 AM - edited 09-22-2021 11:57 AM
@datatechNDT wrote:
What do I mean by that, lets say you use quite often the number 27 with data type u32 as a constant in your programming.
A thought on 'use quite often the number 27 as a constant'.
'Pi' is a constant, '60 seconds per minute' is a constant.
'27 commands for my instrument' might be constant right now, but can change in the future.
And if someday 27 changes to 28 you have to find every instance of the constant and change it.
Have a look at
(presentation and comments) for advantages of having a constant in a VI (as suggested by pincpanter).
UliB
09-22-2021 11:44 AM
Please do consider recommendations of pincpanter and UliB, depending on what this "constant" means to you, it could either be set in stone or a named constant whose value you would like to update in the future.
09-23-2021 03:13 AM
The main use case behind my constants is when I manipulate binary files. Most of the time you chop and typecast into different data types and I just wanted to have a quick drop-down for data types and certain values that I use when manipulating those binary files. Because so far the way I typecast is you drop the typecast function then you drop numeric constant- right click - change data type... any way. Thank you for the help guys. I made my palette and configured it to drop VI content.. game changing 😄