2026-01-05 Monday 1h 18 am
This has to be the most useful procedure I have had programmed in my Editor. It was coded by a brilliant French guy who lives in Israel.
It has saved my life on many occasions.
It works this way:
1. When you click on the procedure, it creates a directory called Backup next to the current directory. If the back-up directory already exists, it deletes it and replaces it with the new one.
2. It gives you a choice: You can either back-up a file or the entire directory.
Here is a trick I use: If I want to keep a version of my file or of my directory, I rename the Back-up directory with the date and it will stay forever.
This function is especially useful when your editor auto-saves.
Believe you me: Copy this code, install it on your editor and you'll have what's really the most important after health: Peace of mind!
# ------------------------------------------
#BEGIN src/save.in.the.backup.proc (called by ...)
proc save.in.the.backup {} {
if {"" eq $::data_dir || "" eq $::current_node} return
file mkdir [file join $::data_dir "Backup"]
write \
[set fd [open [file join $::data_dir "Backup" $::current_node].txt w]] \
[$::main_ht get 1.0 end-1c]
close $fd
$::main_ht edit modified 0
tk_messageBox -message " File: $::current_node\.txt has been copied in the Backup directory"
}
#END src/save.in.the.backup.proc