Redirecting Output from Commands

Posted by Hammerstein on Wed 12 May 2004 03:07 AM — 3 posts, 15,442 views.

#0
I suspect there might be a way to do this, but I'm not sure, so I thought I'd post it here. I was thinking that it would be great if MUSHclient supported a method of, upon the entry of a certain command, displaying the output from that command in a separate window that could be moved around the screen. That would be helpful for certain info commands that are best left always available.

Thank you for your time and effort.
Russia #1
One way to do this would be to pipe those commands through a single function that would send the command text to a notepad window. An example would be:


sub CommandLogger(comText)
     world.AppendToNotepad "Commands", comText & vbCRLF
end sub


Then you could use this function either directly from an alias via send to scripting, or from another scripting function called by an alias. But it would be easier to just have a protocol of calling scripts immediately from aliases and prepending the call to CommandLogger before any other scripts in the aliases that you want logged.
Amended on Wed 12 May 2004 03:54 AM by Ked
Australia Forum Administrator #2
I think he wants the output in a separate window, not the command.

The problem with what you want to do is there is normally a lag between entering the command and receiving the results.

For example, you might type "inventory" but get back:


Lightning crackles in the sky above!
Boris chats 'where is the shop where I can buy swords?'

You are carrying:
     a magic mushroom
     a torch
     a dragonskin
     a bag
     recall scroll
     a braided leather belt
     heavy mail leggings



In this case I have a couple of extra lines that are not really part of the inventory.

Now, if you don't mind that, then you could make an alias for (say) "inventory", that enables an trigger. This trigger would match "*" (everything), and send to "append to notepad", and also "omit from output".

That effectively moves everything that is received afterwards from the main window to the notepad (each notepad has a separate title based on the trigger name).

However your problem is stopping it. If you don't do anything else, then the entire following session will be in the notepad window and not the main window.

You need a "stopper" - in the case above a totally blank line is the end of the inventory. Another trigger could detect that and turn the first trigger off (disable it).

However in my example above there is also a blank line *before* the inventory. So, the simplest thing might be:

  1. Trigger "a" detects "You are carrying:" and enables trigger "b"
  2. Trigger "b" detects "*" (everything) and moves it to the notepad
  3. Trigger "c" detects a blank line and disables trigger "b"