Page 1 of 1
App Developer build in function File
Posted: Wed Sep 21, 2022 10:27 am
by stefan.erni
Hi Ben
I wrote a testprogram for the build in function File.
It's working fast and with long filename.
Only create with the file and close the file there is a little problem.
So I first have to start the program with creat file and then close the program and switch off createfile when the program second time runs.
I also have to close the app before I can open the file in windows. But the file is written extremely quickly
regards
Stefan
file on windows:
- file_2022-09-21_11-23-03.jpg (5.82 KiB) Viewed 5743 times
Re: App Developer build in function File
Posted: Wed Sep 21, 2022 10:46 am
by BenR
Hi Stefan,
If you first try to open the file, then if this fails you can then create the file. This shuold save you going back and having to remove the create file on the second pass.
Regarding the file being locked while flowcode is open, if you call the close macro then the file should be available as soon as the write is complete.
Re: App Developer build in function File
Posted: Wed Sep 21, 2022 11:37 am
by BenR
Aha sorry Steve just pointed out your using the API calls directly and not the file component.
In this case you can call the flush API call to force any pending writes to be completed and then set the file handle to 0 to effectively close the file.
I also didn't add that creating the file will also open the file and so the logic should be like this.
check = FileOpen
if check = false
{
FileCreate
}
Write to file
FileClose
Re: App Developer build in function File
Posted: Wed Sep 21, 2022 11:48 am
by Steve-Matrix
Re: App Developer build in function File
Posted: Wed Sep 21, 2022 12:59 pm
by stefan.erni
Hi Ben, Hi Steve
Thanks a lot.It's working fine now.
With the part "if file not can be open, then create", I understand.
And that there is no command macro for file close so I use file open but with parameter 0 for read and write.
I suppose that's what Ben means.
I will continue to save and open large amounts of data in arrays.
regards
Stefan
to close the file
- file_save_2022-09-21_13-38-38.jpg (42.37 KiB) Viewed 5727 times
Re: App Developer build in function File
Posted: Wed Sep 21, 2022 1:55 pm
by Steve-Matrix
stefan.erni wrote: ↑Wed Sep 21, 2022 12:59 pm
And that there is no command macro for file close so I use file open but with parameter 0 for read and write.
Use the "flush" API call to close the file for reading/writing as in the example.
Re: App Developer build in function File
Posted: Wed Sep 21, 2022 2:20 pm
by stefan.erni
Hi Steve
If I use the example with the flush I get this message. So I have to close FC and then I can open the file.
I don't know exactly what I'm doing wrong that it doesn't work for me on my computer.
regards
Stefan
- notopen_2022-09-21_15-11-12.jpg (14.87 KiB) Viewed 5723 times
Re: App Developer build in function File
Posted: Fri Dec 02, 2022 2:47 pm
by stefan.erni
Hi Steve
Now it's working nice to close the file.
As you wrote flush and open with 0,0,0
regards
Stefan