String Expressions, Operations and Functions

The alphanumeric 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 alphanumeric characters are to be interpreted as string variables or string constants. Furthermore, numeric variables can be converted to alphanumeric 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 numeric 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 numeric variable to string

If the input string consists only of the % signs and the name of a numeric variable, e.g. %A1, then the content of this numeric variable is converted to 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 numeric 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

Result

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 numeric expression num. The value of num may only accept whole number values between 0 and 255.

VAL(string)

Converting a string to a numeric 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.

 Related Topics

String Operations and FunctionsSystem VariablesUser Variables

Version 1702 - HiCAD Basics | Date: 9/2012 | © Copyright 2012, ISD Software und Systeme GmbH