MOO-cows Mailing List Archive


Re: Server Patch - chr() and asc() functions - Ian

> STR chr(NUM)
> This will return a string (length(string) = 1) that contains the 
> character represented by the code NUM.

This is generally a bad idea without proper limitations.  For example, if you
happen to do a chr(10) and stick it in a prop, your checkpoint and dump files
will end up corrupted foreverafter (or at least as long as that value stays in
the DB).

A _much_ better way to deal with making non-cooked codes available for the DB
to use actually involves no server modifications at all (I posted it here some
time ago).  The method is as follows:

1.  Create a prop on an object, and give it an easy to identify and (hopefully)
unique string value ("***!!!UniqueStringThatNobodyElseIsLikelyToUse!!!***" or
some such).
2.  Shutdown your MOO.
4.  Load the DB file into an editor which can handle long lines and control
characters (emacs, for example).
5.  Search for your unique string from step 1.
6.  Replace the line containing the string value with the control character(s)
you want to have available.
7.  Save the DB file.
8.  Restart your MOO.

The result will be that where you used to have your unique string you now have
a string containing the control character(s) you wanted, and you can then do
anything you want with it inside the DB and send it out notify()s, etc, with a
minimum of risk, much better control over what is and isn't allowed, and no
need at all for server mods.

This has the additional advantage that at least you know the particular codes
won't corrupt your DB file, since that's how they got in there in the first

> NUM asc(STR)
> This will return the code NUM of the first character in the string STR.

You don't really need this in the server, actually..  you could just have a DB
routine do an index() match on a table-string and a couple of quick

     Alex Stewart - - Richelieu @ Diversity University MOO
           "For the world is hollow, and I have touched the sky."

Follow-Ups: References:

Home | Subject Index | Thread Index