Execute without echo

Posted by Shadox on Sun 13 Sep 2009 05:25 PM — 7 posts, 35,491 views.

#0
Is there any way to send an Execute style command, meaning one that will be evaluated against aliases, without it local echoing? I can find no way to do it.
#1
I have echo off for all my commands.
Game -> Configure -> Commands menu has an Echo My Input Option. This will toggle echoing all your commands.
Help for the Commands dialog is here.
http://mushclient.com/scripts/doc.php?dialog=IDD_PREFS_P9

The is an option on the alias or trigger dialog to Omit from Command history.

To send one command without echoing it use this function.
Template:function=SendNoEcho
SendNoEcho

The documentation for the SendNoEcho script function is available online. It is also in the MUSHclient help file.

Amended on Sun 13 Sep 2009 11:44 PM by Blainer
#2
That doesn't address my issue.

I'm scripting, and at present just setting EchoInput to False, sending all of my commands, and then changing it back to true.

The issue is sending commands (in a script) with execute level processing but having them not echo (primarily those commands that turn out to not get processed as aliases, as an alias can already be set to not echo).
#3
Sorry I didn't understand your post. As a work around until an expert can answer this worked for me.
 SetOption ("display_my_input", 0)
 Execute ("look")
 SetOption ("display_my_input", 1)
Amended on Mon 14 Sep 2009 02:15 AM by Blainer
Australia Forum Administrator #4
I am inclined to agree with Blainer. Make your own execute function like this:


function ExecuteNoEcho (whatever)
  SetOption ("display_my_input", 0)
  Execute (whatever)
  SetOption ("display_my_input", 1)
end -- function


Then in your script call ExecuteNoEcho instead of Execute. Anything that execute does, that would have echoed your input, won't.

Or, if you have lots of scripts with Execute in them and don't want to rename Execute as ExecuteNoEcho, you could do this in your script file:


function fixup_execute ()
   local Execute = Execute
   return function (whatever)
      SetOption ("display_my_input", 0)
      Execute (whatever)
      SetOption ("display_my_input", 1)
    end
end -- function

Execute = fixup_execute ()


That replaces the Execute function with one that saves a copy of the original, changes the option, executes the original Execute, and puts the option back.
USA Global Moderator #5
The previous replies in this thread are bad. Safer code would be

local original_echo_setting = GetOption("display_my_input")
SetOption ("display_my_input", 0)
Execute (whatever)
SetOption ("display_my_input", original_echo_setting)
Australia Forum Administrator #6
My code was bad in the sense it assumed echo was already on. Fiendish has a point that if it is already off, my suggestion would turn it on. So an improved function would be:


function ExecuteNoEcho (whatever)
  local original_echo_setting = GetOption("display_my_input")
  SetOption ("display_my_input", 0)
  Execute (whatever)
  SetOption ("display_my_input", original_echo_setting)
end -- function