This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Jump to line

Old posts that have not been replied to for several years.
Locked
m
micky
Voice
Posts: 11
Joined: Mon Dec 13, 2004 10:07 am

Jump to line

Post by micky »

How i can jump to line in txt:

Code: Select all

RANDOM0
Constant  
RANDOM1 
RANDOM2
RANDOM3 
RANDOM4
RANDOM5
Code:

Code: Select all

foreach line [split [egghttp:data $sock] \n] {
if {[string match "*Constant*" $line]} {
putlog "$line"
# And i need to write line RANDOM4
}}
thx
s
spock
Master
Posts: 319
Joined: Thu Dec 12, 2002 8:40 pm

Post by spock »

Code: Select all

if {[set a [lsearch -exact [set b [split [egghttp:data $sock] \n]] "Constant"]] != -1} { putlog "random4: [lindex $b [expr $a + 4]]" }
photon?
m
micky
Voice
Posts: 11
Joined: Mon Dec 13, 2004 10:07 am

Post by micky »

this code not work :/
s
spock
Master
Posts: 319
Joined: Thu Dec 12, 2002 8:40 pm

Post by spock »

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]]"
}
produces:
constant: Constant
random4: RANDOM4
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*".
photon?
Locked