You can define your own functions in the following way:
function functionName (arg1,arg2,...) { variableDeclarations Statements Mappings [return [expression]] }
You must put the return statement at the end. For more
information about the return statement see Return Statement. Right before it there
can be some Mappings
, the
variableDeclarations
and
Statements
must be at the beginning, the
variableDeclarations
and
Statements
can even be interspersed, but you must
remember that undeclared and uninitialized variables cannot be used.
So we suggest that first you declare variables and only then specify
the Statements
.
Since CloudConnect version 2.8.0, you can also define a function for your own error messages.
function getMessage() { return message; }
This message
variable should be declared as
a global string variable and defined anywhere in the code so as to
be used in the place where the getMessage()
function is located. The message
will be written
to console.