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.

Lsearch HELP!

Help for those learning Tcl or writing their own scripts.
Post Reply
e
eric
Voice
Posts: 1
Joined: Thu Oct 20, 2005 11:41 am

Lsearch HELP!

Post by eric »

I need help with my script, i have problem with lsearch command, return bad value

Script:

#make a list
set List1 [list 5,83.21,Text1,text1 3,83.22,TeXt2,text2 1,83,23,Tex[t,tex[t]

# List1 = {5,83.21,Text1,text1 3,83.22,TeXt2,text2 1,83,23,Tex[t,tex[t}

#list search
set Var1 {tex[t}
set Var2 "*,$Var1"
set VarIndex [lsearch $List1 $Var2]

VarIndex is set 0, when it must set 2.

Somebody can help me? :cry:
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Because [ has a special meaning in glob match. Try skipping it (i.e. use \[ instead of just [).
Post Reply