console Function
The console
method allows displaying different types of messages in the Console expander of the Script Editor. Any messages traced using this method are not persisted; they are available as long as the Script Editor application is open on the screen.
It is recommended to use the console
method during the development or in debug.
Syntax
It is possible to trace messages in the Console expander. See the following syntax.
console(<message>, <arguments>);
console(<Object>);
Parameters Usage
Parameter |
Type |
Default |
Use |
Annotation |
message |
String |
- |
Mandatory |
Simple string (for example, For example, |
arguments |
variable number of objects |
- |
Optional |
Any comma-separated arguments necessary for the format string. The number of arguments must match the number of format items contained in the Each argument can indicate a constant value or a local variable. |
object |
Object Object Array |
- |
Mandatory |
An individual object or an array of objects. Each object can indicate a constant value or a local value. |
Error Handling
Errors can occur in case:
- The
console
method is called withnull
, empty<message>
, or empty<object>
. - The output in the Console expander is
null
(nothing is traced).
- The
<arguments>
requested by<message>
are missing or provide more or less elements as required by<message>
. Extra elements are then ignored. In case of missing arguments, then the<message>
string is printed as it is. <message>
uses the same index for more than one format item. Any item that uses the same index is replaced by the same value.<message>
or<object>
are not provided.- An exception is generated and the script terminated with an error.
Examples of Use
Print to Console - How to print a message
//Print a date value
var currentDateTime = new Date();
console("Current time: {0}", currentDateTime);
//Print an integer value
var myInteger = -1;
console("Integer value = {0}", myInteger)
console(myInteger)
//Print a real value and a bool value
console("{0}; {1}", 1.23, true)
//Print an array of real values
var myRealArray = [1.23, -4.56, 7.89]
console("{0}", myRealArray)
console(myRealArray)
//Print an array of string values and an array of real values
var myStringArray = ["hello", "world"]
console("{0}; {1}", myStringArray, [-3.45, 6.7])
//Print a simple dynamic object or an array of dynamic objects
var a = {var1: "Hello" }
var b = {var2: 123 }
console("{0}", a)
console(b)
console([a, b])