Non Web-Based JavaScript, call C++ function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • notacreativeguy
    New Member
    • Dec 2012
    • 7

    Non Web-Based JavaScript, call C++ function

    Hey everyone. I'm trying to figure out how to call a C++ function from javascript. Everywhere I look, I'm just getting web-based answers and that won't help me. I'm working on a program that runs javascript while a machine is running, and I need this script to call a C++ function along the way, but can't figure out how. Any help? Even the most basic answer such as how to get a "Hello world" C++ funtion to run will be sufficient. Thanks!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    where does the JavaScript run? in a browser or (like node.js) in the console?

    if the JS runs in a browser, you can’t call a C++ function directly. you have to take a roundtrip and call a server script that runs the function for you.

    Comment

    • notacreativeguy
      New Member
      • Dec 2012
      • 7

      #3
      It runs in the console. Once a machine starts running, it executes a xxx.js file which processes the information. There is no indication on the computer that anything is happening at all. I just need this .js to call on some C++ functions.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        then it depends on the File System API that your JS host provides.

        but even then, you can only call an app/script that runs the C++ for you. there is no way for JS to directly call another language’s function.

        Comment

        • notacreativeguy
          New Member
          • Dec 2012
          • 7

          #5
          How do I go about calling a script to execute the C++?

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            that depends on the API that is available to JS.

            Comment

            • notacreativeguy
              New Member
              • Dec 2012
              • 7

              #7
              I am not aware of the API. I will have to do some digging.

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                you may look at node.js, that’s also a console based JS implementation, so you might get some ideas.

                Comment

                • notacreativeguy
                  New Member
                  • Dec 2012
                  • 7

                  #9
                  There is a funtion in the .js file that causes an arm to move and creates a database recording whther or not it runs in to something. Once the function completes, the robot software requires C++ to create a database and report that records pass/fail results if there were objects that it ran in to. I just need the javascript to call on the C++ scripting at the end of its routine to create the database and report. I don't know what all there is as far as API, other than I use a simple .js to execute commands for the robot and I need it to somehow activate a C++ script.

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    asked the other way round, what application is running the JS?

                    Comment

                    • notacreativeguy
                      New Member
                      • Dec 2012
                      • 7

                      #11
                      It's a machining program called Technomatix.

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #12
                        then you would need to read the Technomatix documentation to find any info about an API that lets you communicate with other applications.

                        Comment

                        • notacreativeguy
                          New Member
                          • Dec 2012
                          • 7

                          #13
                          I just returned from a meeting on the project, and it turns out that my boss has some code from the company that he held from me. He likes to make me work I guess. Thanks for the input!

                          Comment

                          Working...