O'Reilly logo

Practical Programming in Tcl & Tk, Third Edition by Brent B. Welch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Managing the Preferences File

The preference settings are saved in the per-user file. The file is divided into two parts. The tail is automatically rewritten by the preferences package. Users can manually add resource specifications to the beginning of the file and they will be preserved:

Example 42-8 Saving preferences settings to a file.
# PrefSave writes the resource specifications to the
# end of the per-user resource file,
proc PrefSave {} { global pref if [catch { set old [open $pref(userDefaults) r] set oldValues [split [read $old] \n] close $old }] { set oldValues {} } if [catch {open $pref(userDefaults).new w}out] { .pref.but.label configure -text \ "Cannot save in $pref(userDefaults).new: $out" return } foreach line $oldValues { if ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required