Automated Flashcard Backup on WinMo

mfcb

状元
maybe somebody else is worried about his flashcard database in the devices RAM, instead of stored on SD card. according to manual and mike's frequent suggestions here in the forum, the db has to be there, for performance reasons.

i recently learned about "MortScript" (http://www.sto-helit.de/index.php?modul ... ew&menu=29), which is a scripting engine for almost any Windows Mobile (Version 2003 upwards) that could be used easily to make an automated backup into a ZIP file on the SD card. i attached my version of the script, anyway it seems that mostly technically advanced people are using WinMo + posting on this forum :D , so you should not have too many troubles to understand it. and the manual of mortscript is also quite good!

no warranty from my side, that the script works on your device without modification, in fact i don't take any responsibility for any damages done by it.
if you don't understand, what it does and do not trust it, then just don't use it...


functional principle:
every day, 4:00 in the morning (local time) the script is automatically restarted via notifications (standard WinMo functionality, used by outlook, alarm clocks, aso.) it checks for "pleco.exe" running, and tries to close it (flashcards can be copied only when pleco itself is not running). after that the flashcard db is zipped into the folder from where the script is running.

so, to use it, you first need to install mortscript on your WinMo device (if you dont already have it)
after that i suggest to create a folder on your storage card like "BckPleco" and put the attached script file into that folder.
if you want the automatic startup of the script at any other time, edit the script (its a normal text file) and in the first line change the "3600 * 4" into any other value, its the number of seconds after midnight, when the script should execute.
the path to the flashcard db, and its name should be very much the same on every users system, the script takes the path to "My Documents" from the system variable, so whatever localization you have on your system it should work. if you moved the flashcard db to any other place, edit the script to let it find the right folder...
the output ZIP file is put into the same folder where you have put the script file, so it would be a good idea to put it on the storage card, otherwise its not very useful, hehe. the ZIP-files get the names "PFyyyymmddhhmm.zip", and the zip is (at least in my case) about 40% size of the original db. you need to clean up the backups yourself, otherwise you might fill your storage-card over the time...

to register the notification for automatic startup (which also survives soft reset) just start the script one time manually (should be possible via file manager, if mortscript is installed correctly on your device). in fact, you can start the script whenever you want to make a backup of your flashcard db (hence the filename includes hours,minutes). at any given time, there is at max just one notification for automatic startup registered, even if you start the script 7 times manually, hehe. the only difficulty i can think of now is, when you decide to change the backup location after the initial registering, but i guess if you understand whats going on in the script, you will find out how to solve this.

after the zip is completed (takes about a minute for my 5MB flashcard db) a message window pops up. so in the morning you will see, that your db was backed up. if you don't like the message, just remove the last line in the script.


script
(cant attach *.mscr, *.zip, *.7z, so just copy the follwing into file "plecobck.mscr", filename is significant, if you change it, you must adjust the script also...

Code:
dayoffset = 3600 * 4
pleco = "Pleco Flashcards.pqb"
mydoc = SystemPath("Documents") \ pleco
ToggleDisplay(ON)
days = TimeStamp() / 86400
nextrun = (days+1) * 86400 + dayoffset
RemoveNotifications(SystemPath( "ScriptPath" ) \ "plecobck.mscr")
RunAt(nextrun,SystemPath( "ScriptPath" ) \ "plecobck.mscr")
GetTime(hh,mm,ss,dd,nn,yyyy)
zipf = SystemPath("ScriptPath") \ "PF"&yyyy&nn&dd&hh&mm&".zip"
if ( ProcExists( "pleco.exe" ) )
  Close( "Pleco" )
  Sleep(3000)
  if ( ProcExists( "pleco.exe" ) )
    Message("Pleco is running and not closing... no backup made")
    Exit
  endif
endif
ZipFile(mydoc,zipf,pleco)
Message("Pleco Backup "&zipf&" done")
 
Top