strcase function returns the conversion of all alphabetic characters in a string to uppercase or lowercase. It accepts two arguments: a string and an optional argument that specifies the case in which the characters are returned. If the optional second argument is omitted, it evaluates to nil and strcase returns the characters converted to uppercase.
AutoLISP provides functions for working with string values. For example, the_$ (strcase "This is a TEST.")
"THIS IS A TEST."
T, the characters are returned as lowercase. AutoLISP provides the predefined variable T to use in similar situations where a non-nil value is used as a type of true/false toggle.
If you provide a second argument of_$ (strcase "This is a TEST." T)
"this is a test."
strcat function combines multiple strings into a single string value. This is useful for placing a variable string within a constant string. The following code sets a variable to a string value and then uses strcat to insert that string into the middle of another string.
The_$ (setq str "BIG") (setq bigstr (strcat "This is a " str " test."))
"This is a BIG test."
bigstr is set to the preceding string value, you can use the strlen function to find out the number of characters (including spaces) in that string.
If the variable_$ (strlen bigstr)
19
substr function returns a substring of a string. It has two required arguments and one optional argument. The first required argument is the string. The second argument is a positive integer that specifies the first character of the string you want to include in the substring. If the third argument is provided, it specifies the number of characters to include in the substring. If the third argument is not provided, substr returns all characters including and following the specified start character.
Thesubstr function to strip off the three-letter extension from a file name (note that you can actually use the vl-file-name-base function to do this). First, set a variable to a file name.
As an example, you can use the_$ (setq filnam "bigfile.txt")
"bigfile.txt"
strlen to get the length of the string and subtract 4 from that value. Then use substr to specify the first character of the substring and its length.
You need to get a string that contains all characters except the last four (the period and the three-letter extension). Use_$ (setq newlen (- (strlen filnam) 4))
7
_$ (substr filnam 1 newlen)
"bigfile"
newlen, you can combine these two lines of code into one.
If your application has no need for the value of_$ (substr filnam 1 (- (strlen filnam) 4))
"bigfile"
AutoLISP Function Synopsis under the heading String-Handling Functions These functions are described in the AutoLISP Reference.
Additional string-handling functions are listed in AutoLISP also provides a number of functions that convert string values into numeric values and numeric values into string values. These functions are discussed in