# [.net] Cant comment JScript.NET without getting compiler error

This topic is 5393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ahoi, i have another problem: I cant comment my Jscript.NET script without getting confusing errors on compilation.
import Scriptinterface;
import System;
import System.Diagnostics;

class myClass implements IScript
{
private var Host : IHost;

function Test1 ()
{
for (var i : int = 0; i < 1000; i++)
{

}
//Comment
}

function Test2 ()
{
for (var i : int = 0; i < 1000; i++)
{
}
}
function OutputMsg (text : String)
{
Console.WriteLine("1234Hallo IM Script!");
var a : int = int(System.Math.PI);
Host.OutputMsg("1234 Hallo vom Script!");
var t : Thread = new Thread(Test1);
var t2 : Thread = new Thread(Test2);
t.Start();
t2.Start();
}

function GetHost (host : IHost)
{
Host = host;
}
}

Nothing extraordinary. Notice the "//comment" in Test1(). When i compile it via VSAEngine, i get the following error (translated from German to English): Error in File!: Microsoft.JScript.JScriptException: variable 'mport Scriptin terface;' hasn't been defined. Script.JScript://script/test: Line 44 - Error: The variable 'mport Scriptinter face;' hasn't been defined. If I kill the comment, everything works just fine. Can anybody help me? Thanks in advance!

##### Share on other sites
Is Scriptinterface another module that you wrote?

Are you using // for every comment line?

##### Share on other sites
Yup, Scriptinterface is a module that i wrote. It contains the Interfaces IScript and IHost.
It doesnt matter, if i use either /* */ or // as comment tags...
I get an error all the time.

##### Share on other sites
Mind posting the specific comment?

##### Share on other sites
It's up there in the Test1() Method.
"//Comment" beyond the for-loop.

##### Share on other sites
unfortunately I cant recreate your exact problem as I don't have your classes. It would probably be best to try and strip your code down as much as possible to try and work out why its happening...

One other thing, you can actually use the inbuilt print("bla bla bla") function instead of Console.WriteLine. You then don't need to add the System Namespace into your VSA engine...

##### Share on other sites
Quote:
 Original post by MetzlerIt's up there in the Test1() Method."//Comment" beyond the for-loop.

Oh, that's stupid of me. I thought there might be more to the comment and you were using it as a placeholder.

Looking at your code, did you forget this:

package YourSolutionName;

At the top before your import lines?

##### Share on other sites
The package keyword isnt necessary as far as i know.
And it doenst work either ;)
@Mrs Kensington: If I remember correctly, it was you, who once posted his Vsa-Script-Engine on gamedev.net, right?
Do you have any problems related to this? Or is there any Engine-Option, that i have to set?

##### Share on other sites
Man metzler, your computer is really hating on you lately. BTW, do you have the express edition of C# or C++ installed?

##### Share on other sites
Quote:
 Original post by Metzler@Mrs Kensington: If I remember correctly, it was you, who once posted his Vsa-Script-Engine on gamedev.net, right?Do you have any problems related to this? Or is there any Engine-Option, that i have to set?

yeah that was me... I've not had any problems and I tried to recreate your problems but couldn't get it to error... my initialisation code is the following...

engine = new VsaEngine(true);engine.RootMoniker = moniker;engine.Site = new VsaSite(this);engine.InitNew();engine.RootNamespace = rootNamespace;engine.Name = rootNamespace;//set some optionsengine.SetOption("alwaysGenerateIL", true);engine.SetOption("autoRef", true);engine.SetOption("print", true);

I can't see anything in there that would cause your problems... have you got alwaysGenerateIL set to true as that will at least try to build an assembly that runs even if there is an error...

If you could post a stripped down version of your code that we could compile then i'll have a play and see if I can get it to work...

One last question... does it happen if you put a comment anywhere in your code or is it only in function that you are calling as part of a seperate thread?

• 18
• 29
• 11
• 21
• 16