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="JavaS cript" SRC="TEng.js" ></SCRIPT>
</head>
<body>
<script type="text/javascript">
var fst = 10;
var snd = 10000;
var p = new InitEngine(fst) ;
document.write( '<BRrandom: ' + p.EngineRank(sn d) );
</script>
</body>
</html>
b) "TEng.js" file
function InitEngine(diOb j)
{
// initialize the member variables for this instance
this.piObj = diObj;
// initialize the member function references for the class
prototype
if (typeof(_InitEn gine_prototype_ called) == 'undefined')
{
_InitEngine_pro totype_called = true;
InitEngine.prot otype.EngineRan k = EngineRank;
InitEngine.prot otype.rndm = rndm;
}
////////////////////////////////////////////////////////////////////////////
function EngineRank(posO bj)
{
var sTmp = this.rndm(posOb j, 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_pr ototype_called'
has not b
een declared
TEng.js(1,9) : error JS1234: Only type and package definitions are
allowed insid
e a library
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="JavaS cript" SRC="TEng.js" ></SCRIPT>
</head>
<body>
<script type="text/javascript">
var fst = 10;
var snd = 10000;
var p = new InitEngine(fst) ;
document.write( '<BRrandom: ' + p.EngineRank(sn d) );
</script>
</body>
</html>
b) "TEng.js" file
function InitEngine(diOb j)
{
// initialize the member variables for this instance
this.piObj = diObj;
// initialize the member function references for the class
prototype
if (typeof(_InitEn gine_prototype_ called) == 'undefined')
{
_InitEngine_pro totype_called = true;
InitEngine.prot otype.EngineRan k = EngineRank;
InitEngine.prot otype.rndm = rndm;
}
////////////////////////////////////////////////////////////////////////////
function EngineRank(posO bj)
{
var sTmp = this.rndm(posOb j, 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_pr ototype_called'
has not b
een declared
TEng.js(1,9) : error JS1234: Only type and package definitions are
allowed insid
e a library
Comment