About Nodes
A node contains several properties including:
- Definition
- Form
- Comment
- Node display format
- Value display format
- Calculated value
- Runtime attributes
Many of these properties are cosmetic, that is, they simply affect how the node displays. The definition, however, determines what the node does. For this reason, the definition is the most important part.
You create nodes by entering a definition with the format:
Name is the name of the node, (arguments) is an optional list of input arguments, and statement is a formula, statement, or statement block defining the node's function.
Use the Define operator (:=) to create a definition rather than use the Assign operator (=). Assign is used to store a value in an existing variable. Define creates a new node definition, but does not execute it or assign a value to it.
See Define.
See Assign.
If you enter a definition without input arguments, you get a Constant:
If you include arguments, you get a Function:
The right-hand side in both of these examples includes only a single statement. These types of definitions are called simple. If the right-hand side includes a statement block, the definition is called compound. A statement block is simply a list of statements enclosed in braces { }.
Following is an example of a compound constant:
Following is an example of a compound function:
When DScript executes a statement block, it simply executes each statement in the order they are listed and returns the value of the last statement.
Other definitions can call constants simply by using their names as in the following example:
You call functions by using their names followed by a list of argument values. For example:
When you call Profit you do not place a pair of parentheses after the node name, that is, use Profit instead of Profit(). Most other programming languages require you to use parentheses every time you call a subroutine. With DScript, you do not need to do this so long as the node you are calling is defined as a constant.
Constants are a powerful yet unique programming concept. Constants, as supported by DScript, are unlike anything found in traditional languages.