From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Darren's Weekly Nugget 05/11/2009

There was a lot of buzz over on LAVA last week regarding some neat LabVIEW behavior that I assumed everybody already knew.  So here's a nugget to make it official.

 

When you drop a Numeric Constant on the block diagram (my Quick Drop shortcut for numeric constant is 'nc'), its data type is I32.  If you want to change the data type to DBL, you don't have to go through the Right-click > Representation menu.  Instead, simply type a value in the constant that has a decimal point in it.  Even if you don't want to specify a fractional value, but you still want to change the data type, just end your number with a decimal point.  For example, if you drop the constant, and you want it to have a DBL value of "1", then just type "1." into the constant, and there you go...blue to orange in the blink of an eye!  

 

 

Message 1 of 21
(7,454 Views)
Very sweet. Smiley Happy
PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Message 2 of 21
(7,444 Views)

lol that one of the first things i learned with labview 🙂

 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 3 of 21
(7,443 Views)

Harold Timmis wrote:

lol that one of the first things i learned with labview 🙂

 


That's funny.  That is the most recent thing I've learned with LabVIEW.

 

I hadn't heard about this one before and is so simple, but good to know.

 

Message 4 of 21
(7,425 Views)

Darren wrote:

Even if you don't want to specify a fractional value, but you still want to change the data type, just end your number with a decimal point.


Yes, use it all the time. Has been around forever. (Just tried in LabVIEW 4.0.1 and it works) 😄

 

Here's a wish for improvent: Once I do this, I would prefer if "adapt to datatype" would become disabled. Right now, everything can be nicely wired up in all orange, but if I then change the constant to e.g. 2, it turns blue and forces coercion dot. I need to remember to enter the decimal point every time I edit the constant.

 

LabVIEW should be smart enought to not automatically change the datatype if a coercion would result. 🙂

 

 

Message 5 of 21
(7,421 Views)

yeah my manager taught me it.

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 6 of 21
(7,394 Views)
I have used this for years - Very handy
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
Message 7 of 21
(7,385 Views)

Yup, been using this one since as far back as I can remember Smiley Happy

Any way to easily change the representation from I32 to, say, U16 ?

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 8 of 21
(7,380 Views)

Thoric wrote:

 

Any way to easily change the representation from I32 to, say, U16 ?


Other than using the right-click Representation menu, not really.  I would look for another U16 data type (wire, terminal, constant,etc.) and right-click > Create Constant I guess.

 

-D

Message 9 of 21
(7,371 Views)
I've also known about that for a while, but can't remember how and when I learned about it. The trick also works for making a complex constant by typing "0+0i" when you drop the numeric constant. The datatype will automatically be changed to CDB. Not sure if this was introduced at the same time, though, so I don't know how far back this goes.
Message 10 of 21
(7,344 Views)