06-21-2020 09:35 AM
Hi
this is an easy firmware.
i create an empty file sinedata.txt in desktop, then i choose file path to sinedata.txt.
but after runing, Error4 occurred, why?
i change sinedata.txt to sinedata.dat, Error4 still occurred.
thanks.
06-21-2020 09:58 AM
I see what you mean.
I think the problem is that you can't open an empty file. The error occurs deeper inside at a function called "Open/Create/Replace Datalog". It has an input that is required that defines the datatype in that file.
I guess it does something internally to read the file as it opens it. When the file is empty, I guess it errors out trying to find the end of the file since it is expecting a data structure that doesn't exist.
Why are you trying to open an empty file? The quick fix is to only give it file names for files that don't exist.
That said, these error seems unexpected and undesirable. NI should perhaps treat this as a bug and look at the code that contains the Open DataLog and handling this file error 4. It handles some other situations already in there.
06-21-2020 12:34 PM - edited 06-21-2020 12:37 PM
(I agree with Ravens that maybe an empty file pretending to be a datalog file could be handled more gracefully.)
Still, can we take a step back and try to figure out what you are trying to do? Obviously, you want to write a simple 1D array of data to a file. A 1D array is NOT a "waveform", so you should not be using anything from the waveform palette! In LabVIEW, a waveform is a special datatype assuming equally spaced time data with known start time and time spacing (t0 and dt), an array of data ([Y]), and might contain an unlimited set of metadata contained as waveform attributes).
Writing a 1D DBL array to a file as you are trying to do has no resemblance to that! Either write it as binary file or as delimited text file, depending on what you want to do with it later. We have a rich file IO palette to pick a suitable function.
@wu_tong wrote:this is an easy firmware.
Where does the word "firmware" fit in this discussion? Makes no sense.