converting js file into dll

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rizjabbar@gmail.com

    converting js file into dll

    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

  • Dan Rumney

    #2
    Re: converting js file into dll

    rizjabbar@gmail .com wrote:
    [snip]
    >
    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 been declared
    Try declaring _InitEngine_pro totype_called:
    var _InitEngine_pro totype_called = true;

    Comment

    • rizjabbar@gmail.com

      #3
      Re: converting js file into dll

      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_pro totype_called = false;
      if (_InitEngine_pr ototype_called == false)

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

      Comment

      Working...