String operators

Operator

Function

Example

Result

uppercase

Convert string to all upper-case characters

[uppercase("abc")]

Returns ABC

+

If used with two strings, the strings are concatenated.

["abc" + "def"]

Returns abcdef

+

If used with a string and a number the number is converted to a string and then they are added.

["0.5" +0.0]

Returns 0.5. This is a shortcut for converting a string into a number.

mid(string, startpos[,length])

Extracts a substring, starting at startpos, that is length long, from string.
Note: startpos is a 0-based index.

[mid("abcdef",2,3)]

Returns cde

strlen()

Determines the length of a string.

[strlen("abc")]

Returns 3

subst(arg1,"arg2","arg3")

In argument1, replaces every occurrence of argument2 with argument3.

[subst(<WIRE>,"_", " ")]

Replaces every occurrence of "_" with " " in <WIRE>.

InStr([start,]string1,string2[,compare])

Returns the position of the first occurrence of string2 within string1.
Note: String indexes are 0-based. The return value indicating "string not found" is -1.

[instr ("abcdef", "def")]

Returns 3.0

InStrRev (string1,string2[,start[,compare]])

Returns the position of the first occurrence of string2 within string1. The search begins from the end of the string, but the position returned counts from the beginning of the string.
Note: String indexes are 0-based. The return value indicating "string not found" is -1.

[instrrev("defabcdef","def")]

Returns 6.0

Tip: Many of the logical operators also work for strings.

Example

You can use mid() and strlen() to convert the total machining time from the hours:minutes:seconds format to seconds:

[:sec=mid(<MACH-TIME>,strlen(<MACH-TIME>)-2)]<EOB>
[:min=mid(<MACH-TIME>,strlen(<MACH-TIME>)-5,strlen(<MACH-TIME>)-3)]<EOB> 
[:hr=mid(<MACH-TIME>,0,strlen(<MACH-TIME>)-6)]<EOB>
[hr*3600+min*60+sec]<EOB>