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.

String tolower

Help for those learning Tcl or writing their own scripts.
Post Reply
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

String tolower

Post by Buffy_25 »

Hi,

I have a problem with the following code.
When a user joins and leaves after a certain period, i add (if not created yet in mysql-DB) or update his uptime in mysql-DB (if already created).

My problem is, when a person leaves (i.e. MaRkO) and he was already created as marko, then the database will create a new user in stead of updating his actual ID.

Does any one have an idea why the string tolower isn't working?

Thanks.

Buffy

Code: Select all

proc userleft {nick uhost hand dest key arg} {
set fs1 [open /home/account/eggdrop/logs/timeon.txt a+]
puts $fs1 "$arg"
close $fs1
set user [lindex [split $arg] 0]
set time [join [lrange $arg 1 end]]
mysql_connect datab localhost account passw /var/lib/mysql/mysql.sock
set listuser [mysql_query "SELECT name FROM Userinfo"]
foreach a $listuser {
 lappend list1 [string tolower $a]
 }
 if {[lsearch -exact $list1 [string tolower $user]] == -1} {
   set insert_command [mysql_query "INSERT INTO Userinfo (name) VALUES ('$user')"]
   set newtime [mysql_query "UPDATE Userinfo SET timeon='$time' WHERE name='$user'"]
   set time [convert_online $time]
   set timesec [mysql_query "UPDATE Userinfo SET timeonsec='$time' WHERE name='$user'"]
  } else {
  set presenttime [mysql_query "SELECT timeon FROM Userinfo WHERE name='$user'"]
  set convpresenttime [convert_online $presenttime] #the convert_online is working ok !
  set convuseronline [convert_online $time]
  set useronline [expr $convuseronline+$convpresenttime]
  set onlinetime [duration $useronline]
  set newtime [mysql_query "UPDATE Userinfo SET timeon='$onlinetime' WHERE name='$user'"]
  set newtime [mysql_query "UPDATE Userinfo SET timeonsec='$useronline' WHERE name='$user'"]
 }
}
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

string tolower is not applied on all the $user variables in your code. Why don't you initialize it as lower case

Code: Select all

set user [string tolower [lindex [split $arg] 0]]
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

Hi Sir_Fz,

This could be an option, but the problem is that my variables are used kindly everywhere in my scripts, and i would prefer to avoid to modify whole my scripts.
Therefor i tried to keep my nicks as they are, but just wanted to check between the nick registered in database and the nick that left.

Is there a way that i could make it being applied to all the variables?

Thanks.

Buffy
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

If the variable isn't global, you can only apply string tolower inside the proc.
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

I found the problem Sir_Fz ! :)

Thanks for the notice !

Buffy
Post Reply