How do I stop smallbasic automatically saving the program when run?

Started by Stephen, June 12, 2023, 13:58:11

Previous topic - Next topic

Stephen

Has anyone managed to do this yet?   Smallbasic doesn't seem to accept variable dynamic strings from the program in the filename 
eg. ignoring the directory name

Dynamicstring$=Time
Copy "OriginalFile", Dynamicstring$

Midimaster

If you want to use my workaround, you need of course to use the correct syntax of SmallBasic!!!

As I see no commands for timestamps in SmallBasic I would suggest to change to BlitzMax !!!

Sorry... I used the syntax of the wrong SmallBasic for the following lines:

On the SmallBasic homepage I can see this sytntax:

File.CopyFile(sourceFilePath,destinationFilePath)

I guess you need to do it this way


ThisApp = "test.bas"
Backup  = "backup " + clock.date + " " + clock.time + ".bas"
File.Copy ThisApp, BackUp




When you would use HOUR instead of TIME, only one of the backups would remain per hour:

ThisApp = "test.bas"
Backup  = "backup " + clock.date + " " + clock.hour + ".bas"
File.Copy ThisApp, BackUp


Why not change to a adult-Basic like BlitzMax?

...back from Egypt

SToS

From what I have read here I think there may be crossed wires as Stephen (I am 99% sure from the syntax he used) is referring to https://smallbasic.github.io/ and Midimaster is (again 99% sure going on syntax) is referring to https://smallbasic-publicwebsite.azurewebsites.net/.

Please correct me if I'm wrong :-[ and tell me to keep my nose out! :-X

Stephen

Yes SToS 
https://smallbasic.github.io/   
is the SmallBasic for this board as far as I know. Nothing to do with Microsoft.

J7M

@Stephen : I think your code didn't work because TIME returns the time with ":" as separator. Therefore the file name for COPY wasn't valid. Here a program which works well in Android. Replace ThisAppName with your file name. DATE uses "/" as separator. With TRANSLATE the two separators are replaced with "-". Now you have a valid file name.

ThisAppName = "scratch.bas"
Backup = "backup_" + date + "_" + time + ".bas"
Backup = translate(Backup, "/", "-")
Backup = translate(Backup, ":", "-")
copy ThisAppName, Backup

' your code starts here
print "Hello world"

Stephen

J7M

Seems to work, thanks for this!

I would suggest anyone using Smallbasic on Windows 11 (and perhaps on some other OSs) should insert this code at the start of their program, so it's copied to a backup directory. I've spent many an hour kicking myself for forgetting to back up revisions before running them, unable to get it working again.