Hi. I have an Eggdrop connecting to a MySQL database using mysqltcl and displaying the info on an IRC channel. Some rows contain text that I don't want to display like <br> and I want to omit it.
I tried to use the "string map" function ( http://wiki.tcl.tk/2819 ) but the bot crashed when it read the <br> on string map {<br> } $post. Then I tried to put only br to see if I was using it correctly but it seemed that the instruction was ignored.
mysqlmap $db_handle {id username post date} {
set post [string map [list "<br>" " | "] $post]
putserv "privmsg $chan :$post"
}
You use the string map to convert, but are never storing those results as a variable. I included the "set post" and bracket encapsulation [ ] around the [string map] to properly build the correct sequence of commands (stacking). I've also used [list "replace-this" "with-this"] which will work properly regarding variables replacements and special characters (ie, un-exploitable via errors or otherwise), as
is the preferred way to do [string map] rather than hand-crafting within curly braces { }.
School is now in session. The bell has rang. Classroom is filling with students. Grab a seat while you can...
/me takes a bite of the apple on his desk.
Having fun, is of tantamount importance as the task at hand. Remember this. Don't get angry, or give up when learning tcl. Have fun. Consider your failures as lessons, character building exercises. Not as some fundamental skill you lackl. Nobody is perfect. Having a laugh at stupid mistakes helps. Having fun while coding seriously is why I have a lot of success. For no other reason. I enjoy scripting for eggdrop. This is what keeps me sane. This is my wooden ship in a bottle, that I slowly build meticulously piece by piece over time.
Last edited by speechles on Fri May 20, 2011 6:22 pm, edited 1 time in total.