Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Bug reports
➜ setcommand problem...
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
Date
| Wed 30 Apr 2003 09:40 PM (UTC) Amended on Wed 30 Apr 2003 09:42 PM (UTC) by Shadowfyr
|
Message
| This doesn't seem to work. Is it a bug or am I missing something:
Macro Shift-F10 = ToggleMode
<aliases>
<alias
match="^ToggleMode$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>mstemp = getvariable("TempCmd")
setvariable "TempCmd", getcommand
setcommand mstemp
note mstemp
note getvariable("TempCmd")</send>
</alias>
</aliases>
The note lines show that the variables get switched properly, but the contents of the actual input box never changes... :( | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #1 on Wed 30 Apr 2003 11:42 PM (UTC) |
Message
| See the documentation for SetCommand - it will not change the command window if there is something in it. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #2 on Thu 01 May 2003 02:11 AM (UTC) |
Message
| I use the following routine to set commands:
Sub SetCommandLine (CommandString)
World.PushCommand
World.SetCommand CommandString
World.SelectCommand
End Sub
If my script sets a command unexpectedly, I can simply press delete and up arrow to recover what was previously on the command line. I highlight the new command as well, so that if I choose not to use it, I can just start typing a new command or press delete to clear the command box. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
Date
| Reply #3 on Thu 01 May 2003 02:20 AM (UTC) |
Message
| So... I would need:
<aliases>
<alias
match="^ToggleMode$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>mstemp = getvariable("TempCmd")
setvariable "TempCmd", getcommand
docommand "KeysEscape"
setcommand mstemp
</alias>
</aliases>
I assume that would work? docommand "Cut" would work too, but has the occationally unwanted side effect of destroying the clipboard contents. | Top |
|
Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
Date
| Reply #4 on Thu 01 May 2003 06:45 PM (UTC) |
Message
| Ok.. Now this is a bug..
DoCommand "KeysEscape" will clear the contents of the input window, but does not clear whatever internal flag that SetCommand uses to determine if the input box is empty. The result is that my new version won't work either. :p | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #5 on Thu 01 May 2003 10:06 PM (UTC) |
Message
| It is not a bug *wipes brow*.
The release notes for a recent version clarified that DoCommand *queues* the command, otherwise things like DoCommand "close" crash the client because the window has been closed but the script is still trying to execute.
Thus, your example queues up a "KeysEscape" command to be executed *after* the script completes.
I have modified the description for the function DoCommand to make this much clearer.
I suggest you use Magnum's approach to empty the command window, that should work. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
Date
| Reply #6 on Thu 01 May 2003 11:30 PM (UTC) Amended on Thu 01 May 2003 11:33 PM (UTC) by Shadowfyr
|
Message
| Hmm. Actually I didn't really look at Magnum's. It would sort of work for the test case I was trying, but for the more complex issue I was looking at, it wouldn't quite cut it.
The original idea was to 'fake' the trick KMud has. Instead of using two seperate input windows, which can also have seperate command histories, the idea would have been to do:
a = GetCommand
ClearCommand '<--- It all hangs in not having this...
b = GetVariable ("LastCmd")
SetCommand a
SetVariable "LastCmd", b
c = split(GetVariable "CMDList",",")
d = GetCommandList
DeleteCommandHistory
for each e in c
PushCommand e
next
SetVariable "CMDList", join(d,",")
if GetVariable ("Mode") = "1" then
SetVariable "Mode", 2
SetAlphaOption "input_background_colour","#400000"
else
SetVariable "Mode", 1
SetAlphaOption "input_background_colour","#000000"
end if
Other commands, such as activating an editor or the like could be included in the mode change as well and you could have theoretically as many 'input windows' as you could manage bofore they started slowing down the client.
I suppose I could generate a temporary timer to make the substitution, but it isn't exactly what would have been the obvious solution. ;) lol | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #7 on Fri 02 May 2003 04:09 AM (UTC) |
Message
| This seems to almost work for me. I say "almost" because I think it reverses the order of the saved commands, because GetCommandList gets them in starting at the most recent, but you need to push the with the oldest first. However with a bit of tweaking you should get it to work ...
'
' get existing commands
'
cmdlist = GetCommandList (0)
'
' delete them
'
DeleteCommandHistory
'
' get earlier commands
'
oldList = Split (GetVariable ("Saved_Commands"), vbTab)
'
' save current ones for later
'
if VarType (cmdList) = (vbVariant + vbArray) then
SetVariable "Saved_Commands", Join (cmdlist, vbTab)
else
SetVariable "Saved_Commands", ""
end if
'
' put old commands back
'
for each c in oldList
PushCommand
SetCommand c
next
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
Date
| Reply #8 on Fri 02 May 2003 06:11 PM (UTC) |
Message
| Umm. Wait. Are you saying that the GetCommandList also reads what is 'currently' in the command window and that DeleteCommandHistory will nuke that too? If not, then you haven't actually fixed anything with the redesign, though knowing that the sequence of commands returned are reversed is useful. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #9 on Fri 02 May 2003 09:12 PM (UTC) |
Message
| No, you spotted another flaw in it.
You want an initial PushCommand, which will add the current command window contents to the list, and delete it, which is surely what you want to do anyway. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #10 on Fri 02 May 2003 09:13 PM (UTC) |
Message
| However I think my idea of using tabs as the command separator is much more sensible than commas, after all, commands are likely to have commas in them. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
Date
| Reply #11 on Fri 02 May 2003 11:58 PM (UTC) Amended on Sat 03 May 2003 12:05 AM (UTC) by Shadowfyr
|
Message
| Hmm. Yeah. Didn't think of that factor.. popping the last command off to set the line would work. As for using TAB as a seperator... I hadn't considered that, but since it is at least possible that a tab could exist in something copied into the command box, if not entered directly, I would consider using something less likely. One of the characters under 32 or even a pair of characters, like ^`, which are unlikely to occure in anything you copy, let alone type. Split and Join don't care what or how many letters you use, just that they are unique enough to function as a seperator. ;)
Like so:
PushCommand
c = split(GetVariable "CMDList",",,")
d = GetCommandList
DeleteCommandHistory
dim e
for e = ubound(c) - 1 to 0 step -1
PushCommand c(e)
next
SetCommand c(unbound(c))
SetVariable "CMDList", join(d,",,")
if GetVariable ("Mode") = "1" then
SetVariable "Mode", 2
SetAlphaOption "input_background_colour","#400000"
else
SetVariable "Mode", 1
SetAlphaOption "input_background_colour","#000000"
end if
Using yours I would get a duplicate of the 'current' command, which wouldn't necessarilly hurt anything, but isn't needed and as you said, it also reversed the order. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #12 on Sat 03 May 2003 01:52 AM (UTC) |
Message
| Why not be safe and use something like CHR(1)?
Two consecutive commas are not particularly unlikely, especially if have been entering script commands. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Meerclar
USA (733 posts) Bio
|
Date
| Reply #13 on Sat 03 May 2003 10:10 AM (UTC) |
Message
| You also run into the problem of muds with unusual colour escape chars, DoT's ` for instance. Or \ for internal speedwalk support. There are also codebases that use { and @@ for colour escape chars so what might be an 'obvious' delimiter choice for a particular codebase may be totally unusable on several others. Nick's last suggestion is actually pretty good and *should* be universally safe. |
Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org | Top |
|
Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
Date
| Reply #14 on Sat 03 May 2003 06:20 PM (UTC) |
Message
| Hmm. True. Probably a good idea to use char(1).
Also. I think I goofed again though. It should be
for e = ubound(c) to 1 step -1
and
SetCommand c(0)
Otherwise, since you say the sequence is reversed, I would have been 'setting' it to the wrong command. :p | 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.
34,019 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top