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"
}
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"
}