Post Reply 
Program which adds UNDO for programs
09-30-2015, 06:12 PM (This post was last modified: 09-30-2015 08:52 PM by xset.)
Post: #1
Program which adds UNDO for programs
Hey

This is semi-automatic UNDO (backup mechanism)

Press Shift-USER B (B is button Mem) to Backup current version of current program (or last edited if u are not editing some program). Your current version will be stored to BACKUP 1.

Press Shift-USER U (U is button 4) to Restore from BACKUP 1 or undo your previous restore (just in case) from BACKUP 2. So u can flip two versions (previous or saved) calling undo again and again.

Note!!! that u will be thrown away from editor to programs catalog because it can't change text during editing.

You can comment out lines with MSGBOX (at least in Backup code) to avoid pressing annoying OK.

Code:

KEY K_Math() // Shift-USER B ([Mem] button) Backup current program
BEGIN
    LOCAL ProgLst:=Programs;
    LOCAL PName:=ProgLst(1);
    Programs(PName+"_BKUP2"):=""; //delete prev bkup
    Programs(PName+"_BKUP"):=Programs(PName);
    MSGBOX("BACKUP SAVED");
    RETURN "";
END;

KEY K_4() // Shift-USER U (4 button) Restore last backup saving current in backup2 or vise versa
BEGIN
    LOCAL ProgLst:=Programs;
    LOCAL PName:=ProgLst(1);
    IF POS(ProgLst,PName+"_BKUP")>0 THEN
       STARTVIEW(-7,1);
       Programs(PName+"_BKUP2"):=Programs(PName);
       Programs(PName):=Programs(PName+"_BKUP");
       Programs(PName+"_BKUP"):=""; // delete bkup
       MSGBOX("BACKUP 1 RESTORED (U CAN UNDO IT)");
    ELSE
       STARTVIEW(-7,1); 
       IF POS(ProgLst,PName+"_BKUP2")>0 THEN // Have bkup to undo
          Programs(PName+"_BKUP"):=Programs(PName); // save current in first
          Programs(PName):=Programs(PName+"_BKUP2"); // save bkup undo in program
          Programs(PName+"_BKUP2"):=""; // Remove second bkup
          MSGBOX("BACKUP 2 RESTORED (U CAN UNDO IT)");
       ELSE // No bkups
          MSGBOX("NO BACKUPS SORRY");
       END;
    END;
    RETURN "";
END;


Attached File(s)
.hpprgm  ProgUndo.hpprgm (Size: 2.41 KB / Downloads: 7)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)