I'm having a LabView program I have communicate with a Mathematica kernel via WSTP and I'm having the darnest time trying to import a .m file that has a bunch of predefined functions needed to automate data processing. I have in the same directory as the VI a file called "VNA.m" that needs to be imported so that it can processes a directory full of files that the VI creates and build plots automatically. However whenever I try to run the command after building it I always get "$Failed" returned. The command I'm trying to execute is this:


However, when I run it in Mathematica, it imports the file just fine. I thought it may be an issue a standalone kernel has with importing files in general, but when I put the m file in another directory and execute the following command in WSTP, it works just fine.

Import["C:\\Users\\Surge\\Documents\\Physics SeniorProject\\Software\\Labview WSTP Link\\VNA.m"]

Similarly, if I try to export a file it doesn't work half the time either. The following command just as before doesn't work with WSTP and works well in Mathematica.

Export["C:\\Users\\Surge\\Desktop\\test\\VNA.dat", Table[0,{15}]]

And the following command works in both.

Export["C:\\Users\\Surge\\Documents\\Physics SeniorProject\\Software\\Labview WSTP Link\\VNA.dat",Table[0,{15}]]

Both work just fine in Mathematica and import all functions as expected. Is there something that I'm missing here? Are there rules to file i/o that I am not aware of? This is extremely frustrating, because anything involving files doesn't work half the time. I can simply move my VI to a directory that works, but aside from the obvious obvious problem of not having a clear understanding of what's going on, this produces a problem with importing data, sometimes it works and sometimes it doesn't, and it would be really nice if it can be made to work more consistently than that. Anyone have any idea what's going on?



1 Answer 1


So it turns out this isn't a Mathematica problem at all, there is a difference in how Mathematica and Labview treat escape characters, and Mathematica wasn't getting the commands I thought it was. In light of this, I don't know why the functions that were working worked. If you want to send a "\" character in LabView, you have to encode it as "\\", and thus when sending directories over to mathematica they have to be in the format:


My bad, guys.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.