Page 1 of 1

Autosave and version save

Posted: Mon Jul 14, 2014 7:46 pm
by Tribblehunter
Fairly new to livecode after using app Inventor and have been looking for autosave feature and a way of saving versions of app as build progresses.

Have been playing around with this code and it seems to work when stack is opened. Am now playing with making a timed save occur. I am guessing there is something out there (revSmartSave works but over writes last save). I plan to place this in every stack I build. Or maybe I should make a plug-in???

Saves with name of stack and reversed date/time so files are saved in order.

Code: Select all

function reversed theString  --reverses date to give file name which is in sequence
  repeat with thisItem = the number of items of theString down to 1
    put item thisItem of theString after reversedString
  end repeat
  return reversedString
end reversed

command autosave  --autosaves with file name tagged and dated.
   lock screen
   put the system date into tDate
   put the system time into tTime
   replace "/" with "," in tDate
   replace ":"with"" in tTime
   get reversed(tDate) 
   put it into tDate
   save this stack as "E:\selected folder\"&"MeicaReboot"& tDate&tTime&".rev"
   unlock screen
   send autosave to me in 600 seconds
end autosave

on openstack
      ##set the Text of field "lblCopyrightChar" to numToChar(0169)
   autosave
  
end openstack
Would appreciate any comments as being a noob (kind of) not very sure about what i am doing and need all the encouragement I can get!

Re: Autosave and version save

Posted: Mon Jul 14, 2014 8:23 pm
by magice
Often people ask the best way to do things, and the best answer is "However you want to do it". That said, I would point out that (if I am understanding correctly) this is a script solely for saving your stack while it is open in LC. Therefore, it is not something you would want to happen after it is saved to stand alone. You might consider putting the handler in a button somewhere and using a recursive send in time to send a message back to that button. You would have to manually start the process of auto saving, but you might find this to be better since there may be cases where you don't want it saving. The other nice thing about doing it that way, is that you could then use an "on standaloneSaved" message to delete that button. In this way you can keep it in a prominent location in your source code but not have it show up in the standalone.

Re: Autosave and version save

Posted: Mon Jul 14, 2014 8:33 pm
by Tribblehunter
Thanks for the advice magice.

Yes it is solely for saving when scripting in lc. Was planning to remove before converting to stand alone.

Will learn how to do what you advise once I learn more!! lol.

Edit:

Just found this script which will do instead of me making timer!

Code: Select all

on openstack
dosave
end openstack

on dosave
save this stack  --will substitute this for my save code
send dosave to me in 600 seconds
end dosave
Kind regards to Andy Piddcock of http://2108.co.uk/snippets/ for this.

Re: Autosave and version save

Posted: Tue Jul 15, 2014 8:16 pm
by phaworth
My lcStackbrowser plugin includes the ability to create snapshots of a stack either at regular intervals or on request. You can optionally attach a comment to them. You can opt to keep a certain number of them or keep them for a specified length of time, or even get rid of them when the stack is removed from memory. If you need to restore one, you simply pick from a list of them.

If you're interested, there's a 30 day demo available at www.lcsql.com/lcstackbrowser.html If you try it, just right click on any main stack to create a snapshot or restore one. Also check out the preferences for various options to do with this feature.

Pete