hi guys,
i'm making a graphic for my Scilabprogramm with TCl/Tk.And i am new in Tcl/TK. i want to write variables that from my graphic into a File.My codes are:
proc savefile {}{
global name
global jointnr
for { set i 1} { $i <= $jointnr } { incr i +1 } {
global theta$i
global alpha$i
global a$i
global s$i
global poor$i
}
set filename [tk_getSaveFile -filetypes $types -parent. -initialfile $name.txt ]
set fh [open $filename "w+"]
puts $fh "$name"
puts $fh "$jointnr"
puts $fh "$alpha1 $a1 $theta1 $s1 "
puts $fh "$alpha2 $a2 $theta2 $s2 "
close $fh
}
i get the variables "name","jointnr","alpha1","a1".... from outside. I mean i give the values on the graphic,then the codes get the values and save in the file "$name.txt"(it works already)
but my question: how should i do so that i can write the variabels with a loop into the File.
i try something like :
for {set i 1}{i<=$jointnr}{incr i+1}{
puts $fh "$alpha$i $theta$i $a$i $s$i"
}
but it dont work and i dont know where is wrong. Has someone any idea??
thanks a lot!!!
i'm making a graphic for my Scilabprogramm with TCl/Tk.And i am new in Tcl/TK. i want to write variables that from my graphic into a File.My codes are:
proc savefile {}{
global name
global jointnr
for { set i 1} { $i <= $jointnr } { incr i +1 } {
global theta$i
global alpha$i
global a$i
global s$i
global poor$i
}
set filename [tk_getSaveFile -filetypes $types -parent. -initialfile $name.txt ]
set fh [open $filename "w+"]
puts $fh "$name"
puts $fh "$jointnr"
puts $fh "$alpha1 $a1 $theta1 $s1 "
puts $fh "$alpha2 $a2 $theta2 $s2 "
close $fh
}
i get the variables "name","jointnr","alpha1","a1".... from outside. I mean i give the values on the graphic,then the codes get the values and save in the file "$name.txt"(it works already)
but my question: how should i do so that i can write the variabels with a loop into the File.
i try something like :
for {set i 1}{i<=$jointnr}{incr i+1}{
puts $fh "$alpha$i $theta$i $a$i $s$i"
}
but it dont work and i dont know where is wrong. Has someone any idea??
thanks a lot!!!