I am trying to wrtie an ASCII file on C:\ drive of my computer. Which command should I use.
If you are trying to write data from a DataTable out, I suggest using the TableFile instruction.
Public PTemp, batt_volt
Public OutStat As Boolean
Public LastFileName As String * 31
If you want to create a custom file then use the FileOpen, FileWrite, and FileClose instructions.
Const FName = "USR:MyFile.txt"
Dim FContent As String * 63
Dim FHandle As Long
If Save Then
Save = 0
FContent = "<Var01>" + Var01 + "</Var01>" + _
"<Var02>" + Var02 + "</Var02>" + _
"<Var03>" + Var03 + "</Var03>"
SemaphoreGet (1) 'lock file resource
FHandle = FileOpen (FName,"w",0) 'open file
FileWrite (FHandle,FContent,0) 'write file
FileClose (FHandle) 'close file
SemaphoreRelease (1) 'release file resource
* Last updated by: Sam on 6/27/2011 @ 7:07 PM *
Thanks for your reply.
I see you are writing the file to USR.
Let me give you more details about what I am trying to do.
The daq is attached to a computer that runs another software which is supposed to read a number from a text file. That text file is writtern by Daq on the hard drive of the computer.
Let's say in your example, you want to write the "MyFile.txt" to C:\ drive of a computer that is attached to the Daq.
Is there anyway we can do that? on in other words, how can I transfer the text file from USR to the hard drive of the computer, for example C:\ drive.
Of course this transfer has to happen every 200 ms.
Thanks for your reply.
My apologies, I misread your initial post. My response is applicable to writing files locally on the logger.
If you would like to write files to the PC, another approach is required
* Use LoggerNet to collect the data and write to PC
* Use LoggerNet to perform a retrieval of a file written locally on the logger (like previous post)
* Use the logger's web services commands to retrieve a file via HTTP. In CRBasic help see the "Web Server/API Commands" section.
* Use Email or FTP for transfer of a file written locally on the logger (like previous post)
I'm dubious of the 200ms transfer rate.
If you just want to write data being logged directly to the hard disk in real-time, there is a function in our RTDAQ product that allows you to spool the data from the logger onto disk at relatively high speed; much faster than 200 ms.
You do this using the Table Monitor tool and click on the Save to file checkbox. This is designed for short term experiements though, where the Table Monitor is left open throughout.
Details and a free trial can be found here:
Thanks for your replies.
I tried the Table Monitor option, but it does not write the file on HDD until the stop button is pressed. The file is written on HDD after stopping the monitor.
Is there a way to continuously write the table on HDD? for example to write every sample in the file on HDD.
I am using a CR1000 logger.
If you need the file to be close after every transfer, then Sam's suggestion of using a Loggernet to collect data as fast as it will allow in its schedule.
The only other way I can think to store data to a remote computers hard disk based upon when data is stored in the logger is by following the process Sam outlined above where you write a file to the dataloggers drive and then fire it off via ftp to a computer. FTP is not optimised for speed to it is unlikely you will achieve the speeds you want.