trying to say if line 2 == BLANK and line 1 is either XBox or PS3 do this!
This is beginning to sound like some sort of echo/pre/warez script to me. But before we address that, your mistaking how lindex works. lindex is short for list index, and works similar to how lrange does. To get each line, its better to use a [split $t \n] with a foreach.
Now to address the warez aspect, thats more than likely all the help you will get as this is going to be used it seems for piracy... ;/
if its multiple lines with <carriage returns> your going about it completely wrong and fail to understand how lindex works. It isnt line index, it is list index. When you split without a paramter, which [split $t] does, it makes a list of words. [lindex [split $t] 2] = the 3rd word ([lindex [split $t] 0] would be the 1st), not the 2nd line of the file as you mistakenly believe. For you to get better help, perhaps paste some of the actual script that needs fixing, or at the very least what contents $t is holding....
no you are just confusing me. sorry I don't think you understand the way im trying to do it =[ I'm ONE line away from it being perfect, and can't figure it out.
theice wrote:no you are just confusing me. sorry I don't think you understand the way im trying to do it =[ I'm ONE line away from it being perfect, and can't figure it out.
set consoles [split "xbox ps3"]
set styles [split "guitar bass vox drums"]
set difficulties [split "easy medium hard expert"]
if {[llength [split $t]] != 3 || [lsearch -exact $consoles [string tolower [lindex [split $t] 0]]] < 0 || [lsearch -exact $styles [string tolower [lindex [split $t] 1]]] < 0 || [lsearch -exact $difficulties [string tolower [lindex [split $t] 2]]] < 0} {
putserv "NOTICE $n :\002Syntax error:\002 please use (.search console [XBox/PS3] [Guitar/Bass/VoX/Drums] [Easy/Medium/Hard/Expert]) ie \002.search console PS3 VoX Expert\002"
} else {
set console [string tolower [lindex [split $t] 0]]
set style [string tolower [lindex [split $t] 1]]
set difficulty [string tolower [lindex [split $t] 2]]
# rest of script goes here
}
##no-word-wrap#################################################################################################################################################################################################################################################################
The above code, stores your search terms you want to appear in lists above. Clearly you see this. First we check list length, if it isnt 3 they fudged up. Next we use lsearch to check our search term lists against the users split input using their positions against this list, if we don't find it trigger the message. It's very simple. This works.
PS. What I'm trying to tell you, is your more than one line away from doing it. This is how you do it elegantly, allowing you to easily change those lists to accept less or more terms. Hard coding them is messy.