B4PPC Backup utility v1

Cableguy

Expert
Licensed User
Longtime User
Hi guys..
After yesterdays fiasco I went back to the drawing board and re-think my simple backup utility, and I am now happy to say that it is working....

First things first...

Execute Backup.exe ...

A form Pops with 3 basic inputs:

The file Extension you want your backups to have...
The number of Backups to keep
And the Folder in wich they will be created...

All these can be altered in the sbp file and the just re-compile it...
I hadded just a few basic ones in order to have a practical running app....

How to backup?

From your currently developing app add this line of code.

Shell("Backup.exe", YourFileName) You should replace YourFileName by the name you want the backups to have...

The utility Then creates a backup Folder based on the ini file, with the extension defined in the ini file and keeps the number of backups defined in the ini file...
 

Attachments

  • Bakup.zip
    57.1 KB · Views: 434

agraham

Expert
Licensed User
Longtime User
Hi Cableguy - I hope that you won't take this the wrong way, I want to educate not criticise, but as a software engineer could I make a couple of points regarding programming style

I don't think that "FileSearch" is guaranteed to return the filenames in any particular order as you are assuming, so it would be good programming practice to add a "nrfiles.Sort(cCaseSensitive)" line to your code after "FileSearch". This ensures that you know what order the filenames are in. This is called "defensive programming" where you add code to check what you are not already sure of. This change probably also means that you will have to reverse the order of your delete and copying as I think that the sort order of an ArrayList may be ascending.

Also, depending upon how the string sort is done your backup order may break if a user ever wanted 10 or more backups as File12.bak may sort before File2.bak. I haven't checked this on B4PPC but it is the principle I am commenting on. Defensive programming would add a maximum (and minimum) check so that all the names that could ever possibly be produced are guaranteed sortable correctly.

Also "goto" is normally regarded as anathema in structured programming. It would be better programming style, and make your intentions easier for others to read, to abstract your your "CopyFiles" section to a sub of its' own.

I am afraid that you may think this is being pedantic, and maybe it is for a small program but think about how many traps, such as I've pointed out, you can lay for yourself with a larger application and how much debugging grief you can save by defensively programming in the first place.
 

Cableguy

Expert
Licensed User
Longtime User
Thanks for the hints....

Althought the status say I'm a veteran it only reflects the number of post I have in this Great comunity, not my programing experience...
Still with B4PPC I've come to atlest be able to do a complete working program...With other languages, every time I got stuck there just wasn't anyone to turn to and ask....

I have said before, I hope to learn with others, and others experience in other languages and logical thinking...

In programing I'm a bit like a child playing with a bag of toys and don't relly know how to get to what I want...so I start coding and sometimes realize my aproach is wrong and restart...

I need to learn a bit more of programing logic, as in flowcharting the sequence of the code...and such...

Anyway I Thank you for having the time to look at my app, and hope it does what it was created to do....
 

agraham

Expert
Licensed User
Longtime User
You post - I listen and comment if you are willing to to listen to what I say. I have been associated with computers for more than 40 years and over that time it has got more and more difficult for beginners to be able to get a start in programming as the complexity of being able to achieve anything worthwhile has increased. Despite the availability of the Express versions of Visual Studio (which are still a bit daunting for beginners) I think that Basic4PPC,which has a simplified programming model of the .NET framework, is a superb tool for starters -especially as it can target portable devices and enable development on the device. If I can at least help a few people to achieve something that they would otherwise not be able to achieve then I am happy,

Enjoy!
 
Top