Register forum user name Search FAQ

Gammon Forum

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 ➜ Suggestions ➜ History Log

History Log

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


Posted by WillFa   USA  (525 posts)  Bio
Date Sun 01 Feb 2009 08:31 AM (UTC)
Message
I'm one of these people that doesn't reboot for months, has 32 windows open, and never closes mushclient.

On the rare occasion that I do need to reboot, I'm always peeved that my command history's gone.

What I'd love is if the scripting interface included:

CommandHistoryAdd/CommandHistoryLoad
CommandHistorySave/CommandHistoryExport

So in my OnWorldClose function I could export it to a text file, and re-read it OnWorldOpen.

Thanks Nick.

Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 01 Feb 2009 06:55 PM (UTC)
Message
Months, eh? MUSHclient must be pretty reliable then. :)

For getting the command history:

http://www.gammon.com.au/scripts/doc.php?function=GetCommandList

For putting it back (per command):

http://www.gammon.com.au/scripts/doc.php?function=SetCommand

then:

http://www.gammon.com.au/scripts/doc.php?function=PushCommand



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #2 on Sun 01 Feb 2009 11:28 PM (UTC)

Amended on Sun 01 Feb 2009 11:44 PM (UTC) by WillFa

Message
Thanks Nick.

If anyone else is looking for similar, here's the code.


function OnWorldOpen()
	local tmp = GetInfo(54):sub(1,-4) .. "cmds"
	f = io.open(tmp)
	repeat
		local line = f:read()
		if line then
			SetCommand(line)
			PushCommand()
		end
	until not line
	f:close()
end

function OnWorldClose()
	local tmp = {}
	f = io.open(GetInfo(54):sub(1,-4) .. "cmds", "w")
	for _,cmd in ipairs(GetCommandList(GetCurrentValue("history_lines"))) do
		if not tmp[cmd] then
			f:write(cmd .. string.char(13) .. string.char(10))
		end
		tmp[cmd] = true
	end
	f:close()
end


OnWorldClose removes duplicates from the history. The commands are saved to a .cmds file in the same directory as the world file.
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.


12,135 views.

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

Go to topic:           Search the forum


[Go to top] top

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