Re: Standard toolkit
- Posted by "Kat" <gertie at visionsix.com> Jul 06, 2005
- 686 views
On 6 Jul 2005, at 8:14, Jason Gade wrote: > > > posted by: Jason Gade <jaygade at yahoo.com> > > Kat wrote: > > > > Re: strings > > > > There's nice basic (no pun intended) functions in string.e by Greg Harris > > > > For "associated strings", there's several, i began using Jiri Babor's a > > while > > back. It makes up for the lack of dynamic string generation which mirc and > > many Basics have. It can also be slightly modified to make it run code on > > certain vars when you access them. > > > > For regex, David Cuny wrote one years ago, and Bach has regex.b. > > > > Kat > > > > > Pardon my ignorance, but what is "dynamic string generation"? At a basic level, in some languages, you don't need to pre-declare all the variables you wish to use. You don't even need to state the form the name of the var takes or the data it holds, which makes languages like mirc very adept at finding things (altho mirc is so much slower than Eu it's not even on the same planet). Instead of: sequence thisvar, thatvar you simple begin using the var's name: anothervar = "blah" or, like i am fond of doing in mirc: if ( %npass.oper. [ $+ [ %net ] $+ . $+ [ %server ] $+ . $+ [ $me ] ] != $null ) { ; code here } or: if ( %iop. [ $+ [ %net ] $+ . $+ [ # ] ] == yes ) { idme } and in that code i don't need to spec what network i am on, the server's name, or my nick there, or that the var even exists or what form (sequence, integer, etc) the var has. If the var doesn't exist, there's no error. And i used all those "& . &" to make a dotted notation to the variable's name, so i can do this sorta thing: set -u0 %temp.nick&pass $read -w [ $+ [ *=%npass.oper. [ $+ [ %net ] $+ . $+ [ %server ] $+ ] .* ] ] $mircdir/remotes/ctcp.ini which is mirc's way of setting a local var, doing a file read with pattern matching of a var i make the name of on-the-fly. Makes it so easy to do this too: -- in the on:join event idme set %did.id. [ $+ [ %net ] $+ . $+ [ # ] $+ . $+ [ $me ] ] did which makes a var like: %did.id.dalnet.#test.kat did -- in the on:part event unset %did.id. [ $+ [ %net ] $+ . $+ [ # ] $+ .* ] which unsets all the ident'ing i did in that channel for any nick i used while there. --in the on:quit, on:disconnect, on:start events -- or in one alias called by them unset %did.id.* and all the vars signifying that i did id for any network, room, nick, and channel are cleared in one decidedly non-Euphoric swoop. Can't do those things natively in Euphoria. Which is also why strtok got written, because i can do this in mirc: if ( *!* at user-?*?*.dialup.mindspring.com iswm %1 ) { if ( $2 == 3 ) { return *!* $+ $right($remove($gettok($gettok(%1,1,64),2,42),~),9) $+ @user-* $+ $gettok($gettok($gettok(%1,1,46),2,64),2,63) $+ *.dialup.mindspring.com } } But associated lists help a *lot*, because you can do -- pseudocode! proc setvar(object whatvar,object data) -- see jiri's/derek's code for how to do this end proc func getvar(object whatvar) -- see derek's/jiri's code on how... return data else return 0 end func setvar({"blarg."&chan&".bloo"},textline) if match(getvar("what."&chan&".bloo"),data[1]) then -- falls thru, no errors, if var doesn't exist -- normal eu code end if Now if i could get a: goto "what."&chan&".bloo" or goto gettok(data[1],32) or goto %var like mirc has!! Kat wishing terribly that Euphoria was more advanced