# Alternatives to the MUF Program Editor

strict warning: Only variables should be passed by reference in /home/umuck/www/modules/book/book.module on line 559.

The MUF Program Editor is guaranteed to be available on any TinyMUCK and regardless of what client you use to connect. However, it doesn't match the flexibility and ease-of-use that modern text editors provide.

Most MUD clients have a feature that makes it possible for us to use our favorite text editor instead of the MUF program editor.
IMPORTANT NOTE: A word-processor, such as Microsoft Word, Wordperfect, or Open Office's Writer, is NOT a text editor. If you use a word processor to edit your programs, bad things WILL happen. If you are not familiar with any text editors you like, I'll be including a list and where you can obtain them.

First, I'll explain how this works in general and then I'll cover how to do it with specific clients. Pretend that you have typed up the "Hello World!" program in your favorite text editor and saved it as "HelloWorld.muf" where-ever you store your files on your computer.

That's when the magic starts. You tell your mud client "send this text file to the Muck" the client sends the entire text of the file to the muck as if you were typing whatever was in the file. Pay special attention to that last bit. It's very important: Everything in the text file will be sent to the Muck as if you typed it.

That includes commands. You could, in theory, do all sorts of useful things with this, but I'm only going to cover how it helps us write MUF programs. Consider our old friend, the HelloWorld program:

: main
  "me" match "Hello World!" ansi_notify
;

We could type that up in a text editor. Then connect to the Muck and type the command to create a program, @prog HelloWorld, type insert to go into insert mode. Then tell our mud client to send the file to the muck. Then finish up by entering a period by itself on a line, typing compile and quit and I'd be done.

But wait. If the text file is sent to the muck as if I was sitting at the keyboard typing it, what if I typed the following into my text editor?

@prog HelloWorld
insert
: main
  "me" match "Hello World!" ansi_notify
;
.
compile
quit

Now, when I sent the file to the Muck, not only is the entirety of the program sent, but also the commands required to create, insert, compile, and quit are all sent automatically1.

However, there are some pitfalls you should be aware of when using this technique.

If you are editing a program that is already in place you need to change the text file so that it replaces the program text as part of the operation. To do this you have to use the delete command to delete the entire program so that the new program text replaces the old. Thus, your text file has to look something like this:

@prog HelloWorld
1 10000 delete
insert
: main
  "me" match "Hello World!" ansi_notify
;
.
compile
quit

The 1 10000 delete effectively deletes the entire program (so far I've not seen a program that long--yet.), then we do our insert and the rest of the steps as normal.

I have another pitfall to point out though. If you're not careful with this technique you can end up with multiple copies of the program. It will happen if you the program's database item is not in your inventory or the room when you send the file to the Muck. The muck looks locally for the program when you send/type the @prog2 command. If it finds a matching program, it assumes you want to edit it--but if it doesn't it creates a new one.

What I recommend strongly instead is that you use @register to assign the program register name. For personal programs, you should use @register #me <program's database reference>=<some name you can remember>. For programs to be use by other programmers, wizards, or mortals you may want to register the program in the global registry. You will need to consult with the staff on your muck about how and where it should be registered. Let's assume for a moment that you've registered the HelloWorld program as programs/HelloWorld. Then you would change your text file to look like this:

@teleport $programs/HelloWorld=me @prog HelloWorld 1 10000 delete insert : main  "me" match "Hello World!" ansi_notify ; . compile quit All this extra effort may not seem worthwhile right now. But when your programs get longer and you have to make many edits to improve them--that's where the extra effort becomes worth while. You can also do things like make yourself templates for new programs so that you don't have type all of that more than maybe a couple of times. Before you go, I'd like to show you one more variation on the text file...this time with little messages to yourself so you know when the text file starts going to the muck and when it finishes--something that pays off for slow connections and large programs. whisper me=Beginning upload of Hello World... @teleport$programs/HelloWorld=me
@prog HelloWorld
1 10000 delete
insert
: main
  "me" match "Hello World!" ansi_notify
;
.
compile
quit
whisper me=Upload Complete

In the next few sections, I'll explain how to do the "send the file to the muck" part for specific clients. Feel free to read them all, but you only need to read the one for your favorite.

• 1. If you're thinking "Wait! Does this mean we are actually still using the MUF program editor? You're right. We're using the muck client to send the commands automatically to the MUF program editor.
• 2. If you're thinking to yourself that you could solve this using @edit--trust me when I say that creates a whole another problem that is quite a bit uglier.

## Post new comment

• Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3> <h4> <h5> <h6> <blockquote> <iframe>
• Lines and paragraphs break automatically.
• Use [fn]...[/fn] (or <fn>...</fn>) to insert automatically numbered footnotes.
• Use [# ...] to insert automatically numbered footnotes. Textile variant.
• You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <glow>, <muf>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].