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.

Expl Script

Old posts that have not been replied to for several years.
Locked
G
Guest

Post by Guest »

It writes to a file like:
test1;testing 1..2..3;BoB
test2;testing 1..2..3;Fred

This code gets the test1 test2 out of that

proc pxexpl:get {term chan} {
set fd [open $chan.define r]
while {![eof $fd]} {
set input [gets $fd]
if {[pxexpl:term $input] == [string tolower $term]} {
close $fd
return "[string range $input [expr [string last ";" $input]+1] end] [string range $input [expr [string first ";" $input]+1] [expr [string last ";" $input]-1]]"
}
}
close $fd
return 0
}

proc pxexpl:term {fstring} {
set term [string range $fstring 0 [expr [string first ";" $fstring]-1]]
if {$term != ""} { return $term } else { return 0 }
}

but i want it to get the nickname out just the nickname on its own like BoB, Fred
how can i do this?, Thanks

p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This seems a rather complex script, for such a simple task.

it would be simple enogugh to use split and lindex to get each section of text.

Code: Select all

proc pxexpl:get {term chan} { 
set fd [open $chan.define r] 
while {![eof $fd]} { 
set input [gets $fd] 
if {[pxexpl:term $input] == [string tolower $term]} { 
close $fd 
return [lindex [split $input ";"] 2]
} 
} 
close $fd 
return 0 
} 
Locked