From 5fe24b959045e2d8a5c1697afd6011d579cdaf36 Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Sun, 11 Aug 2024 13:53:23 +0100 Subject: [PATCH] Fixed open. Stupid --- basic/test.bsc | 25 ++++++------------- .../sources/interface/fileinterface.cpp | 3 ++- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/basic/test.bsc b/basic/test.bsc index 405050b2..608a8fde 100644 --- a/basic/test.bsc +++ b/basic/test.bsc @@ -1,18 +1,9 @@ -sound 0,100,100,14 -end +if exists("test.txt") then mos "del test.txt" -call snd(0,660,50,0,0,100) -call snd(0,440,50,0,0,30) -end - -proc snd(ch,fq,ms,sl,ty,v) - while peek($FF00):wend - poke $FF04,ch - doke $FF05,fq - doke $FF07,ms - doke $FF09,sl - poke $FF0B,ty - poke $FF0C,v - poke $FF01,7 - poke $FF00,8 -endproc \ No newline at end of file +open output 1,"test.txt" +print #1,"Hello world" +close 1 +cat +open output 1,"test.txt" +close 1 +cat diff --git a/firmware/common/sources/interface/fileinterface.cpp b/firmware/common/sources/interface/fileinterface.cpp index 34fc9b68..d5c7f237 100644 --- a/firmware/common/sources/interface/fileinterface.cpp +++ b/firmware/common/sources/interface/fileinterface.cpp @@ -311,7 +311,8 @@ uint8_t FIOSetFileAttributes(const std::string& filename, uint8_t attribs) { uint8_t FIOOpenFileHandle(uint8_t fileno, const std::string& filename, uint8_t mode) { if (mode == FIOMODE_RDWR_CREATE) { // If open truncate uint8_t exists; - if (FIOExistsFile(filename,&exists) == 0) { // If file exists + FIOExistsFile(filename,&exists); + if (exists) { // If file exists uint8_t error = FIODeleteFile(filename); // try to delete it, as we truncate it anyway ! if (error) return error; }