set g_last2 [linsert $g_last2 end $g_lastinfo]
set fileio [open /home/ultralord/www/g_last2.txt "w"]
puts $fileio $g_last2
flush $fileio
close $fileio
that creates one txt file with name g_last2 .. i want w8 that proc run's second time then i want to create txt file with name g_last201 .. is it possible?
#instantiate the file_counter variable upon load
set file_counter 0
...
proc yourproc ....
set fileio [open "/home/ultralord/www/g_last2[format "%02u" [incr ::file_counter]]" "w"]
...
Here we use incr to increase the value of the counter upon every iteration of the code, and then format to achieve the desired 2-digit format with padding zeros.
Ohh, you meant restore..
Well, one way would be to include code to (re)write a simple tcl-script (loaded from your script once it completes) which basically sets the variable to the previous value...
set directory "txts/"
#only txt files :)
set pattern "*.txt"
if {[catch {glob "${directory}${pattern}"} files]} {
return "No files in this dir"
} else {
if {[string match "*[info script]*" $files]} {
set listOffilesInThistDir [expr [llength $files] -1]
}
}
now when you know filecount you script newfile to $listOffilesInThistDir + 1
good try also if you can make another proc and you can put one number like 1 1 1 1 and when you rehash the bot the variable read how many times you have the number 1 1 1 1 into a txt file and then you have your latest id number .