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


Reply
Knight of NI
altenbach
Posts: 23,139

Re: LabVIEW Minutiae (that may bite you someday)

Here is one involving X-Controls.

 

Xcontrols are a bit complicated to configure, so it might not be clear what it means if the "data changed?" boolean in the action cluster is set to true.

 

For example, there is an event case name "Data Change", and the programmer might think that "data changed?" needs to be set to TRUE in that event case. (After all, if you write to a terminal, the data changes in some way, right? :smileywink: ...wrong! :smileysurprised:)

 

Bad idea, but you might never notice a problem until you do some profiling:

 

If "data changed?" is set to TRUE in the "Data Change" event of an xcontrol, writing to a plain local variable of the xcontrol in the main program actually fires any "value changed" event associated with the xcontrol, same as if you would write to a value(sgnl) property. This can lead to unexpected behavior. :smileywink:


LabVIEW Champion . Do more with less code and in less time .

Trusted Enthusiast
JackDunaway
Posts: 2,445

Re: LabVIEW Minutiae (that may bite you someday)

Wow! I just learned one that threw me for a loop! I rarely use the Expression Node, so when I tried to generate a simple parabola out of instinct I tried "x^2 + 2*x". You can imagine I was shocked to see the following drunken graph:

 

19921i34FC20B09629F5A1

 

 

 

Apparently, the '^' operator is the XOR operator, not "to the power of" like I expected. This was clearly evident for such a simple formula, but could be much more insidious in a complex formula.

 

See here for the original thread where I ended up using "x*x + 2*x" as the example.

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Active Participant
elset191
Posts: 1,132

Re: LabVIEW Minutiae (that may bite you someday)

 


JackDunaway wrote: 

 

Apparently, the '^' operator is the XOR operator, not "to the power of" like I expected. This was clearly evident for such a simple formula, but could be much more insidious in a complex formula.

 

See here for the original thread where I ended up using "x*x + 2*x" as the example.


Not sure if you discovered it in your research, but ** is "to the power of".  i.e.  "x**2 + 2*x"

 

--
Tim Elsey
LabVIEW 2010, 2012
Certified LabVIEW Architect
Knight of NI
altenbach
Posts: 23,139

Re: LabVIEW Minutiae (that may bite you someday)

The few syntax differences (formula node vs. parser) are a bit of a weak point and can be confusing.

 

Here is a list of some differences.

 

excerpt from the help:


The parser in the Mathematics VIs supports all elements that Formula Nodes support with the following exceptions:

  • Variables—Only aa0, ..., a9, ... zz0, ..., z9, are valid.
  • Logical, conditional, inequality, equality—?:,, &&, !=, ==, <, >, <=, and >= are not valid.
  • Functions—atan2, max, min, mod, pow, rem, and sizeOfDim are not valid. You can use these functions in a Formula Node or use their corresponding LabVIEW functions.

...

The following table lists cases where Formula Nodes and the parser in the Mathematics VIs use different syntax.

ElementFormula NodeParser VI Routine
pi pi(1) =, pi(2) = 2, 2pi or 2(pi) return an error
Exponentiation ** ^

The precedence of operators is the same for the Mathematics VIs as in Formula Nodes. Refer to Formula Parsing VIs for more information about specific Formula Parsing VIs.

The parser in the Mathematics VIs uses the following syntax:

function (argument)



LabVIEW Champion . Do more with less code and in less time .

Trusted Enthusiast
JackDunaway
Posts: 2,445

Re: LabVIEW Minutiae (that may bite you someday)

Have you ever heard of "Coerce to Type"? You may not realize you need this function to squash bugs waiting to happen in data type conversions and typecasts.

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Active Participant
mitulatbati
Posts: 201
0 Kudos

Re: LabVIEW Minutiae (that may bite you someday)

[ Edited ]

I try to configure a case structure in a way that one case matches all the input strings started with "CurrentMeasurement" (and others.)

 

This results TRUE, if the input = "CurrentMt" and also TRUE if input = "Currenteasurement". But FALSE for "CurrentMeasuremen"


So what is the rule? In the help I find only hints for string ranges, for example stringe begin with a and b should be "a..c"

 

case.gif

 

Mitulatbati

Knight of NI
altenbach
Posts: 23,139
0 Kudos

Re: LabVIEW Minutiae (that may bite you someday)

 


mitulatbati wrote:

I try to configure a case structure in a way that one case matches all the input strings started with "CurrentMeasurement" (and others.)


This looks like a normal question looking for help, so please post it as a new thread in the LabVIEW forum.

 


LabVIEW Champion . Do more with less code and in less time .

Trusted Enthusiast
SteveChandler
Posts: 2,249
0 Kudos

Re: LabVIEW Minutiae (that may bite you someday)

 


mitulatbati wrote:

I try to configure a case structure in a way that one case matches all the input strings started with "CurrentMeasurement" (and others.)

 


You just gave me an idea for the idea exchange. What if the string could be a regular expression?

 

=====================
LabVIEW 2012


Trusted Enthusiast
SteveChandler
Posts: 2,249

Re: LabVIEW Minutiae (that may bite you someday)

If an event structure is registered for an event but does not have a case for that event then firing that event will still reset the timeout timer for the structure.

 

Some people consider it a bug and others consider it to be expected behavior.

 

There is an interesting debate on Lava about this.

 

timeout.png

 

Anyone know why creating a snippet converts a control reference into a control?

 

=====================
LabVIEW 2012


Knight of NI
Knight of NI
tst
Posts: 10,302

Re: LabVIEW Minutiae (that may bite you someday)

 


SteveChandler wrote:

 

Anyone know why creating a snippet converts a control reference into a control?


Because NI wants to encourage people to use the Code Capture Tool which doesn't have this issue and can back-save your snippet as well?

 


___________________
Try to take over the world!
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