error using save("");

Posted by KatAngel on Tue 24 Feb 2009 11:31 PM — 21 posts, 87,361 views.

#0
I have a timer set to save my world file every five minutes. When it fires, I SOMETIMES get an error, and I sometimes don't. The error shows up... maybe one in 10 fires on average. Here's the error:

Script error
World: KoD
Execution of line 1 column 1
Immediate execution
Internal application error.

The trigger is just:

world.Save("");

Even when it does fire without an error message, when I close it, it still says that world internal variables have changed and asks if I want to save the file. It does this even if I manually trigger world.Save("") while disconnected, and then close immediately after.

Am I doing something wrong here?

Using MUSHClient version 4.37
Australia Forum Administrator #1
Hmm. Strange. No, I don't think you are doing anything wrong. I Googled for:


jscript "Internal application error."


A few sites seemed to advise re-registering the jscript.dll file as follows:

  • Click Start, and then click Run.
  • In the Open box, type regsvr32 jscript.dll, and then click OK.


You should get the same result by simply clicking on the "Register DLL" button in the scripting configuration dialog.

Let us know if this doesn't fix the problem.
#2
That didn't fix it.
Australia Forum Administrator #3
On this page is a plugin that reports your jscript version (JScript_Version):

http://www.gammon.com.au/plugins/

Can you please run that and advise what version you have?

Actually, I think it is part of the MUSHclient distribution, it should already be in the plugins directory.
Amended on Wed 25 Feb 2009 01:00 AM by Nick Gammon
Australia Forum Administrator #4
I got:


Script engine = JScript
Version = 5.7
Build  = 16599


Australia Forum Administrator #5
Also can you please show the timer:

http://mushclient.com/copying
#6
Script engine = JScript
Version = 5.7
Build = 18066

<timers>
<timer enabled="y" minute="5" second="0.00" offset_second="0.00" send_to="12"
active_closed="y" >
<send>world.Save("");</send>

</timer>
</timers>

It gives the same error if I put it directly into the command window using the script prefix. (i.e., "/world.Save("");")
Australia Forum Administrator #7
Well can you try this instead?

This does the same thing, but in a plugin with Lua as the script language. Maybe there is something funny about jscript.

Save between the lines to disk as Auto_Save.xml, and then use File menu -> Plugins to install that as a plugin. You will get a confirmation message about whether or not it thinks it saved OK. You might want to check on disk that the date/time of the world file has been updated.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, February 25, 2009, 5:51 PM -->
<!-- MuClient version 4.40 -->

<!-- Plugin "Auto_Save" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Auto_Save"
   author="Nick Gammon"
   id="3ea0bfc4db127153568ff673"
   language="Lua"
   purpose="Saves the world file periodically"
   date_written="2009-02-25 17:50:10"
   requires="4.00"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Saves the world file periodically.
Default is every 5 minutes.
]]>
</description>

</plugin>


<!--  Timers  -->

<timers>
  <timer 
    enabled="y" 
    minute="5" 
    send_to="12"
>
  <send>

if GetInfo (111) then  -- world file changed?
  if Save () == false then
    ColourNote ("green", "", "World file saved.")
  else
    ColourNote ("white", "red", "Couldn't save world file.")
  end -- if
end -- if world file changed

</send>

  </timer>
</timers>

</muclient>
Amended on Wed 25 Feb 2009 11:01 PM by Nick Gammon
#8
It gives me "Couldn't save world file." every single time, and after about 5 times, it gives me an alert that says "an unnamed file was not found." The plugin then stops functioning at all. If I try to reinstall it, MUSHclient crashes.

The last modified date on the file changes even though it says it couldn't save, but after the crash, any changes I made don't show up once I open it back up again. So it changed the date, but didn't actually save.
Amended on Wed 25 Feb 2009 03:36 PM by KatAngel
Australia Forum Administrator #9
Hmmm, we have a larger problem here than the version of jscript.

There must be something about your environment - if people in general couldn't save thousands of players would be screaming.

Let's narrow it down some more ...

  • What operating system are you using? (Visa, XP, WIndows 98, Ubuntu, etc.)
  • If under Vista are you running with Administrator privileges?
  • Can you tell me the name of the world file? I assume you have named it already (on disk) as you said you checked the date/time of it. Perhaps special characters in the file name are responsible.
  • In particular, are any of the characters: "<>"|?:#%;/\" in the file name?
  • What directory are you saving it to?
  • Do you have write permission to that directory?
  • Can you reliably save it using File menu -> Save? (and if so, do changes get saved?)
  • What is your "current directory" when doing a save? To find this out execute this script command:

    
    Note (GetInfo (64))
    

  • Do you have any plugins installed? If so, does the problem go away if you disable all of them?
  • Do you have a script function name entered on the World Events -> Save box in the scripting configuration?


#10
  • Using Windows XP Professional
  • World file is named KoD, another one named KoD2. Both have the same timer and experience the same problem.
  • One is saved to C:\Program Files\MUSHclient, the other to C:\Program Files\MUSHclient\worlds
  • I have write permissions to all directories.
  • I can reliably save with File->Save, and all changes get saved.
  • Current directory is "C:\Program Files\MUSHclient\"
  • I do not have any plugins installed.
  • I do not have anything written in the World Events -> Save box in the scripting configuration
Australia Forum Administrator #11
It looks like I confused myself by having a very obscure return code from Save.

Also, the documentation was wrong. :(

Anyway, I have amended the plugin above - it should be checking for false, that representing a good save. I also added a check that it didn't save if it didn't have to, to save your screen filling up with "World file saved." messages when you don't change anything.

Can you try the amended plugin please, and report back your results?
#12
Seems to be working so far. I'll let you know if it ever throws an error.
#13
I got the "an unnamed file was not found" error again just a moment ago.
Australia Forum Administrator #14
That plugin does not have a provision for displaying the exact error. It either says "World file saved." or "Couldn't save world file.".

Do you perhaps have the timer still running?

Where does the error message "an unnamed file was not found" appear? Does a dialog box pop up with it in it?

A Google search for "an unnamed file was not found" seems to indicate that, under some situations, this error may occur. They refer to the MFC libraries, which is what MUSHclient is built using. So far I haven't seen a resolution.

There appears to be a suggestion that, for some users, they can save once, but not more than once. Also it suggests that the problem occurs because MFC saves the file under a temporary name, and then cannot rename it.

I will continue to investigate.
Australia Forum Administrator #15
Also see this:

http://www.gammon.com.au/forum/?id=8855

http://www.gammon.com.au/forum/?id=4964

Quote:

World file is named KoD, another one named KoD2. Both have the same timer and experience the same problem.


So it is actually KoD.mcl on disk?
Australia Forum Administrator #16
Also can you see if you can find a file named something like MFCxx.tmp in your MUSHclient directory tree? And if so, does it have inside it what looks like your world file?

Another thing to look into is, does MUSHclient have write access to whatever directory that file is in?

And possibly, if you have been saving every 5 minutes for a few weeks, maybe you have thousands of these files and it can't fit any more there. Maybe.
Australia Forum Administrator #17
Here is another thing to try. Edit the plugin, and replace:


if GetInfo (111) then  -- world file changed?
  if Save () == false then
    ColourNote ("green", "", "World file saved.")
  else
    ColourNote ("white", "red", "Couldn't save world file.")
  end -- if
end -- if world file changed


By:


if GetInfo (111) then  -- world file changed?
  DoCommand ("save")
end -- if world file changed


This saves in a different way - effectively being as if you clicked on File -> Save.

Since that is done a different way, maybe it will work better. Since there is no error return, you would need to check that the file actually saves, by looking at the date/time stamp.
#18
Ok... let me try to answer all these questions. Hopefully I don't miss any.

Yes, it pops up as a dialogue box. When I click ok, all timers fail to work until I reset them.

Yes, it is KoD.mcl on the disk. (By that token, no, it doesn't have a dash in it.)

There are 747 MFCxxxx.tmp files in the MUSHclient/worlds directory! I'll delete them, but I don't think it's a problem with anything as far as write permissions, capacity, etc. go, because it DOES save successfully 95% of the time. I'm going to go the DoCommand route, because I've never had a problem saving from the file menu before. If I'd known about that function, I'd have just tried that before I posted anything; somehow, I overlooked it.

Also, I've noticed that GetInfo(111) doesn't reflect changes to world-internal variables. Is there any way to detect changes in those?
#19
I'll also mention that, when using the save(""); function, both in JScript and in the LUA plugin you gave me, if MUSHclient crashed (which, my computer crashed a little bit ago, hense the reason for the autosave in the first place :P) any changes I've made still aren't reflected. The modified date changes, but it doesn't actually save anything new, it just seems to rewrite the world file with the exact same data.

I should clarify, it seems to save changes to triggers, timers, etc., but this is like the fourth time I've changed one of the custom colors.
Amended on Thu 26 Feb 2009 03:53 AM by KatAngel
Australia Forum Administrator #20
Quote:

Also, I've noticed that GetInfo(111) doesn't reflect changes to world-internal variables. Is there any way to detect changes in those?


It seemed to work for me. Er, well it worked if I changed the variable in the GUI. It seems that SetVariable doesn't set that flag. I have added a new GetInfo (118) in version 4.41 that would let you query that.

Meanwhile, you could make your own SetVariable function that sets the variable, and also sets a flag you can check.

As for the absence of changes, that seems to support the idea mentioned on some other web sites, that it actually writes a temporary file, and then fails to rename it. Thus, something got written, just not to the actual world file. Deleting those temporary files may help, at least in the short term.