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.

is it possible...

Old posts that have not been replied to for several years.
Locked
P
PloP

is it possible...

Post by PloP »

....to sort the following code so user input has to be at least 3 characters ?
i tried changing the if {[llength $arg] < 3} then { but that doesnt work.


proc qfind {nick host hand chan arg} {
if {[llength $arg] < 1} then {
putquick "NOTICE $nick : You might wanna put in a search word to limit the list a bit"
return
a
abn0rmal

Post by abn0rmal »

i suppose "at least 3 characters" should mean that [llength $arg] should be < 4
logic ;)
I
Iridium

Post by Iridium »

You're using llength. That counts the number of 'elements' in a list. (in this case the number of words). Using llength on raw user input is bad because whatever they input will be interpretted literally.

if you want to count the number of words, do this:

Code: Select all

if {[llength [split $arg]] < 4} {
  # put in less than four arguments.. fob them off
} else {
  # they put in four or more arguments.. code to do whatever goes here
}
But that isn't even what you want. You want to count the number of characters he put in.

Code: Select all

if {[string length $args] < 4} {
  # they put in less than four characters.. bitch at them
} else {
  # they put in four or more arguments.. code to do whatever goes here
}
Hope that helps.
Last edited by Iridium on Thu Aug 29, 2002 3:18 pm, edited 1 time in total.
P
PloP

Post by PloP »

thx a bunch iridium... just what the doctor ordered :>
I
Iridium

Post by Iridium »

No problem, glad to be of service :D
Locked