Hello,
$(scrdir) is the project file source directory and so will look for files in the same directory as the .fcfx file you opened. Glad you have found the issue, let us know if you find anything further.
Write to start of sd card file
-
- Matrix Staff
- Posts: 1926
- http://meble-kuchenne.info.pl
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: Write to start of sd card file
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: Write to start of sd card file
I've had another look at this. I've added retval and watched to see if the opnefile macro returned 0 but it never does
No matter where I put the files (test.txt and filetest.fcfx) and open them from, retval never changes. I just dont understand this. In my own program the file i updated with the data I am logging ok so its definitely finding my own cfg file but if I could get your file to work I might be able to figure out what I'm doing wrong.
Is it a windows 11 environment variable or something?
No matter where I put the files (test.txt and filetest.fcfx) and open them from, retval never changes. I just dont understand this. In my own program the file i updated with the data I am logging ok so its definitely finding my own cfg file but if I could get your file to work I might be able to figure out what I'm doing wrong.
Is it a windows 11 environment variable or something?
- Attachments
-
- FileTest(1).fcfx
- (11.73 KiB) Downloaded 398 times
-
- Valued Contributor
- Posts: 1462
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 136 times
- Been thanked: 713 times
Re: Write to start of sd card file
Hi,
Something is odd - I can run this AOK.. I changed the FileSystem->RootDirectory to R:\ and it works perfectly. I wonder if there is a limit on the path length ?
Martin
Something is odd - I can run this AOK.. I changed the FileSystem->RootDirectory to R:\ and it works perfectly. I wonder if there is a limit on the path length ?
Martin
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: Write to start of sd card file
Hello Wingnut,
The console may help in diagnosing your problem.
I had a look and it looks like your path is missing the final \
but probably should instead be
My clue was this line in the console.
On adding the slash
I might see if I can auto add the slash if it's missing so this problem goes away.
The console may help in diagnosing your problem.
I had a look and it looks like your path is missing the final \
Code: Select all
C:\Users\Norma\Documents\Flowcode files
Code: Select all
C:\Users\Norma\Documents\Flowcode files\
Code: Select all
Open File: C:\Users\BenR\Documents\Flowcode Filestest.txt - Error File Not Found
Code: Select all
Open File: C:\Users\BenR\Documents\Flowcode Files\test.txt - OK - Filesize: 167 Bytes
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: Write to start of sd card file
I've now fixed the problem in the component and it now auto adds the slash if it's missing.
Fingers crossed this works for you.
Fingers crossed this works for you.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: Write to start of sd card file
Also added a further mod which does the same thing for open folder and also fixes a bug I just spotted where the open folder simulation would only allow you to go one level deep.
Also applied these fixes to the App Inventor File component.
Also applied these fixes to the App Inventor File component.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: Write to start of sd card file
Tried it straight away and still wouldn't work so I added the other variables to the "watch variable" in simulation debugger so I could see it step by step reading in the string but it wouldn't write the incremented number back. I disabled 'update filesector and added write filesector and it works! At all speeds too. Now to try it in my own program. Not sure what the issue is with update filesector
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: Write to start of sd card file
Hello,
Glad there's some progress
Write file sector will add data to the file header, it will update the file length by 512 bytes by adding a new sector to the file. If the file is a newly created fresh file then it will add the first sector to the file complete with the data in the buffer.
Update file sector won't modify the header and will just overwrite the current sector with the data in the buffer. If the file is a newly created fresh file then the sector will not be added to the file and the file will still appear as being empty.
At least that's what should be happening
Glad there's some progress

Write file sector will add data to the file header, it will update the file length by 512 bytes by adding a new sector to the file. If the file is a newly created fresh file then it will add the first sector to the file complete with the data in the buffer.
Update file sector won't modify the header and will just overwrite the current sector with the data in the buffer. If the file is a newly created fresh file then the sector will not be added to the file and the file will still appear as being empty.
At least that's what should be happening

Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: Write to start of sd card file
Ok Thanks Ben. I did get some success with write file sector in my own program last night but not quite what i was expecting and that may be partly my own fault and partly what you have described above. I'll have another go with update file sector tonight