• Thanks @Gordon and @allObjects for the pointers. I did something hopefully in line with your suggestions and it seems to work! Wahooooo!

    Here's how I added to the global Bangle name space

    Bangle.AppLog = {
                currentFile: null,
                lock: false,
                init: (filename) => {
                    try{
                        if(filename != null && filename != ''){
                            Bangle.AppLog.currentFile = s.open(filename, "a");
                        }
                        else{
                            console.error("Log file name not provided");
                        }
                    }
                    catch(ex){
                        console.log("Failed to create file", ex);
                    }
                },
                write : (sentence) => {
                    if(Bangle.AppLog.lock != true){
                        Bangle.AppLog.currentFile.write(sentence­ + "\n");                    
                    }
                },
                clearLog: () => {
                    Bangle.AppLog.lock = true;
                    Bangle.AppLog.currentFile = null;
                    require("Storage").open("ftclog", "w").erase();
                    Bangle.AppLog.lock = false;
                    load();
                }
            };
    
    

    Calling Bangle.AppLog.clearlog() from the python script does the trick. All ftclog files get removed, the app gets reloaded and I am left with a grin on my face :D

    Also, as suggested by @Gordon I used the load() function in clearLog() and it works like a treat

    Thanks again.

    P.S. I should really save the incoming filename so I don't have to hardcode it in the clearLog() :D

About

Avatar for PiOfThings @PiOfThings started