[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Execute without echo
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Execute without echo

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Shadox   (2 posts)  [Biography] bio
Date Sun 13 Sep 2009 05:25 PM (UTC)
Message
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.
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Reply #1 on Sun 13 Sep 2009 11:20 PM (UTC)

Amended on Sun 13 Sep 2009 11:44 PM (UTC) by Blainer

Message
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.

[Go to top] top

Posted by Shadox   (2 posts)  [Biography] bio
Date Reply #2 on Mon 14 Sep 2009 01:51 AM (UTC)
Message
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).
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Reply #3 on Mon 14 Sep 2009 02:13 AM (UTC)

Amended on Mon 14 Sep 2009 02:15 AM (UTC) by Blainer

Message
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)
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Mon 14 Sep 2009 10:19 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #5 on Mon 04 Apr 2016 03:09 PM (UTC)
Message
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)

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Mon 04 Apr 2016 08:18 PM (UTC)
Message
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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


5,919 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]