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.
Old posts that have not been replied to for several years.
T
TheElite
Post
by TheElite » Fri Aug 09, 2002 2:16 am
Well... I was trying to use isnumber but it doesn't seem to work. I made it echo to the channel to see what it returned and it always returns 0, no matter what.
Code: Select all
putmsg $chan "$dice $sides blah[isnumber dice]blah[isnumber sides]blah"
I put the blahs there to see if I was getting spaces in it. Howerver, there were no spaces. Here's the variable assignment.
Code: Select all
set dice [string range $text 0 [string wordend $text 0]]
set sides [string range $text [string wordend $text 0] [string wordend $text 1]]
If anyone can help, it'd be much appreciated.
ppslim
Revered One
Posts: 3914 Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England
Post
by ppslim » Fri Aug 09, 2002 4:55 am
isnumber is not a Tcl command, unless it is provided by a tool set or another script.
Besides that, the way you use the variables in the script is wrong.
using "isnumber dice" is like asking if the word "dice" is a number. This is clearly faulse, so it returns 0.
Maybe you are trying to use the variable named "dice". In that case, you should use "isnumber $dice".
T
TheElite
Post
by TheElite » Fri Aug 09, 2002 12:05 pm
It's not a TCL command but it's a function provided by alltools.tcl
I tried doing it with a $... it still didn't work.
T
TheElite
Post
by TheElite » Fri Aug 09, 2002 12:35 pm
Ok, well I figured out that it was putting in whitespace... is there any function that gets rid of whitespace?
stdragon
Owner
Posts: 959 Joined: Sun Sep 23, 2001 8:00 pm
Contact:
Post
by stdragon » Sat Aug 10, 2002 1:49 am
You use isnumber like this:
if {[isnumber $blah]} {
putlog "it's a number"
}
Might I ask why (or where) you need to get rid of whitespace? If you're getting whitespace in your numbers, then you're extracting them wrong. But anyway, you get rid of whitespace like this (well, it's one way):
regsub -all " " $blah "" blah
I think I should point out that [string range] is not the best way to extract words from a string. Also, if you know you're trying to extract 2 numbers, you can use 1 regexp statement to extract and validate both of them.
T
TheElite
Post
by TheElite » Sat Aug 10, 2002 10:58 am
Thanks... I found that in another post after I had posted that... sorry