04-29-2010 12:13 PM
Is there any way to programatically import a mathscript from a file? I see I can import and export interactively, but I would like to have a VI that reads a mathscript from a file, runs it, and then outputs a waveform. This way people without Labview would be able to edit the script after deployment.
I realize that inputs and outputs will need to be the same. I'd just like to be able to programatically import and export the stuff inside the math script.
04-30-2010 07:39 AM
06-20-2011 09:23 PM - edited 06-20-2011 09:26 PM
I have basically the same problem, I would like the user to be able to choose a m-file he wants to run.
Is it possible to set the Mathscript search path programatically ? Or does e have to set it manually via Tools>Options>Mathscript in order to run the desired m-file.
One more thing, is it possible to run a m-file which is not a function ? In fact I have a lot of parameters set in the m-file, it is not very convenient to put all these parameters as outputs of the functions.
06-21-2011 10:50 AM - edited 06-21-2011 10:50 AM
kurisu,
As of right now tI know of no way to bypass the Tools>Options>Mathscript path. However it maybe possible to load multiple .m files and then use a path constant in LabVIEW to select the location of that .m file stored on the computer. 🙂 you may want to post that idea on the idea exchange http://forums.ni.com/t5/LabVIEW-Idea-Exchange/idb-p/labviewideas
06-21-2011 02:36 PM
Hello Kurisu,
It is possible to set the search path programatically using the addpath('c:/') function as described here:
http://zone.ni.com/reference/en-XX/help/371361G-01/lvtextmath/msfunc_addpath/
However, this will only work for that one particular MathScript Node and its .m files and while the VI is running. Additionally, it will put the MathScript Node in reduced performance mode which could significantly slow the operations you are trying to perform. Finally, this function isnt supported in the LabVIEW run-time engine so you shouldnt use it in a stand-alone application or a shared library. Why are you unable to set the search paths statically? Is there no way to know the location of your files before runtime?
As far as your other question - yes it is possible to run an m-file which is not a function but it will also put your MathScript Node into the reduced perfomance mode since MathScript will be unable to determine the inputs and outputs your script consumes.
Cheers!
K Scott
06-21-2011 07:45 PM
Thank you for your reply.
It worked well with addpath. In fact, I just wanted the user to choose the m-file to run so I don't know the path before running the VI. It is a parameter m-file. Maybe it is not the ;ost efficient way to do it, but since I am totally new to LabVIEW, I don't know any better way.