Hello I'm trying to automatic save the contents of a textwidget. Thisis the code I'm fighting with:
proc Vraagstukoverzicht {} {
set f [toplevel .overzicht]
frame $f.one
label $f.titel -text "Vraagstuktitel"
text $f.invoertitel -width 20 -height 1 -relief sunken
button $f.one.bevestig -text Bevestig -command {save}
button $f.one.verdwijn -text Verdwijn -command [list destroy $f]
pack $f.one -side bottom
pack $f.titel -side top
pack $f.invoertitel -fill x -expand true
pack $f.one.bevestig -side right
pack $f.one.verdwijn -side left
proc save { } {
global filename
set data [$f.invoertitel get 1.0 {end -1c}]
set file_types {
{"Text Files" { .txt .TXT} }
{"Tcl Files" { .tcl .TCL .tk .TK} }
{"All Files" * }
}
set filename [tk_getSaveFile -filetypes $file_types -initialdir pwd -initialfile $filename -defaultextension .tcl]
wm title . $filename
set fileid [open $filename w]
puts -nonewline $fileid $data
close $fileid
}
The error I'm receiving is:
Error: can't read "f": no such variable
I don't understand it I do declare F earlier in the procedure
proc Vraagstukoverzicht {} {
set f [toplevel .overzicht]
frame $f.one
label $f.titel -text "Vraagstuktitel"
text $f.invoertitel -width 20 -height 1 -relief sunken
button $f.one.bevestig -text Bevestig -command {save}
button $f.one.verdwijn -text Verdwijn -command [list destroy $f]
pack $f.one -side bottom
pack $f.titel -side top
pack $f.invoertitel -fill x -expand true
pack $f.one.bevestig -side right
pack $f.one.verdwijn -side left
proc save { } {
global filename
set data [$f.invoertitel get 1.0 {end -1c}]
set file_types {
{"Text Files" { .txt .TXT} }
{"Tcl Files" { .tcl .TCL .tk .TK} }
{"All Files" * }
}
set filename [tk_getSaveFile -filetypes $file_types -initialdir pwd -initialfile $filename -defaultextension .tcl]
wm title . $filename
set fileid [open $filename w]
puts -nonewline $fileid $data
close $fileid
}
The error I'm receiving is:
Error: can't read "f": no such variable
I don't understand it I do declare F earlier in the procedure