Using channels inside expressions in components


Recommended Posts

I have an U16 channel "Units" that contains 0 or 1.

If I enter ? iif(units[0],format("%.3f",23),format("%.1f",23)) into the command / alert it works as expected.

if I try to put the same thing inside a variable value component expression iif(units[0],format("%.3f",23),format("%.1f",23))  does not work. 

global myunits

if I repeat the same expression with a global variable inside a variable value component expression iif(myunits,format("%.3f",23),format("%.1f",23)) it works.

I have also tried this in the visibility expression with no success.

What am I doing wrong ?

 

Link to comment
Share on other sites

The variable value component has its own variable called "Units", so when you take your expression and put it into the Variable Value component, it pulls from the units variable of the component instead of the channel. 

DAQFactory searches private variables first, then member variables of objects (and components are objects), then it goes to the global namespace for global variables, then after global variables are channels.  That said, it is just better to not have conflicting symbol names.

 

Link to comment
Share on other sites

I just tried to "look up" the variable by typing component._variablevalue.units and got nothing. How can us users navigate the "keyword" issue?

I am assuming caption, precision, font, visible, blink, interval might be obvious, but font size? or speed key? or x size are getting a little harder to guess at.

Link to comment
Share on other sites

"Units" is actually synonymous with "strUnits".  There was a time, before variable declaration, when you had to put "str" in front of your variable names to indicate a string.  So, at that time strUnits was created.  Once that was removed we added a "Units" name for the same variable.

Font size on a variable value component is stored in XSizeMin.  Yes, this is a bit confusing and the upcoming release of DAQFactory eliminates this in the replacement control.

Otherwise I don't have a great answer.  Most names match up with the caption used in the dialog box.  Again, in the next release we have replaced most of the controls (though existing controls still work on existing documents...) and there the properties window actually shows the variable name as is so this is much easier to track.  Please email us if you have any interest in trying the beta of the next release.  It is a significant release and we always welcome feedback before release (and after...)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.