on 01-25-2014 10:45 AM
This is an example of reading file. of cause this is NOT for your scenario. if [infotag get cfg_avpair_exists dial-file] { set dial_file [string trim [infotag get cfg_avpair dial-file]] } else { set dial_file flash:/speed_dial.txt puts -nonewline " -- ERROR: Mandatory parameter speed dial file does not exist added default flash --" } proc readDataFile { fname } { global speedDialArray if [catch {set fd [open $fname] } errmsg] { error "Unable to open file: $fname for reading\n$errmsg" return -1 } set noDataRead 1 while {[gets $fd string] != -1} { set key [lindex $string 0] set data [lindex $string 1] puts "File: $fname ::key: $key :ata: $data ::" if { [regexp {^#} $key] } { puts "Line is a comment" continue } if { ![regexp {^[0-9]*$} $key] } { puts "Invalid Key: $key is given in file: $fname, ignoring this key option" continue } if { [regexp {^[0-9]*$} $data] } { puts "Speed Dial Phone number: $data is assigned to Key: $key" set speedDialArray($key) $data set noDataRead 0 } } ;#end of while # Process any errors that occurred during the read if ![eof $fd] { error "Error occurred while reading 'somefile'" } close $fd if { $noDataRead } { log -s ERR "Tcl script : No data readed from Speed dial data file, please check the Content file, might be corrupted" } } flat file format: 21 0123456789 24 1123456789Lisandro Quinteros:Thanks for you reply.. I will start researching because I have no idea how to load variables from a text file. It's seems to be a good choice… But I got another doubt now… Today I load in the text file 8 holiday dates..2 weeks later I have to add another date.. I would have to reload the tcl application to cache? Just read the file when hetting ev_setup_indication then it should be fine And how it’s the syntaxes to make an IF statement to compare today_date_is vs. ALL dates from the text file… My idea is to make a generic If statement so when I add a new date to the text file it's not necessary to change the if statement… How to compare the date string is really your choice. if possible I would use soemthing like "04172013" for April 17 2013. Thanks..
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: