In today's nugget I'm going to talk more about the little yellow triangular warning glyph that you may have seen on your MathScript Node. There's a great explanation of this glyph in the help topic for the MathScript Node but I thought I would highlight what this glyph means, how it's caused, and how to fix it.
If you have a warning glyph on your MathScript Node, it means the node will be less capable in several ways:
- your run-time performance will be slower
- MathScript will have reduced edit-time error checking
- syntax highlighting won't differentiate between functions, variables, and other symbols
- type highlighting and context help won't show any information
- you can't run your node in a built application or shared library
- you can't deploy your MathScript Node to real-time targets
If none of these issues is a problem for you, then it is perfectly OK to have a warning glyph in your MathScript Node. But if you do want any of the above, you'll need to know what's causing the warning glyph and how to get rid of it.
Calling any of the following will cause the warning glyph to appear:
- a built-in function that modifies the search path at run-time (for example, 'path', 'cd', or 'addpath')
- a function that changes control flow in a way that LabVIEW doesn't handle naturally (break, return, or continue)
- a function that requires MathScript to track which variables exist at every step of your program (for example, 'clear', 'global', or 'eval')
- a user-defined script (a .m file without the 'function' keyword at the top)
- a user-defined function with one of the above calls
MathScript makes it easy to find which of these is the culprit. The glyph will appear next to the line containing the offending call. If the root cause is in a user-defined function, you can use the VI Hierarchy to find exactly which function causes the warning: your .m files appear in the hierarchy with warning glyphs on them.
Removing the warning glyph requires changing the syntax that causes it.
- Instead of changing the search path at run-time, set it up at edit-time using the Tools>>Options MathScript page (or the My Computer>>Properties page if you are working in a project).
- Instead of calling break, return, or continue, structure your code with nested 'if' statements to avoid executing the code after the command (this can be pretty tedious so the MathScript team is investigating ways to stop making these functions cause the warning glyph in future LabVIEW versions).
- Unfortunately there's usually nothing you can do about these functions besides removing them from your program.
- Instead of calling user-defined script, inline the code or put it in a user-defined function.
- Follow the above steps to remove the warning glyphs from your user-defined function.
I hope this nugget has helped you understand the where the warning glyph comes from, what it means, and how to get rid of it!
jattas
LabVIEW MathScript R&D
ps Check out
previous MathScript Nuggets!