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.

Problem with <,<=

Help for those learning Tcl or writing their own scripts.
Post Reply
r
romain
Voice
Posts: 12
Joined: Sun Oct 16, 2005 1:51 am

Problem with <,<=

Post by romain »

Hello ,

I've this script

Code: Select all

for {set i 0} {$i < [lindex $a 0]} {incr i} {
     if {0 < [lindex $a 0] <=5} {
      ##blabla
        if {$i == [lindex $a 0]} {
           ##blabla 
        }
    } elseif {5 < [lindex $a 0] <= 10} {
         ##blabla
        if {$i == 5} {
         ##blabla
        } elseif {$i == [lindex $a 0]} {
          ##blabla
        }
   }   
 } 
But don't works :?:
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

} elseif {5 < [lindex $a 0] <= 10} {
You mean

Code: Select all

} elseif {5 < [lindex $a 0] && [lindex $a 0] <= 10} {
And is [lindex $a 0] a number?
r
romain
Voice
Posts: 12
Joined: Sun Oct 16, 2005 1:51 am

Post by romain »

Thx Sir_Fz.

Yes it's a number. How verifier who a list is well a list of number?

Code: Select all

regexp {\d} [split $list]
:?:
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

romain wrote:Thx Sir_Fz.

Yes it's a number. How verifier who a list is well a list of number?

Code: Select all

regexp {\d} [split $list]
:?:
now if you get this, you deserve to work for the NSA :P
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
r
romain
Voice
Posts: 12
Joined: Sun Oct 16, 2005 1:51 am

Post by romain »

Lol demond,

i write now for work for the NSA :P

Just, i have this code

Code: Select all

foreach d [split $list] {
  if [regexp {\d} $d] {
   putlog "$d is a number"
  } else {
   putlog"$d is not a number"
  }
 }
It's good?
If yes, it's not possible to make more simple and fast for verify if a list is just a number list :?:
User avatar
BarkerJr
Op
Posts: 104
Joined: Sun Mar 30, 2003 1:25 am
Contact:

Post by BarkerJr »

I think you want \d+, right?
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You can check using the string command.
Post Reply