microsoft / Chakra-Samples

Repository for Chakra JavaScript engine related samples.
MIT License
216 stars 84 forks source link

Provide sample js script and command line input for ChakraCoreHost sample #41

Open haichencheng opened 8 years ago

haichencheng commented 8 years ago

When I am trying to run the ChakraCoreHost sample project, the instruction

  1. Run the sample by pressing Ctrl+F5 or using Debug > Start Without Debugging. is not correct.

After I stepped through the code, I got that I supposed to provide a path to a js file such as C:\Users\XXX\Desktop\temp\runSimple.js

to exercise the host's function, I create runSimple.js with content: host.runScript('C:/Users/XXX/Desktop/temp/simple.js');

Where simple.js has content: host.echo("wbc",1,2,3);

liminzhu commented 8 years ago

@haichencheng are you talking about this one? Right you need to supply the script and the path as argument and that isn't clear from the readme. Let me fix this.

misuo commented 7 years ago

I believe the below simple javascript (a nameless function call) - when saved to a test.js file - illustrates how it works:

( () => {
  host.echo('Hello World!');
  // host.argument[0] is the .js file.
  host.echo("Hello " + host.arguments[1]);

  return 0;
} )();

In a command prompt run the test.js script with (here illustrated using the Windows version):

ChakraCoreHost.exe test.js "YourName"

And you should/will see the output:

Hello World!
Hello YourName
0
liminzhu commented 7 years ago

Sorry for the late update. Added some clarification in readme to make it obvious. https://github.com/Microsoft/Chakra-Samples/commit/42d4bfcaa9406ebf1733ef335eac00b55812c8b6