Page 1 of 1
App developer How close a file
Posted: Thu Mar 11, 2021 5:16 pm
by stefan.erni
Hi Ben
To write file with the App developer is very nice to do.
I think is a fast way to test files and fileheader before I use it embedded.
Is there a way to close the file in App developer?
If I write a file and open the file with wordpad or HexEditor I get a warning.
So I have to close Flowcode (not just end the App) .
regard
Stefan

- warning_2021-03-11_11-02-59.png (11.83 KiB) Viewed 4756 times

- close-file_2021-03-11_17-51-03.png (168.21 KiB) Viewed 4756 times
Re: App developer How close a file
Posted: Fri Mar 12, 2021 10:47 pm
by BenR
Hi Stefan,
For now you could try opening a file that doesn't exist and it should close the handle to the file.
I'll see if we can add a close function for you.
Re: App developer How close a file
Posted: Fri Mar 19, 2021 9:35 am
by stefan.erni
Hi Ben
For now you could try opening a file that doesn't exist and it should close the handle to the file.
this is working. It's close the file.
To write a file with header and data is very comfortable with Flowcode. One question more.
When the recording is finish I have to write how many samples are recorded. How can I write (overwrite) just the first block or even the few byte with the info about the number of samples?
regards
Stefan
Re: App developer How close a file
Posted: Fri Mar 19, 2021 9:55 am
by BenR
Hi Stefan,
Adding and Inserting data half way through a file is tricky. Ideally if you make enough room for the largest number of characters you can expect in the header then you can update the value without having to shift the rest of the file by adding new characters.
Once you open a file the first sector (512 bytes) of the file are loaded into memory. By using the ReadByteFromBuffer and WriteByteToBuffer you can read and write the sector memory loaded in RAM. Then by calling WriteFileSector you will overwrite the Filesector with the RAM buffer.
Hopefully this helps but let us know how you're getting on.
Re: App developer How close a file
Posted: Fri Mar 19, 2021 10:30 am
by stefan.erni
Hi Ben
That's working fine. Thank you for this help.
regards
Stefan

- number_of_sample_2021-03-19_11-22-43.png (175.28 KiB) Viewed 4707 times