Ever work for hours forgetting to hit save while coding in LiveCode and then do something dumb like inavertally locking up your project with a loop and unable to save your changes? The following code will dynamically (automatically) will save your project each time you test/run your code.
on resumeStack
save this stack
end resumeStack
💣 Just remember to remove/comment it before compiling your project.
The disadvantage of the above example is that it automatically overwrites the original project's source each time you test it. Problem is you may had tried something new by making some changes and discovered the changes would only lock your project up and now the project's original source were overwritten by these changes.
But if you want an automatic backup with an unique name then the code provided below will save a backup with the name of the filename it is saved under with an appended version number based on the current timestamp. A folder named Backup will be created within the parent folder of the source code and the backups will be stored in this folder. The file name's extension is used to determine if the current code is in development or a standalone/executable. The filename's appended serial will be formatted as:
YearMonthDayHourMinuteSecond
This appended serial number will serve as a version and keep the backups in chronological order. For example:
A backup for myApp.livecode will be named myApp-20211030160638.livecode
The appended serial number 20211030160638 represents
Year: 2021
Month: 10 (October)
Day: 30
Hour: 16 (4 PM)
Minute: 06 (Note numbers smaller than ten will be padded with a zero)
Second: 38
Code for autoBackup Code for auto backup coming soon. Please Be patient ...