06-16-2011 10:00 AM
I am creating a .csv file using the File I/O->Open/Create/Replace file VI. I am able to create a file at the file location that I gave it, but when I save the refnum to a byte stream refnum global, it will not save the refnum. When I call on the global in a seperate VI, it reads "0".
06-16-2011 10:11 AM
Are you trying to run these VIs on their own? In other words, do you have the individual front panels open and you click the run arrow in one, and then the other? If so, that won't work. Once the global VI is no longer in a running VI then it falls "out of scope", and is no longer valid. The same thing happens with TCP/IP references. You must have a higher-level VI that calls all the individual VIs so they can remain running in memory. NOTE: Using the "Run Continuously" button in the toolbar will not work.
06-17-2011 08:13 AM
I see that. I think I may just have to use a text .ini file and a .NET assembly to store and read the file path. Thank you for your help.
06-17-2011 09:03 AM
I don't see why you'd have to resort to a .NET assembly to store a file path. What are you trying to do?
06-17-2011 09:10 AM
I am trying to create a csv file once a item has been scanned and started testing. This filename will be attached to a file path and when VIs running certain tests are initiated, they are to look in a global information source for this file location and append the csv file.
06-17-2011 09:13 AM - edited 06-17-2011 09:20 AM
Oops, you posted while I was typing -
"I am trying to create a csv file once a item has been scanned and started testing. This filename will be attached to a file path and when VIs running certain tests are initiated, they are to look in a global information source for this file location and append the csv file."
Ok, you want to look into the "Programming\File I/O\Configuration File pallette. Or better yet go to the OpenG site and get their tools for writing configuration files. Or use the spreadsheet file function to write the name-path pairs to a file and read them back in when needed, allowing you to populate a two dimensional array with one column being item name, the next being path to its file. Search the array to find the name entry, pull out the path.
refnums are meaningless outside of the instance they were instantiated for, in other words, they won't point at a file that was created in a previous run of a vi, they only point to the file while the vi(s) that are manipulating it are running.
As was asked before, what are you trying to do? It is relatively trivial to save a "filepath" (i.e. C:\Projects\Blah.csv) into a file to be used later to access Blah.csv
06-17-2011 09:24 AM
I'm not familiar with the "Open G" site. What is it?
06-17-2011 09:30 AM - edited 06-17-2011 09:31 AM
OpenG is a LabVIEW open source community. Many useful VIs have been created by that community, and they can be easily installed using the VI Package Manager. The web site: http://wiki.openg.org/Main_Page. And: http://forums.jki.net/topic/233-how-do-i-use-vipm-to-get-openg-libraries-installed-onto-labview/
Note that LabVIEW has built-in functions for writing configuration (.ini files), so you can use those if you wish. However, OpenG has a plethora of other useful VIs.