LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I am having trouble saving a byte stream file refnum

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".

0 Kudos
Message 1 of 8
(3,038 Views)

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.

0 Kudos
Message 2 of 8
(3,034 Views)

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.

0 Kudos
Message 3 of 8
(3,016 Views)

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?

0 Kudos
Message 4 of 8
(3,013 Views)

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.

0 Kudos
Message 5 of 8
(3,009 Views)

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

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 6 of 8
(3,008 Views)

I'm not familiar with the "Open G" site.  What is it?

0 Kudos
Message 7 of 8
(3,003 Views)

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.

0 Kudos
Message 8 of 8
(2,997 Views)