converting js file into dll

R

rizjabbar

I have a js file that is being accessed through an html page. This
requirement is not going to change.
At this time, a need has arisen for access to the functions of these
files from another program that is running in C# / .Net environmet. Is
there any way to convert this file from a js file to dll.
I have access to all the three codes, the only requirement is that we
want to maintain one version of the js file.

Here is an example of the working code:
a) HTML calling code
<html>
<head>
<SCRIPT LANGUAGE="JavaScript" SRC="TEng.js" ></SCRIPT>
</head>
<body>
<script type="text/javascript">
var fst = 10;
var snd = 10000;
var p = new InitEngine(fst);
document.write('<BR> random: ' + p.EngineRank(snd) );
</script>
</body>
</html>

b) "TEng.js" file
function InitEngine(diObj)
{
// initialize the member variables for this instance
this.piObj = diObj;

// initialize the member function references for the class
prototype
if (typeof(_InitEngine_prototype_called) == 'undefined')
{
_InitEngine_prototype_called = true;
InitEngine.prototype.EngineRank = EngineRank;
InitEngine.prototype.rndm = rndm;
}
////////////////////////////////////////////////////////////////////////////
function EngineRank(posObj)
{
var sTmp = this.rndm(posObj, this.piObj);
return sTmp;
}

function rndm(a, b)
{
return a + Math.floor(Math.random()*(b-a+1));
}
}
////-----------------------------------------------

Tried compiling the dll code with visual studio's jsc command but got
the following error.
TEng.js(7,24) : error JS1135: Variable '_InitEngine_prototype_called'
has not b
een declared
TEng.js(1,9) : error JS1234: Only type and package definitions are
allowed insid
e a library
 
R

rizjabbar

You are right: I was thinking that I needed it to be undefined... but
change the basic logic and keep the initialization process in touch.
This resolved one of the two issue. Here are the changes.
var _InitEngine_prototype_called = false;
if (_InitEngine_prototype_called == false)

Still getting the second errorJS1234: Only type and package
definitions are allowed inside a library
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top