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

Is there a way of stopping smallbasic automatically saving the latest version of a program when it's run?  It wipes over the previous version unless the name has been changed.  I usually keep on saving under a different name every time and running after each small change to make sure I can go back to a previous version if I encounter a major problem. 

Kronos

Couldn't you use git or svn to save your progress.

bplus

I've never know SmallBASIC to save automatically. I've always had the opposite problem.

@Stephen you aren't talking about MS Small Basic are you?
1 person likes this

jsalai

Quote from: bplus on June 13, 2023, 19:44:20I've never know SmallBASIC to save automatically. I've always had the opposite problem.

@Stephen you aren't talking about MS Small Basic are you?
The Android version(s) save the changed proram when you run it...
Sometimes it may be frustrating, sometimes anoying, but as I don't know the philosophy of Android/Google battery I did not complain.
in fact I always develope in Win, so there is always the original copy 8)
I won't belong to any organization that would have people like me as members.
[Groucho Marx]

Stephen

Quote from: bplus on June 13, 2023, 19:44:20I've never know SmallBASIC to save automatically. I've always had the opposite problem.
@Stephen you aren't talking about MS Small Basic are you?
No, Smallbasic, the one this forum relates to, and I only use it in Windows 11.    I just assumed that it was designed that way, so I've been battling through it.

I've just written this simple Print program, run it, then closed smallbasic, then opened smallbasic again.  The lines have been updated despite the program never been saved either through the menu or any other way.

Print "Program to illustrate automatic save by running"
Print "edit at 08:02"
Print "edit at 08:03"
Print "edit at 08:05"
Print "edit at 08:07"
Print "edit at 08:18"

Incidentally, if I write a new line and try to shut it down, I receive a prompt if I wish to save before closing.  However, if I write a new line, run it, then close it, there's no prompt, because it has apparently been saved by the run.

PS Obviously the problem is not 'automatic saving' as such, but automatic saving it under the last filename, effectively erasing the last version.  If I encounter a serious problem and can't remember what lines I've changed, then the last operating program is lost, which can be a disaster.

bplus

Odd! but I don't have most recent version of sb, and only Windows 10 but that shouldn't make a difference.

When I try to quit with new code line I am prompted about saving both from top right X click and right click Back option.

Save prompt from sb.PNG

There were many many frustrating times where I made all these changes only to lose everything when I unthinkingly clicked top right x box to quit a run or back out of editor and sb quits.

No automatic saves for this geezer!

Come to think about it, you should be able to do a Save As so the old code does not get changed and the new stuff is saved under a new version name.  Is that available? 

Aha! No Save As is available on popup, maybe Chris has a Save As key combo but there is nothing in popup of options. 
Aha! no Save As.PNG

Check Key combo Help... well I forgot where access is to that, not Help on popup list. Ha! maybe it's listed in the list of Key Combos: Catch 22!

1 person likes this

bplus

@Stephen a possible work around for you is to Select All and paste the code into a new program and don't save current changes under old program name.

Maybe someone knows the key combo for a Save As ? (If there is one.)
1 person likes this

chrisws

The Android and FLTK versions both save on run. 

It should be simple enough to change the FLTK version.

In the SDL and Android versions you can use the [File] link/button to do SaveAs.

Midimaster

as a workaround during development you could add 3 code lines on the top which copy the given bas-file by adding date and time...

I dont know small-basic, so I give you a pseudo-code example:

Local ThisAppName$ = "test.bas"
Local Backup$ = "backup" + date + time + ".bas"
CopyFile ThisApp, BackUp

'now your code start:
Graphics 800,600
.....

maybe you have to find out the correct pathes and adjust the strings...
...back from Egypt

bplus

@Midimaster  

Interesting workaround idea. Can sb know the app and path it's running in editor? it should...

You might enjoy learning some of the unique ways sb does things specially with arrays.

1 person likes this

Stephen

Quote from: bplus on June 14, 2023, 17:42:44@Stephen a possible work around for you is to Select All and paste the code into a new program and don't save current changes under old program name.

Maybe someone knows the key combo for a Save As ? (If there is one.)
I've often pasted the latest program into Notebook before running, as well as renaming it by the date a, b, c etc.  I must have had about a hundred versions during development, although after a few weeks I delete most of the previous versions. 

Stephen

Quote from: Midimaster on June 15, 2023, 13:50:25as a workaround during development you could add 3 code lines on the top which copy the given bas-file by adding date and time...

I dont know small-basic, so I give you a pseudo-code example:

Local ThisAppName$ = "test.bas"
Local Backup$ = "backup" + date + time + ".bas"
CopyFile ThisApp, BackUp

'now your code start:
Graphics 800,600
.....

maybe you have to find out the correct pathes and adjust the strings...
Seems like a good idea.  Of course a separate version will be generated every time it's run, but I could just transfer them into a 'dump' directory at the end of the day or week, and perhaps delete those after I'm completely certain I will never need them.

Midimaster

If you would like to invest more than 3 code lines in this project, you could also write a perfect function for backup:

This function would compare size and timestamp of the last copy with current version. And then decide to create a new copy or let it be, if it it too closed to the current version. Also this function could remove old copies, so that only one copy remains from yesterday 
...back from Egypt

chrisws

You could also put the backup code into a unit for reuse in other projects.

But let me know if there's any need to update the FLTK version (assuming that's what you are using).

Tinine

Quote from: Stephen on June 12, 2023, 13:58:11Is there a way of stopping smallbasic automatically saving the latest version of a program when it's run?  It wipes over the previous version unless the name has been changed.  I usually keep on saving under a different name every time and running after each small change to make sure I can go back to a previous version if I encounter a major problem.
Hi, I'm a brand new user and I started-out doing what I do with other programming languages, I open the file and Edit in Notepad++

I am currently copying/pasting from Notepad++ to SmallBASIC because I haven't figured-out how to open a source file in SB but the cool thing is that I can make quick changes in SmallBASIC and if I save them (Ctrl-s), returning to Notepad++, it recognises that the file has changed and asks if I want to overwrite the previous.
Another neat feature of NP++ is the "Save a Copy" which I prefer to "Save As".

Craig