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.
Support & discussion of released scripts, and announcements of new releases.
parakeet
Voice
Posts: 3 Joined: Sun Jun 04, 2023 5:22 am
Post
by parakeet » Sun Jun 04, 2023 6:27 am
The script: Conversion v1.00, date 20-05-2001 by DrN
Filename: tempc100.tcl
Download URL:
https://tclarchive.org/search.php?str=conversion
There are 3 binds:
!c2f
!f2c
!convert
It's a pretty nice script and I like it a lot but I had to fix all the formulas for the conversions as they gave incorrect results.
For conversions between Celsius and Fahrenheit with !c2f or !f2c, if I enter a negative number the script tells me that my input is incorrect. I know that the procedure 'isnum' checks for a number but it doesn't seem to account for negative numbers. This is not a big deal since I can use: !convert -20 celsius * farenheit instead which does work because it doesn't use the proc isnum, but it's a bit annoying nonetheless.
Is there a way to modify the isnum procedure to allow for negative numbers without adding or modifying too much code?
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Sun Jun 04, 2023 11:19 am
Here's two options:
scan and
string is integer .
Code: Select all
bind pub - [cmdchar]c2f pub_c2f
proc pub_c2f {nick uhost hand chan rest} {
set data [lindex $rest 0]
if {![isnum $data]} {putserv "PRIVMSG $nick :Calling syntax is ${cmdchar_}c2f <tempeture in celsius>"
return 1}
set cdata [expr $data * 1.8 + 32]
putserv "PRIVMSG $chan :$data degrees celsius is $cdata degrees farenheit."
}
becomes:
Code: Select all
bind pub - [cmdchar]c2f pub_c2f
proc pub_c2f {nick uhost hand chan text} {
if {[scan $text {%d} no] != 1} {
puthelp "PRIVMSG $nick :Calling syntax is ${cmdchar_}c2f <temperature in celsius>"
return
}
set temp [expr $no * 1.8 + 32]
puthelp "PRIVMSG $chan :$no degrees Celsius is $temp degrees Farenheit."
}
or:
Code: Select all
bind pub - [cmdchar]c2f pub_c2f
proc pub_c2f {nick uhost hand chan text} {
set no [lindex [split $text] 0]
if {![string is integer $no]} {
puthelp "PRIVMSG $nick :Calling syntax is [cmdchar]c2f <tempeture in celsius>"
return
}
set temp [expr $no * 1.8 + 32]
puthelp "PRIVMSG $chan :$no degrees Celsius is $temp degrees Farenheit."
}
Adapt the rest of the code in a similar manner.
Edit: typo fix.
Last edited by
caesar on Mon Jun 05, 2023 3:14 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
Online
CrazyCat
Revered One
Posts: 1301 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Sun Jun 04, 2023 4:00 pm
parakeet
Voice
Posts: 3 Joined: Sun Jun 04, 2023 5:22 am
Post
by parakeet » Sun Jun 04, 2023 4:03 pm
Thank you caesar and CrazyCat. So far caesar's code don't seem to work very well.
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Mon Jun 05, 2023 3:12 am
Fixed typos above as I did a copy/paste and forgot to replace some variables.
Once the game is over, the king and the pawn go back in the same box.
parakeet
Voice
Posts: 3 Joined: Sun Jun 04, 2023 5:22 am
Post
by parakeet » Wed Jun 07, 2023 12:33 am
Thank you caesar, I will test this tomorrow.