Hello Segger staff,
I have a techinnical inquiry regarding to the emScript.exe that is included in Segger Embedded Studio.
I would like to know what kind of javascript version is being used in the emScript.exe interpreter. I am interested in knowing that becuase I need to know what kind of method I can use or not. For instance, I do know making usage of the method search() in a string will turn into an 'undefined' error, which to me means that that method seems not to be implemented.
Therefore, I would like you to tell me the API that is implemented in emScript.exe in order to cope with javascript files.
Finally, I instance you to try to run the below code snippet in Embedded Studio using emScript to check that the method search() for strings (amongst other) is not implemented or understood by emScript.exe. It will compile without error but the execution/ouput is wrong.
Looking forward to hearing from you,
Kind regards
Code:
Display All
I have a techinnical inquiry regarding to the emScript.exe that is included in Segger Embedded Studio.
I would like to know what kind of javascript version is being used in the emScript.exe interpreter. I am interested in knowing that becuase I need to know what kind of method I can use or not. For instance, I do know making usage of the method search() in a string will turn into an 'undefined' error, which to me means that that method seems not to be implemented.
Therefore, I would like you to tell me the API that is implemented in emScript.exe in order to cope with javascript files.
Finally, I instance you to try to run the below code snippet in Embedded Studio using emScript to check that the method search() for strings (amongst other) is not implemented or understood by emScript.exe. It will compile without error but the execution/ouput is wrong.
Looking forward to hearing from you,
Kind regards
Code:
JavaScript Source Code
- var myLog = "log.txt"
- var example = "Example_for_emScript";
- CWSys.writeStringToFile(myLog, "--Starting emScript method test--"+"\n")
- //These two examples will fail because the return value of the call example.search() is undefined, which is wrong since
- // javascript implements the method search to search string within strings. See https://www.w3schools.com/Jsref/jsref_search.asp
- CWSys.appendStringToFile(myLog, "example.search(emScript) ouput->"+example.search("emScript")+", output should be 12"+"\n")
- CWSys.appendStringToFile(myLog, "example.search(for) output->"+example.search("for")+"output should be 8"+"\n")
- //None of the following strings will be appended to log.txt since the output of search is undefined...
- if( example.search("emScript") >-1 ){
- CWSys.appendStringToFile(myLog, "emScript string was found!"+"\n")
- } else if (example.search("for") >-1) {
- CWSys.appendStringToFile(myLog, "for string was found!"+"\n")
- }
- CWSys.appendStringToFile(myLog, "--Finishing emScript method test--"+"\n")