LabVIEW 2012 MathScript RT Module Help
»View Product Info
Owning Class: support
Requires: MathScript RT Module
save file a b ... c
save file '-struct' structname fieldname1 fieldname2...
Saves variables to a file. save and save file save all variables to a file. save file a b ... c saves variables a, b, ..., c to a file. You can specify an unlimited number of variables to save. save file '-struct' structname fieldname1 fieldname2... saves fields specified by fieldname1, fieldname2... in the struct specified by structname to a file. You can specify an unlimited number of fields to save. You must use the save function to save variables to a file before you can load those variables with the load function.
The file string can be an absolute path or a path relative to the current working directory. If you do not specify file, LabVIEW saves the variables to the default.mlv file in the current working directory.
If file saves to the current working directory, you can specify just its filename. If file saves to a location outside of the current working directory, you must specify its path and use single quotation marks to define it as string.
You can use the save
function in the following situations:
- To save variables to a .mlv file.
- (Windows) To save variables to a binary measurement file (.tdm or .tdms). You then can exchange data between NI software, such as LabVIEW and DIAdem. When you use the save function to save variables to a .tdm or .tdms file, LabVIEW saves each variable as a channel group. The name of the variable determines the name of the channel group. If the .tdm or .tdms file you specify already exists, LabVIEW overwrites the original file. LabVIEW also creates a backup copy of the original file. LabVIEW does not support saving non-numerical variables to a .tdm or .tdms file.
- (Windows) To save data to an external data file, such as a .csv or .mdf file. To save data to an external data file, you first must install the correct National Instruments DataPlugins. Refer to the National Instruments website to download DataPlugins. LabVIEW does not support saving non-numerical variables to an external data file.
You also can use the fwrite_csv
function to save data to a .csv
You cannot use the previous syntax to save to a file whose name you define in a variable. Use the syntax in the following example to save the variable A
to a file named myfile
, which you define in the fname
variable.fname = 'myfile'save(fname, 'A')
The file path that you specify can be relative to the working directory. Changes you make to the working directory using the cd
function apply only to the current instance of the LabVIEW MathScript Window
or the MathScript Node
from which you call the function. Changes to the working directory for one MathScript Node do not apply to any other MathScript Nodes. LabVIEW resets the working directory to the default when you close the LabVIEW MathScript Window
or when the MathScript Node stops executing. Use the MathScript: Search Paths
page of the LabVIEW MathScript Properties
dialog box to change the default working directory for the LabVIEW MathScript Window
. Use the MathScript
page of the Options
dialog box to change the default working directory for MathScript Nodes in the main application instance
The following table lists the support characteristics of this function.
|Causes reduced performance ()
|Supported in the LabVIEW Run-Time Engine
|Supported on RT targets
A = 12
B = A+1
save 'C:\Program Files\National Instruments\data.mlv'