Feature Parameter Formulas


Syntax in the documentation

Functions will be described with the following syntax in the documentation:

function_name(Parameter1: Data_type1, Parameter2: Data_type2): Return_data_type

This syntax describes the function called Function_name. The function expects to receive two parameters: Parameter1 with the data type Data_type1 and Parameter2 with the data type Data_type2. The function returns a value of the type Return_data_type.

 

Example

distance_point_edge(p: Point, e: Edge): Real

The function distance_point_edge expects two parameters: One Point and one Edge, and returns a Real value.


Formal specifications

Formula

=

ConditionedExpression

ConditionedExpression

=

Expression1 ["?" Expression1 ":" Expression1 ]

If the section exists with a question mark, HiCAD checks whether the expression before the question mark is zero. If it is, the expression after the colon is taken; if it is not, that before the colon is taken.

Expression1

=

Expression2 { ("&" | "|") Expression2}

"&" is a logical And, "|" a logical Or.

Expression2

=

SimpleExpression [ ( "=" | "<" | ">" | "<=" | ">=" | "<>" ) SimpleExpression ]

The result of the comparison is 1 for true and 0 for false.

SimpleExpression

=

[ "+" | "-" | "!" ] Term { ("+" | "-") Term }

"!" is the logical Not. If the term after the "!" is zero, the result is 1, if not, 0

Term

=

Factor { ( "*" | "/" | "%") Factor }

"%" calculates the integral remainder in a division (modulo). To work with decimal numbers, use the modulo function.

Factor

=

SimpleFactor ["^"SimpleFactor]

"^" is the potentiation.

SimpleFactor

=

Variable | Number | Constant | Function Call | "(" ConditionedExpression ")"

Bracketing can be used to nest formulas as required.

FunctionCall

=

Function "(" [ ConditionedExpression { "," ConditionedExpression } ] ")"

Parameter-free functions are called using empty brackets: f().

Constant

=

"pi"

Function

=

"sin" | "cos" | "tan" | ... | "aint" | ...

For the precise list of functions, see below.

Variable

=

Letter {LetterOrDigit | "_"}

Variable names must begin with a letter. The maximum length of a variable name determines the valid length of HiCAD macro variables.

Number

=

(Number1 | Number2) [("e" | "E") ["-" | "+"] Digits]

Examples: 1; 1.2; .2; 1e10; 1.23E5.

Number1

=

Digits ["." Digits]

Number2

=

"." Digits

LetterOrDigit

=

Letter | Digits

Letter

=

"a" | ... | "z" | "ä" | "ö" | "ü" | "A" | ... | "Z" | "Ä" | "Ö" | "Ü"

Digit

=

"0" | ... | "9"

Digits

=

Digit {Digit}

List

=

" (" SimpleExpression ( "; " | {"; " SimpleExpression}) ") "

 

Examples

(If 'l' is greater than 100, the value of 'a' is obtained, if not, 'b'+20)

(Functions must have brackets even if they do not have parameters)

Selection from a list - The variable type indicates which value from the list is to be returned: If type=1, 10 is returned; type=2 returns 50 and type=3 returns 100.

The Value Input: Formulas and Variables