You can define your own functions in the following way:
function returnType functionName (type1 arg1, type2 arg2,..., typeN argN) { variableDeclarations otherFunctionDeclarations Statements Mappings return [expression]; }
You must put the return statement at the end. For more
information about the return statement see Return Statement. Inside some functions, there
can be Mappings
. These may be in any place inside the function.
In addition to any other data type mentioned above, the function can also return void
.
Since CloudConnect version 2.8.0, you can also define a function for your own error messages.
function string 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.