Values and Expressions
CSL supports the following types of values
Arithmetic: can be designated by expressions (see below), numeric literals such as 50 or 21.75, or identifiers such as roughMass or machine.cycleTime. See Numerical Literals for more information about arithmetic values.
String: can be designated by expressions (see below), string literals, such as ‘Material Cost’, or identifiers such as op.name. See String Literals for more information about strings.
Boolean: can be designated by expressions (see below), the boolean literals true and false, or identifiers such as op.isManualOverride.
Object: can be designated by expressions (see below) or identifiers such as part, gcd, or machine. Each object has one or more named fields which you can access using dot notation, as in part.volume or part.material. The value of a field can be any type of CSL-supported value, including a collection or other object.
Collection: can be designated by expressions (see below) or identifiers such as childOps or tubLaserCutting. Note that a cost model’s lookup tables are collections; each collection element is a table row, and each collection-element field corresponds to a table column. You can retrieve a collection’s elements by using query or foreach expressions.
See Identifiers and Literals for information on CSL literals and identifiers.
CSL supports the following kinds of expressions:
Arithmetic: can be formed using binary and unary arithmetic operators, such as * and -. See Arithmetic Expressions for more information.
String: can be formed using the string concatenation operator +. See String Expressions for more information.
Boolean: can be formed using unary and binary logical operators such && and ~, as well as binary arithmetic comparison operators such as == and <=. See Boolean Expressions for more information.
Conditional: evaluates to one of several alternative values, depending on the value of boolean expressions associated with the alternative values. See Conditional Expressions for more information.
Function invocation: evaluates to the result of substituting the invocation’s actual parameters for the formal parameters in the corresponding function definition. See Function Invocations for more information.
Query: retrieves or aggregates collection elements or values. These expressions have essentially the same semantics as SQL queries. See Query Expressions for more information.
Foreach: evaluates to the result of applying a formula to each collection element in turn. See Foreach Expressions for more information.
In general, a type mismatch (for example, using a string as an operand of a boolean operator) causes an exception (that is, runtime error) in CSL. In some cases, the cost engine converts an arithmetic value to a string in order to resolve a mismatch. Similarly, true and false are converted to 1 and 0 (respectively) in some cases.