Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update values

Status
Not open for further replies.

bebig

Technical User
Oct 21, 2004
111
US
I want to update values into txt file.

this is original file.(file name is t.txt)

1 10:10 11:20
2 10:30 11:40
3 11:00 12:00

I have one TCL page to call these data and another page to send updated data into t.txt file.
when I made a code, I used first colum as lindex 0(number), second colum as lindex 1(time 1), and third colum as lindex 2(time2).
But this time, I want to have first col. as lindex 0(number), second col. as lindex1 (default), third col. as lindex 2(time 1), forth col. as lindex 3(time 2), fifth col. as lindex 4(another default value) on t.txt file.


The reason why I use default value is if I need to update values into t.txt file, I want to send data to only these two default areas.

But, when I have default values, I got different values.

Would you please help me??

thank you in advance.


====sample code====
set auditoriumNum ""
set beforeStartTime ""
set selectedData "$houseNum $startTime $endTime"
set selectedData "$houseNum $auditoriumNum $beforeStartTime $startTime $endTime "
lappend storeList $selectedData; #list of lists

gets $readFile line

} ;#end of while

set StoreName ""
set StoreId ""
set StoreNum ""

for {set i 0} {$i < [llength $storeList]} {incr i} {
if {$StoreId == [lindex [lindex $storeList $i] 0]} {
lappend store($StoreId) [lindex $storeList $i]
} else {
set StoreId [lindex [lindex $storeList $i] 0]
lappend store($StoreId) [lindex $storeList $i]
}
if {[lsearch -exact $StoreName store($StoreId)] == -1} {
lappend StoreName store($StoreId)
lappend StoreNum $StoreId
}
}

set StoreNum [lsort -index 0 $StoreNum]
foreach elem $StoreNum {
set ssL $store($elem)
set storeOpen($elem) [lsort -index 2 $ssL]
##
set open1 "[lindex $storeOpen($elem) 0]"


set openIndex1 [lindex $open1 0];#house number

set openIndexA [lindex $open1 1];# default, auditorium
set openIndexAs [lindex $open1 2];# default, startUp

set openIndex2 [lindex $open1 3];#earliest opening time


set storeClose($elem) [lsort -index 2 -decreasing $ssL]


set close1 "[lindex $storeClose($elem) 0]"

set closeIndex1 [lindex $close1 4];#earliest closing time



set theResults "$openIndex1 $openIndexA $openIndexAs $openIndex2 $closeIndex1" ;# it sends to common.txt file.

puts "$theResults"



}
 
I'm having difficulty decoding your script (it always seems clearer to the author than to anyone else). Where exactly is the script failing and what is it doing?

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top