Satish Lele
satish.lele@gmail.com


Text Functions
String Formatting:
strcase: Returns a string where all alphabetic characters have been converted to upper case or lower case (strcase string [whichcase])
If whichcase is omitted or evaluates to nil, all alphabetic characters in string are converted to upper case. If whichcase is supplied and is not nil, all alphabetic characters in string are converted to lower case.
(strcase "Sample")     returns "SAMPLE"
(strcase "Sample" T)     returns "sample"
The strcase function will correctly handle case mapping of the currently configured character set.

strcat: Returns a string that is the concatenation of multiple strings
(strcat string1 [string2]...)
(strcat "a" "bout")     returns "about"
(strcat "a" "b" "c")     returns "abc"
(strcat "a" "" "c")     returns "ac"

strlen: Returns an integer that is the number of characters in a string
(strlen [string]...)
If multiple string arguments are provided, it returns the sum of the lengths of all arguments. Omitting the arguments or entering an empty string returns 0 (zero).
(strlen "abcd")     returns 4
(strlen "ab")     returns 2
(strlen "one" "two" "four"     returns 10
(strlen)     returns 0
(strlen "")     returns 0

substr: Returns a substring of a string. (substr string start [length])
substr function starts at the start character position of string and continues for length characters. If length is not specified, the substring continues to the end of string. start and length arguments must be positive integers. The first character of string is character number 1.
(substr "abcde" 2)     returns "bcde"
(substr "abcde" 2 1)     returns "b"
(substr "abcde" 3 2     returns "cd"

Conversion of Number to String:
rtos: Converts a number into a string (rtos number [mode [precision]])
rtos function returns a string that is the representation of number according to the settings of mode, precision, and the system variables UNITMODE and DIMZIN. mode and precision arguments are integers that select the linear units mode and precision.
(rtos "17.50" 1) returns string 1.7500E+01,     Mode 1 = scientific
(rtos "17.50" 2) returns string 17.50,     Mode 2 = decimal
(rtos "17.50" 3) returns string 1'-5.50",     Mode 3 = engineering
(rtos "17.50" 4) returns string 1'-5 1/2",     Mode 4 = architectural
(rtos "17.50" 5) returns string 17 1/2,     Mode 5 = fractional

angtos: (angtos angle [mode [precision]]): Converts an angular value in radians into a string.
itoa: (itoa int): Returns conversion of an integer into a string.
chr: (chr int): Returns conversion of an integer representing an ASCII character code into a single-character string.

Conversion of String to Number:
angtof: (angtof string [mode]): Converts a string representing an angle into a real.

distof: Converts a string that represents a real (floating-point) value into a real value (distof string [mode]) The mode argument specifies the units in which the string is formatted. The value should correspond to values allowed for the AutoCAD system variable LUNITS, as shown in the following table. If mode is omitted, distof uses the current value of LUNITS Linear units values are same as Mode value.
(distof "17.50" 1) returns real 1.7500E+01,     Mode 1 = scientific
(distof "17.50" 2) returns real 17.50,     Mode 2 = decimal
(distof "17.50" 3) returns real 1'-5.50",     Mode 3 = engineering
(distof "17.50" 4) returns real 1'-5 1/2",     Mode 4 = architectural
(distof "17.50" 5) returns real 17 1/2,     Mode 5 = fractional

atof: (atof string): Returns the conversion of a string into a real.
(angtof "180" 0) returns 180,     Mode 0 = degrees
(angtof "180" 1) returns 180d0'0\",     Mode 1 = deg/min/sec
(angtof "180" 2) returns 200.0000g,     Mode 2 = grads
(angtof "180" 3) returns 3.14159r,     Mode 3 = radians
(angtof "180" 4) returns W,     Mode 4 = surveyor's

atoi: (atoi string): Returns the conversion of a string into an integer.

ascii: (ascii string): Returns the conversion of the first character of a string into its ASCII character code (an integer).

Control Characters in Strings: Within quoted strings, the backslash (\) character allows control characters (or escape codes) to be included. The following table shows the currently recognized control characters.
Control Code Characters Description
\\     character \
\"     character "
\e     Escape character
\n     Newline character
\r     Return character
\t     Tab character
\nnn     Character whose octal code is nnn
\U+xxxx     Unicode character sequence
\M+nxxxx     Multi-byte character sequence

cvunit: Converts a value from one unit of measurement to another.
(cvunit value from to)
The value argument is the numeric value that you want to convert. It can also be a list containing two or three numbers to be converted (a 2D or 3D point). from argument is the unit that the value is being converted from, and to is the unit that the value is being converted into. from and to arguments can name any unit type found in the acad.unt file. If successful, cvunit returns the converted value. If either unit name is unknown (not found in the acad.unt file), or if the two units are dimensionally incompatible (as in converting grams into years), cvunit returns nil.
(cvunit 1 "minute" "second")     returns 60.0
(cvunit 1 "gallon" "furlong")     returns nil
(cvunit 1.0 "inch" "cm")     returns 2.54
(cvunit 1.0 "acre" "sq yard")     returns 4840.0
(cvunit '(1.0 2.5) "ft" "in")     returns (12.0 30.0)
(cvunit '(1 2 3) "ft" "in")     returns (12.0 24.0 36.0)

trans: function translates a point or a displacement from one coordinate system into another.
(trans pt from to [disp])
It takes a point argument, pt, that can be interpreted as either a 3D point or a 3D displacement vector, distinguished by a displacement argument called disp. The disp argument must be nonzero if pt is to be treated as a displacement vector; otherwise, pt is treated as a point. A from argument specifies the coordinate system in which pt is expressed, and a to argument specifies the desired coordinate system.
backBack top