forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


VDS5 deleting files bug TIP

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Miscellaneous
View previous topic :: View next topic  
Author Message
filip
Valued Contributor
Valued Contributor


Joined: 07 Aug 2004
Posts: 340

PostPosted: Fri Dec 16, 2005 4:30 pm    Post subject: VDS5 deleting files bug TIP Reply with quote

My protection solution...

Newer put more than one project file in Code directory !!!

Use separate directories for projects !!!

When it happens it's 100% that you have main project open then just save
back and that's it.

Tested with high success...
Back to top
View user's profile Send private message Send e-mail
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Thu Jan 19, 2006 1:20 am    Post subject: Re: VDS5 deleting files bug TIP Reply with quote

I use separate directories for each project. I also compile to a sub-directory. And backup everything regularily. I never double-click on a project file if another project is already open. I always close the project before exiting the IDE.

A sure fire to lose all files in the project directory is to have a identical #DEFINE in both the main file and an included file. Or maybe it was OPTION, or #INCLUDE...

filip wrote:
When it happens it's 100% that you have main project open then just save back and that's it.

Except when your testing some code that crashes or freezes the IDE. Then it's all gone. No IDE to save the files from. And nothing in the recycle bin. And what about if you close the IDE before you find out it's eaten your files. Also, the IDE only saves the project file when exiting (cleanly) so you can end up losing any changes you've made there, including version number increments.


My solution (after the IDE crashed 5 times in 5 hours) is to:
Compile to a "compile" sub directory.
Backup the Project and Source files to a "backup" sub directory.
Append the version number to the end of the backups' filenames.

To automate this I wrote VDS Version Backup and now just:
Save changes (which I now do as changes are made), compile, and run my "VDS Version Backup" program from the Tools menu.

This way I can restore, or revert, back to any previous version. I can even compare changes I made or easily find the version that worked if I've made incorrect changes at some point. It only backs up files with the A attribute - so if you have many included files it won't back them up unnecessarily. It also copies the compiled exe to the project directory so @verinfo(%0,V) works within the IDE.

But the best part is it alerts you to that fact that the IDE has eaten your files. If it warns you that the version number already exists you can be sure that your files (in the project directory) have been deleted and you've opened an older project file.


Code:
#-----------------------------------------------------------------------------#
# Program:    VDS Version Backup                                              #
# Author:     Dave(R)                                                         #
# Copyright:  2005, ToppyTools                                                #
#-----------------------------------------------------------------------------#

  OPTION SCALE,96
  OPTION DECIMALSEP, "."

  TITLE VDS Version Backup

  gosub RegRead


#-----------------------------------------------------------------------------
#  CREATE AND SHOW DIALOG

  DIALOG CREATE,VDS Version Backup,-1,0,436,205,ONTOP
  DIALOG ADD,STYLE,STYLE1,,,R
  DIALOG ADD,STYLE,STYLE2,Verdana,,C
  DIALOG ADD,TEXT,TEXT1,22,10,80,13,PROJECT:,,STYLE1
  DIALOG ADD,COMBO,Project_,19,95,259,21,%%project,,CLICK
  DIALOG ADD,BUTTON,BF1,19,358,35,21,Find
  DIALOG ADD,BUTTON,BD1,19,396,22,21,X,,STYLE2
  DIALOG ADD,TEXT,TEXT2,51,10,80,13,Source Path:,,STYLE1
  DIALOG ADD,COMBO,Source_,48,95,259,21,%%srcpath,,CLICK
  DIALOG ADD,BUTTON,BF2,48,358,35,21,Find
  DIALOG ADD,BUTTON,BD2,48,396,22,21,X,,STYLE2
  DIALOG ADD,TEXT,TEXT3,80,10,80,13,Compiled Path:,,STYLE1
  DIALOG ADD,COMBO,Compiled_,77,95,259,21,%%compath,,CLICK
  DIALOG ADD,BUTTON,BF3,77,358,35,21,Find
  DIALOG ADD,BUTTON,BD3,77,396,22,21,X,,STYLE2
  DIALOG ADD,TEXT,TEXT4,109,10,80,13,Backup Path:,,STYLE1
  DIALOG ADD,COMBO,Backups_,106,95,259,21,%%bakpath,,CLICK
  DIALOG ADD,BUTTON,BF4,106,358,35,21,Find
  DIALOG ADD,BUTTON,BD4,106,396,22,21,X,,STYLE2
  DIALOG ADD,BUTTON,Backup_,144,112,64,24,Backup,,DEFAULT
  DIALOG ADD,BUTTON,Save_,144,188,64,24,Save
  DIALOG ADD,BUTTON,Cancel_,144,263,64,24,Cancel
  DIALOG ADD,STATUS,STATUS1,
  DIALOG SHOW

  gosub HistoryRead

 
#-----------------------------------------------------------------------------
#  EVENT LOOP
   
:EvLoop
  wait event, .3
  # %V is event, %W is dialog number that issued it (0,1,2,etc.)
  parse "%V;%W", @event(D)
  dialog select, %W
  goto %V


#-----------------------------------------------------------------------------
#  TIMER CODE

:Timer
  # Disable unusable buttons
  if @dlgtext(Project_)
    dialog enable,BD1
  else
    dialog disable,BD1
  end
  if @dlgtext(Source_)
    dialog enable,BD2
  else
    dialog disable,BD2
  end
  if @dlgtext(Compiled_)
    dialog enable,BD3
  else
    dialog disable,BD3
  end
  if @dlgtext(Backups_)
    dialog enable,BD4
  else
    dialog disable,BD4
  end
  if @null(@dlgtext(Project_)) @null(@dlgtext(Source_)) @null(@dlgtext(Backups_)) @null(@dlgtext(Backups_))
    dialog disable,Backup_
    dialog disable,Save_
  else
    dialog enable,Backup_
    dialog enable,Save_
  end
  goto evloop


#-----------------------------------------------------------------------------
#  CLOSE PROGRAM

:Close
:Cancel_BUTTON
  stop


#-----------------------------------------------------------------------------
#  BUTTON EVENTS

:BF1BUTTON
  %%project = @name(@filedlg(Choose Project Filename,%%project))
  dialog set,Project_,%%project
  goto EvLoop


:BF2BUTTON
  %%srcpath = @dirdlg(Choose Source Directory,%%srcpath)
  dialog set,Source_,%%srcpath
  goto EvLoop


:BF3BUTTON
  %%compath = @dirdlg(Choose Compile Directory,%%compath)
  dialog set,Compiled_,%%compath
  goto EvLoop


:BF4BUTTON
  %%bakpath = @dirdlg(Choose Backup Directory,%%bakpath,shownewfolderbutton)
  dialog set,Backups_,%%bakpath
  goto EvLoop


:BD1BUTTON
  %X = @msgbox(Are you sure you want to delete the selected Project name?    ,Delete Project Name,$024)
  if @equal(6,%X)
    %%project = @dlgtext(Project_)
    registry delete,default,,Project,%%project
    registry delete,default,History\Project,%%project
    gosub HistoryRead
    dialog set,Project_,
  end
  %X =
  goto EvLoop


:BD2BUTTON
  %X = @msgbox(Are you sure you want to delete the selected Source path?    ,Delete Source Path,$024)
  if @equal(6,%X)
    %%srcpath = @dlgtext(Source_)
    registry delete,default,,SourcePath,%%srcpath
    registry delete,default,History\SourcePath,%%srcpath
    gosub HistoryRead
    dialog set,Source_,
  end
  %X =
  goto EvLoop


:BD3BUTTON
  %X = @msgbox(Are you sure you want to delete the selected Compile path?    ,Delete Compile Path,$024)
  if @equal(6,%X)
    %%compath = @dlgtext(Compiled_)
    registry delete,default,,CompiledPath,%%compath
    registry delete,default,History\CompiledPath,%%compath
    gosub HistoryRead
    dialog set,Compiled_,
  end
  %X =
  goto EvLoop


:BD4BUTTON
  %X = @msgbox(Are you sure you want to delete the selected Backup path?    ,Delete Backup Path,$024)
  if @equal(6,%X)
    %%bakpath = @dlgtext(Backups_)
    registry delete,default,,BackupPath,%%bakpath
    registry delete,default,History\BackupPath,%%bakpath
    gosub HistoryRead
    dialog set,Source_,
  end
  %X =
  goto EvLoop


:Save_BUTTON
  %%project = @dlgtext(Project_)
  %%compath = @dlgtext(Compiled_)
  %%srcpath = @dlgtext(Source_)
  %%bakpath = @dlgtext(Backups_)
  gosub RegWrite
  info  Current selections saved.   ,
  goto EvLoop


:Backup_BUTTON
  %%project = @dlgtext(Project_)
  %%compath = @dlgtext(Compiled_)
  %%srcpath = @dlgtext(Source_)
  %%bakpath = @dlgtext(Backups_)
  # Get file version from compiled exe
  %%exever = @verinfo(%%compath\%%project.exe,V)
  %O = 0

  if @both(@file(%%compath\%%project.exe,A),@equal(%%exever,@verinfo(%%compath\%%project %%exever.exe,V)))
    warn  Version number already exists!    ,
  else
    if @file(%%compath\%%project.exe,A)
      #//// Backup Compiled EXE file if Archive attribute set ////
      dialog set,status1,"    "Backing up %%project.exe
      file copy,%%compath\%%project.exe,%%compath\%%project %%exever.exe,allowundo,showerrors,confirm
      rem file delete,%%srcpath\%%project.exe
      if @ok()
        file copy,%%compath\%%project.exe,%%srcpath\%%project.exe,allowundo,showerrors
        # Clear Archive attribute on original file
        file setattr,%%compath\%%project.exe,-A
      end
      wait .1
      %O = @succ(%O)
    end

    #//// Backup DSC source file(s) and DSP project file ////
    list create,5
    # Create list of files with Archive attribute set
    list filelist,5,%%srcpath,A
    %%qty = @count(5)
    %%cnt = 0
    # Loop through files in list
    while @unequal(%%qty,%%cnt)
      list seek,5,%%cnt
      # Only backup .dsc and .dsp files
      if @equal(dsc,@ext(@item(5))) @equal(dsp,@ext(@item(5)))
        %%ext = @ext(@item(5))
        %%name = @name(@item(5))
        if @file(@item(5),A)
          dialog set,status1,"    "Backing up %%name.%%ext
          file copy,%%srcpath\%%name.%%ext,%%bakpath\%%name %%exever.%%ext,allowundo,showerrors,confirm
          if @ok()
            file copy,%%srcpath\%%name.%%ext,%%bakpath\%%name.%%ext,allowundo,showerrors
            # Clear Archive attribute on original file
            file setattr,%%srcpath\%%name.%%ext,-A
          end
          wait .1
          %O = @succ(%O)
        end
      end
      %%cnt = @succ(%%cnt)
    wend
    list close,5
    %%qty =
    %%cnt =
    dialog set,status1,
    if @equal(0,%O)
      warn  Nothing to back up!    ,
    else
      info  Finished backing up to    @cr()@cr()%%project %%exever    ,
    end
  end
  goto close


#-----------------------------------------------------------------------------
#  COMBO CLICK EVENTS

:Project_CLICK
  %%project = @dlgtext(Project_)
  if @not(@null(%%project))
    registry write,default,,CurrentProject,%%project
    gosub regread
    dialog set,Compiled_,%%compath
    dialog set,Source_,%%srcpath
    dialog set,Backups_,%%bakpath
  end
  goto EvLoop


:Source_CLICK
  %%srcpath = @dlgtext(Source_)
  dialog set,Source_,%%srcpath
  goto EvLoop


:Compiled_CLICK
  %%compath = @dlgtext(Compiled_)
  dialog set,Compiled_,%%compath
  goto EvLoop


:Backups_CLICK
  %%bakpath = @dlgtext(Backups_)
  dialog set,Backups_,%%bakpath
  goto EvLoop


#-----------------------------------------------------------------------------
#  GOSUBS

:RegWrite
  # Save current settings to Registry
  if %%project
    registry write,default,,CurrentProject,%%project
    registry write,default,History\Project,%%project
  end
  if %%srcpath
    registry write,default,%%project,SourcePath,%%srcpath
    registry write,default,History\SourcePath,%%srcpath
  end
  if %%compath
    registry write,default,%%project,CompiledPath,%%compath
    registry write,default,History\CompiledPath,%%compath
  end
  if %%bakpath
    registry write,default,%%project,BackupPath,%%bakpath
    registry write,default,History\BackupPath,%%bakpath
  end
  exit


:RegRead
  # Set Combo Box vars from Registry
  %%project = @regread(default,,CurrentProject,)
  %%srcpath = @regread(default,%%project,SourcePath,)
  %%compath = @regread(default,%%project,CompiledPath,)
  %%bakpath = @regread(default,%%project,BackupPath,)
  exit


:HistoryRead
  # Create Combo Lists from History in Registry
  %X = @regexists(default,History\Project,)
  if @equal(1,%X)
    list regvals,Project_,default,History\Project
  end
  %X = @regexists(default,History\SourcePath,)
  if @equal(1,%X)
    list regvals,Source_,default,History\SourcePath
  end
  %X = @regexists(default,History\CompiledPath,)
  if @equal(1,%X)
    list regvals,Compiled_,default,History\CompiledPath
  end
  %X = @regexists(default,History\BackupPath,)
  if @equal(1,%X)
    list regvals,Backups_,default,History\BackupPath
  end
  %X =
  exit

_________________
cheers

Dave
Back to top
View user's profile Send private message
filip
Valued Contributor
Valued Contributor


Joined: 07 Aug 2004
Posts: 340

PostPosted: Thu Jan 19, 2006 11:24 am    Post subject: Reply with quote

Nice

If you add a zip archive creation that will be perfect...

I never use a backup program it's much easier to backup by my self
(burn to a CD or use a flash key device)

I use mini CD-RW to get quick access... Smile
Back to top
View user's profile Send private message Send e-mail
JRoza
Contributor
Contributor


Joined: 17 Aug 2003
Posts: 182
Location: Netherlands

PostPosted: Fri Jan 20, 2006 7:17 am    Post subject: Reply with quote

On the subject of backups .........
I know that Jules wrote a perfect little utility (in Vds) called GetBack.
It makes backups on the fly without you having to think about it.
Just specify which folders and files you want GetBack to monitor and GetBack makes a backup the moment one of those files is changed.
All this is done in the background without you even noticing it.
The beauty of this little gem is that you can go back one or more versions if you want that since it uses timestamps in the backup filenames, so no older backup files are overwritten.
It's not free but very cheap and very effective.
Saved me from trouble already on numerous occasions.

Very Happy
Jan
Back to top
View user's profile Send private message Visit poster's website
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Thu Jan 26, 2006 11:20 am    Post subject: Reply with quote

Or use CodeBackup Wink

[/spam Mr. Green]

Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Thu Jan 26, 2006 11:35 am    Post subject: Reply with quote

I do use CodeBackup when I want to back ALL my source and project files. Though I've never bothered to recover any files that it's backed up... yet. Wink
_________________
cheers

Dave
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Miscellaneous All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group