String Expressions, Operations and Functions

The alphanumerical variables $A to $Z as well as the system variables $@ to $@9 can also be used in an expression. The formula interpreter determines whether the entered alphanumerical characters are to be interpreted as string variables or string constants. Furthermore, numerical variables can be converted into alphanumerical variables. It is mainly the first character that decides what string type to interpret the input as. Function calls can also be carried out using string variables that return numerical results.


String constant

If the first character of the character string is the $ or % sign, then all the following characters are transferred as a string constant; for example, $A=Test means that $A is a string constant.


Convert numerical variable into string

If the input string consists only of the % signs and the name of a numerical variable, e.g. %A1, then the content of this numerical variable is converted into a string. System variable $@ has a special significance in this procedure. The content of this system variable is interpreted as a FORTRAN format and used for conversion. The format string must be enclosed in round brackets and can contain other format statements beside a numerical format, e.g. an additional text in the form of a Hollerith format. Using variable $@ can be particularly beneficial for annotations in the drawing and in connection with the automatic BOM generation.

If, for example, the string (4HFl.: , F8.2 , 5H m^^2) is assigned to variable $@  and then the content of system variable Z0 inserted as text in the drawing, the output appears in the form Fl.: 148.25 m2

System variable $@ should then be deleted again.

A string that starts with the % sign, but is not followed by a variable name, is transferred as a string constant without any changes.


String start with $

In the simplest case, the input string consists only of the name of a string variable, e.g. $A. The content of the relevant string variable is then made available for further processing. It is, however, also possible not to use the entire content of a string variable, but only a part of it. To do this, specify the start and end position of the partial string behind the variable name in round brackets. Start and end positions can be any arithmetic expressions and must be separated by a colon.

$N= C:DATEI1  ->   $N(3:7)  -> DATEI


String operations

Strings can be linked by the operator +, whereby there must be no spaces between the operands and the + sign.

$A=Text1 and $B=Text2


String functions

The following string functions are available in HiCAD:

Function

LEN(string)

Length of the string, with the string being either a string constant or a string variable. The result is numeric.

ASC(string)

ASCII code of the first character of the string.

CHR$(num)

ASCII character which is the same as the result of the numerical expression num. The value of num may only accept whole number values between 0 and 255.

VAL(string)

Converting a string into a numerical value. The prerequisite is that the content of the string can be interpreted numerically. Under certain circumstances, only a part of the string may be used for the conversion.

TIM$

Current time in the form HH:MM:SS. The result is a string.

DAT$

Current date in the form YY:MM:DD. The result is a string.

The date is output according to the Date format set in the Configuration Editor at System settings > Units. This also applies to the use of DAT$ in macros.

String Operations and FunctionsSystem VariablesUser Variables