Re: question that might not have an answer
On Sat, 10 Jan 2004 09:15:20 -0500, Michelle Rogers
<michellerogers at bellsouth.net> wrote:
>I would like for mud-"coders" to be able to add commands "on the fly" from
>inside the mud.
If you want to make it easier to add Euphoria code snippets, provide
an include file expressly for this purpose. Following is a cut down
copy of userfunc.exw used both in my print preview and report
generator (which is part shrouded), and also in Expression Evaluator
(which is full source):
--- code starts ---
--
-- Examples of user/application functions that can be used in
-- calculated fields.
-- Just add a function and update the table at the end.
--
include wildcard.e -- upper()/lower()
function Capital(object charstring)
if not sequence(charstring) then return ("Capital() error") end if
if length(charstring)>1 then
charstring=lower(charstring)
charstring[1]=upper(charstring[1])
end if
return charstring
end function
function ufvrid(sequence name)
integer r
r=routine_id(name)
if r=-1 then ?9/0 end if
return r
end function
if initialise_pprg(0,{},{},{
"Capital","(x) %s -- first character upper case, rest
lower",ufvrid("Capital")}) then end if
-- code ends --
NOTES:
1) obviously ignore 0,{},{} passed to initialise_pprg(); they are used
elsewhere. The main thing is "name","desc",routine_id.
2) ufvrid() illustrates another trick you may need: 'wrapping'
routine_id to ensure it is physically located in the source at the
right place. Otherwise you get -1's returned.
3) naturally, if userfunc.exw is modified, the application must be
restarted before any changes take effect.
> I can handle the actual adding of the command easy
>enough...on one line, they would simply type:
>
>addcommand <command> <function> <levelreq>
As you may have guessed, this is what initialise_pprg does. It just
appends the values passed to three existing tables. The functions can
then later be invoked by name.
Download Expression Evaluator from my page if you want to see the
above in action. However what I suspect you should really be doing is
allowing your mud-"coders" to invoke an existing routine, with
different parameters.
Regards,
Pete
http://palacebuilders.pwp.blueyonder.co.uk/euphoria.html
|
Not Categorized, Please Help
|
|