LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the MathScript node working directory to the working directory of the VI in which the node is added

Solved!
Go to solution

Hello,

 

 I want to automatically  change the working directory of the Mathscript node in a VI to the working directory of the VI, so that I don't have to specify everytime where my .m file is, as most likely it will be in the same folder as the VI.

 

Thank you,

 Walid F. Abdelfatah

0 Kudos
Message 1 of 4
(7,693 Views)
Solution
Accepted by topic author wfarid

Hi Walid,

 

The following snapshot illustrates how to add your VI's directory to MathScript Search Paths.

 

AddMSSearchPath.png

帖子被ttrr在 02-03-2010 11:07 PM
时编辑过了
0 Kudos
Message 2 of 4
(7,688 Views)

Just another related questions:

 

If I have multiple MathScript nodes in a VI :

 

1. Changing the working directory of one node, does it change the working directory of all nodes ? I changed the working directory of one node and in another node I called a user-defined script, but I got that it is an invalid name.

 

2. Is it fine to have multiple Mathscript nodes, or is there some coding style I better follow ?

 

Thank you ttrr,

 Walid

0 Kudos
Message 3 of 4
(7,679 Views)
Hello Walid,

Note that the method that ttrr suggests causes a warning glyph to appear in the MathScript node.  This will result in a performance degradation.  The recommended method of setting the MathScript search path is through the Tools >> Options dialog for the main application instance, right-clicking on the My Computer project target and selecting Properties, or through File >> LabVIEW MathScript Properties for the MathScript Window.  While you will see the greatest performance with this method, the paths do not change so you will not be able to have the VI's current directory in the search path.  The best method would be to have all your .m files located in one spot and simply include that path in your search path settings.  By default, MathScript will search in your "My Documents\LabVIEW Data" directory.

As for you questions regarding the method that ttrr suggested,
1) Overriding the search path with the addpath function will only change the path for that particular node.  If you need this search path for multiple nodes, you will need to call the addpath function in each node.  Note if you use the search path settings dialog mentioned above, the search path applies to all nodes in the diagram.
2) It is fine to have multiple nodes.  In fact, if you have a longer script, splitting it into multiple nodes will improve your compile time when making changes to the script.

Grant M.
Senior Software Engineer | LabVIEW MathScript | National Instruments
Message 4 of 4
(7,670 Views)