nodpc / jn-npp-plugin

Automatically exported from code.google.com/p/jn-npp-plugin
0 stars 0 forks source link

Microsoft JScript runtime error #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. install jN.zip to npp dir
2. run npp

What is the expected output? What do you see instead?
npp alert:
"Syntax error
 line: 1, pos: 1
"

What version of the product are you using? On what operating system?
npp version v5.9.8
jN version 1.0.34
win xp sp3 x86

I try to debug the "start.js" file at "/nppdir/plugins/jN/",
it seems the code "addScript(scr);" will occur this problem.
cause some js code like "(function(){...})()", it looks the plugin not support 
the syntax

Original issue reported on code.google.com by Aluc...@gmail.com on 24 Sep 2013 at 6:11

GoogleCodeExporter commented 9 years ago
Did you built jN.dll from newest sources? If yes get the newest sources jN 
directory. I changed addScript method adding new parameter (path to file to be 
added). It allows to debug scripts in VS or MS Script Debugger and see loaded 
files.

Original comment by eugen.kr...@gmail.com on 24 Sep 2013 at 9:30

GoogleCodeExporter commented 9 years ago
Can you provide script file causing that issue?

Original comment by eugen.kr...@gmail.com on 24 Sep 2013 at 7:25

GoogleCodeExporter commented 9 years ago
Maybe i find the problem, it's the file encoding.

I compare the script files, the files that causing the issue are UTF-8 
encoding, and i transform them to ANSI as UTF-8(UTF-8 without BOM), then no 
errors there.

files: path: nppdir\plugins\jN\includes\
clearcase.js
run.js
svn.js
tests.menu.js
Zen Coding.js

I remember that i had got the same issue before in IE6, does the plugin's 
JScript engine is the same as the IE6's?

Original comment by Aluc...@gmail.com on 25 Sep 2013 at 2:24

GoogleCodeExporter commented 9 years ago
The plugin uses actually installed MS Script Engine specially JScript 
implementation. It should be the same that IE is using. What IE version do you 
have?

What do you see, if you run following script in Npp (Ctrl+N, paste following 
script, F5)

function GetScriptEngineInfo(){
   var s;
   s = ""; // Build string with necessary info.
   s += ScriptEngine() + " Version ";
   s += ScriptEngineMajorVersion() + ".";
   s += ScriptEngineMinorVersion() + ".";
   s += ScriptEngineBuildVersion();
   return(s);
}

alert(GetScriptEngineInfo());

I see "JScript Version 5.8.17866"

Original comment by eugen.kr...@gmail.com on 25 Sep 2013 at 7:02

GoogleCodeExporter commented 9 years ago
JScript Version 5.7.22589

Original comment by Aluc...@gmail.com on 25 Sep 2013 at 10:30

GoogleCodeExporter commented 9 years ago
IE6

Original comment by Aluc...@gmail.com on 25 Sep 2013 at 10:45

GoogleCodeExporter commented 9 years ago
Strange! I began jN development on windows XP and it worked with old IE 
version. I would close this issue, because you found a workaround.
If you can reproduce this issue you can try to replace include method in 
start.js by following test it again.

    include : function (file){
        if (this.fso.FileExists(file)){
            var stream = new ActiveXObject("ADODB.Stream");

            stream.Charset = "UTF-8";
            stream.Open();
            stream.LoadFromFile(file);

            var scr = stream.ReadText();
            stream.close();

            try{
                addScript(scr);
            }catch(e){
                this.errors.push(e);
            }
        }
    },  

Original comment by eugen.kr...@gmail.com on 26 Sep 2013 at 6:08

GoogleCodeExporter commented 9 years ago
I replace the method and i cannot reproduce this issue again.

But, another issue happened.

I created a script file with encoding GB2312, and i wrote some GB2312 
characters like "你好", run this code snippet:

Editor.alert("你好");

actually the Editor alert the white space.

When i close npp, open it after a while, i saw that text trasform to encoding 
UTF-8.
I try some other similer case, for example, first i use encoding UTF-8 with out 
BOM, then do the same things, and the file transform to ANSI encoding finally.

Original comment by Aluc...@gmail.com on 26 Sep 2013 at 7:09

GoogleCodeExporter commented 9 years ago
Very strange! But does not have anything with jN-plugin. Plugin tries 
explicitly to load all of scripts as UTF-8 encoded. I chose this encoding 
because it is a natural encoding for Npp. But I get a BOM problem :-).

Original comment by eugen.kr...@gmail.com on 26 Sep 2013 at 8:44

GoogleCodeExporter commented 9 years ago

Original comment by eugen.kr...@gmail.com on 2 Oct 2013 at 8:09