Debugging by Log

From iRidium Mobile Wiki
Jump to: navigation, search
Консоль (выделена красным)

You can use a console as a debugging tool in iRidiumScript. The console is used for storing error messages, debugging JavaScript code and other tasks. You can write data in the console with the IR.Log(data) command, where data is the information that has to be input in the console.

The console also automatically shows errors in the code which are discovered while executing the script.The module and string number are indicated nextto the error. Besides with the help of log you can control data output in the console. When developing a script it is useful to know values of variables to be able to check it the code isexecuted correctly. The log works under the Windows OS only.


  IR.Log("Hello World"); //Output in the console Hello World
  • This method can be used for outputting the calculated values:
 var a = 2; // Definition of variable a
 var b = 5; // Definition of variable b
 var result = a+b; //Adding variables up
 IR.Log(result); //Output in the console 12
  • The IR.Log() instruction is convenient to use when developing drivers:
  IR.AddListener(IR.EVENT_RECEIVE_TEXT, DEVICE, function(text)
  {
     IR.Log(text) //Output all data which came from the device in the console 
  });
  • You can also output the result of executing of any command in the console:
  IR.AddListener(IR.EVENT_RECEIVE_TEXT, DEVICE, function(text)
  {
     IR.Log(text.length) //Output the length of the string with the data received form the device in the console 
  });