Code: Select all
RANDOM0
Constant
RANDOM1
RANDOM2
RANDOM3
RANDOM4
RANDOM5
Code: Select all
foreach line [split [egghttp:data $sock] \n] {
if {[string match "*Constant*" $line]} {
putlog "$line"
# And i need to write line RANDOM4
}}
Code: Select all
RANDOM0
Constant
RANDOM1
RANDOM2
RANDOM3
RANDOM4
RANDOM5
Code: Select all
foreach line [split [egghttp:data $sock] \n] {
if {[string match "*Constant*" $line]} {
putlog "$line"
# And i need to write line RANDOM4
}}
Code: Select all
if {[set a [lsearch -exact [set b [split [egghttp:data $sock] \n]] "Constant"]] != -1} { putlog "random4: [lindex $b [expr $a + 4]]" }
Code: Select all
set data "RANDOM0\nConstant\nRANDOM1\nRANDOM2\nRANDOM3\nRANDOM4\nRANDOM5"
if {[set a [lsearch -exact [set b [split $data \n]] "Constant"]] != -1} {
putlog "constant: [lindex $b $a]"
putlog "random4: [lindex $b [expr $a + 4]]"
}
however, at second glance, it seems you want to check if "Constant" is in the line, rather than if the line equals "Constant". Try replacing -exact with -glob for the lsearch, and setting the pattern to "*Constant*".constant: Constant
random4: RANDOM4