String Functions
The following table lists the available string functions.
ZPL STRING FUNCTIONS
Function | Description |
$BUFFER() | Returns the current string in the lens buffer. This function is used to extract string data from various ZPL keywords and functions. |
$CALLSTR(i) | Returns the string from the CALLMACRO string buffer at index i. See "Calling a Macro from within a Macro". |
$COAT(i) | Returns the coating name for the ith surface. |
$COATINGPATH() | Returns the path name for coating files. |
$COMMENT(i) | Returns the comment string for the ith surface. |
$DATAPATH() | Returns the path name for data files. |
$DATE() | Returns the current date and time string. The formatting is specified by the Date/Time control settings in the General section of the OpticStudio Preferences. |
$EXTENSIONPATH() | Returns the path name for OpticStudio extensions. |
$FILENAME() | Returns the current lens file name, without the path. |
$FILEPATH() | Returns the current lens file name, with the complete path. |
$GETSTRING(A$, n) | Returns the nth sub-string for the string A$ using spaces for delimiters. For example, if A$ = "one two three", then $GETSTRING(A$, 2) returns "two". Input A$ must be a string variable defined prior to calling this function. |
$GETSTRINGC(A$, n) | Returns the nth sub-string for the string A$ using commas for delimiters. For example, if A$ = "one,two,three", then $GETSTRING(A$, 2) returns "two". Input A$ must be a string variable defined prior to calling this function. |
$GLASS(i) | Returns the glass name of surface number i. |
$GLASSCATALOG(i) | Returns the name of the ith loaded glass catalog for the current lens. If i is less than 1, then the names of all the loaded catalogs separated by spaces are returned in a single string. |
$GLASSPATH() | Returns the path name for glass catalog files. |
$LEFTSTRING(A$, n) | Returns the left most n characters in the string A$. If A$ has fewer than n characters, the remaining spaces will be padded with blanks. This allows formatting of strings with a fixed length. Input A$ must be a string variable defined prior to calling this function. |
$LENSNAME() | Returns the lens title defined in the System Explorer. |
$MACROPATH() | Returns the path name for macro files. |
$NEWLINE() | Returns the tab character (\n). This function should primarily be used to update the Title/Notes section in the System Explorer. |
$NOTE(line#) |
Returns the notes information defined in the System Explorer. Because the notes may be very long, $NOTE returns the characters from the notes in groups called lines. A line ends when a newline (carriage return) character is found, or when the total number of consecutive characters on the line reaches 100, whichever comes first. The line# indicates which line in the notes is to be returned. For example, $NOTE(1) returns the first line in the notes, up to the first newline character. If there are more than 100 consecutive characters before the first newline is found, then line 1 will be the first 100 characters, and line 2 will be the remainder of the line up to the first newline, or the next 100 characters, whichever comes first. The maximum number of characters in the notes is currently 4000 (because of space limitations, it may not be possible to edit this many characters in the Title/Notes section of the System Explorer however). $NOTE will return a null (empty) string if there are no defined characters in the notes for the specified line. The function SLEN can be used to determine the actual number of characters returned by $NOTE using this syntax: A$ = $NOTE(1) N = SLEN(A$) The value N will be the integer number of characters in the string A$. |
$OBJECTPATH() | Returns the path name for NSC object files. |
$PATHNAME() | Returns the path name only for the current lens file. This is useful for determining the folder where the lens file is stored. |
$PROGRAMPATH() | Returns the path name for program files. |
$QUOTE() | Returns the double quote character ("). |
$RIGHTSTRING(A$, n) | Returns the right most n characters in the string A$. If A$ has fewer than n characters, the remaining spaces will be padded with blanks. This allows formatting of strings with a fixed length. Input A$ must be a string variable defined prior to calling this function. |
$STR(expression) | Returns a string formatted using the format defined by the FORMAT keyword. The numeric expression may be any equation, including combinations of constants, variables, and functions. See function SVAL(A$) to convert strings to numbers. |
$TAB() | Returns the tab character (\t). |
$TEMPFILENAME() | Returns the name of a temporary file, with complete path, suitable for temporary storage of text or binary data. See keyword GETTEXTFILE. Use the DELETEFILE keyword to delete temporary files as they are not automatically deleted. |
$TOLCOMMENT(operand) | Returns the comment for the specified tolerance operand. |
$TOLOPERAND(operand) | Returns the operand name for the specified tolerance operand. |
$UNITS() | Returns either MM, CM, IN, or M, depending upon the current lens units. |
Next: