Re: Boards. Patrick J. Dughi on Fri, Nov 07, 1997 at 04:36:21AM -0600

From: Eric Green (thrytis@IMAXX.NET)
Date: 11/08/97

On Fri, Nov 07, 1997 at 04:36:21AM -0600, Patrick J. Dughi wrote:
>         I was just going to re-write some board procs, and I was curious
> if anyone could think of a better way (read that, more elegant) than using
> BOARD_MAGIC in the string_add function?
>         To those of you who may be confuseled, BOARD_MAGIC is an
> arbitrairy number which is used in the following way:
>         When posting on a board, you must save the board number (remember
> which board you're writing to).  Now, since we don't have any special way
> to specifically do this, we use the long int "to_mail".  However, we have
> to differentiate mail and boards, so we add BOARD_MAGIC + the board
> number, and do a check to see if any to_mail is greater than
> BOARD_MAGIC. If so, its a board, if not, its mail.
>         As long as "to_mail" is never set normally (ie, by mail) to more
> than BOARD_MAGIC , we'll never have a problem. This works fine, but
> shouldn't there be a less "hackish" way of doing it?

Start with rewriting the editor function.  Instead having a large
string_add function, break it up into three:

  string_edit:    Starts the editing by setting up structures and
                  variables needed.
  string_add:     Add user input to the current string.
  string_finish:  Call the finish function (see below) and clean up
                  structs and flags.

For string_edit, you give it the parameters:
  descriptor data: who is editing
  max string size: how long to we continue to add
  finish function: a function to call when you're done editing.
  data: Info about the string needed by the funish function

    start string: A existing string to be appended to or modified

This function saves the information to the descriptor, sets needed flags,
and starts a new string (copying existing string if append/modify mode).
You never edit on the destination string, since it can result in problems
with multiple people editing, and the target string disappearing.  It also
allows for aborting all modifications to the string after editing has

String_add simply adds the user's input to the current string.  This is
called from comm.c, same as the existing string_add.  If you have different
editors (such as full screen editor), you call the approriate string_add.

String_finish calls the finish function (see below), deletes the string
you've been editing, frees the structures, clears flags, etc.  It is
called from the string_add function when an '@' is found by itself on
a line (for the case of the standard editor).

The finish function does the work.  Each type of editing (such as description
editing, note editing, olc editing, board editing) requires a finish
function.  It is responsible for taking the resulting string and moving
it to where it belongs.  For example, the board finish function is passed
the board number and subject (from the data passed to the string_edit
function).  Using this, it builds the message and tacks it on the end of
the board.  This way, multiple people can write on the board at the same

There is no need for board magic or like because the finishing function
defines exactly what type of editing you are doing.

DGC ( uses this method if you want a code
example.  It also works well using C++ and objects.


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/08/00 PST