Question about automatic file saving


bluelotus128

Recommended Posts

Hi,

I am programming an application that requires automatic saving of a file with a pre-defined file name (file name defined in the sequence). I found this function: FileSaveDialog([default file], [initial dir], [filter], [title]): however this prompts the user to save instead is there a solution to automatically save the file without prompting the user?

Link to comment
Share on other sites

I'm not quite sure what you mean. How are you writing to this file? Through a logging set, or with File. functions()? If with a logging set, just change the file name of the logging set to the new file name, and it will close the old one. Its something like: logging.mylog.strFileName = "c:\mypath\myfile.csv". If you're using File. functions to write, just close the file with File.Close() and open a new one with File.Open()

Link to comment
Share on other sites

  • 3 weeks later...

Dear sir,

I aplogize for not being specific. Let me explain from the beginning again. The interface in DAQ Factory that I use currently has a button 'Download' so basically the code behind this button connects to an Aquatic Controller and transfers the saved datalogs from the Microcontroller memory bank (On board the Aquatic controller) and transfers them to a array variable in DAQ Factory. Then there is a different button called 'Save', the code behind this button checks to see if the data has successfully been transferred to the DAQ Factory array variable then uses the file save dilog function in the following way: File.FileSaveDialog("user_defined_filename.csv", "c:\", "*.csv", "Logged Data") then uses the File.Open(User_defined_filename, 1,0,1,0) then uses the File.write() function to write all the data in the array varaiable in to this file and then after the writing is done uses the File.Write(handle) to close the file. My question is if I were to create an interface where the DAQ Factory Application just triggers on a user set time and on trigger it connects to the Aquatic Controller and initiates a download on its own, completes download to the DAQ Factory array varaible, then tries to save this data to a file, is it possible to use an alternative to the function: File.FileSaveDialog("user_defined_filename.csv", "c:\", "*.csv", "Logged Data") ? Where the user does not have to initiate the saving of the file or where the user need not be prompted to save the file? Where the DAQ Factory just uses a pre-defined file name and saves it automatically to the PC? I would appreciate it if you could le me know the posibility of this feature soon, sir.

Best Regards,

JM

Link to comment
Share on other sites

Certainly. Just don't do the File.FileSaveDialog() call and create your own string variable. For example:

private string fileName = "c:\myData\myFile_" + formatDateTime("%y%m%d%H%M", systime()) + ".csv"

private handle = file.open(fileName,1,0,1,0)

...

The first line creates the filename without prompting the user. In this case, it uses the current time in the filename.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.