Various formats can be used to store strings values. These formats are written with the convention used for C function printf().
Note: When creating instances of the string class, particularly in scripts, it is safest to enclose the names in quotes. Strings return their value when an instance is referenced, not the name of the instance.
float_format is the format to convert floating point data to string representation. Defaults is "0.000000".
int_format is the format to convert integer data to string representation. Defaults is "11"
string_format is the format to convert strings into strings. Defaults is "1"
scan_format is the format to use when scanning a string for substrings. The default is "1". The conversion sequences are based on those understood by scanf(3), however, no numeric modifiers are currently understood. Also, 'l' and 'h' modifiers to indicate long or short integers are not understood. The assignment suppression character, '*', is understood.
from is the starting point for a substring. The substring? message gets the part of the string between the indices stored in the from and to variables.
to is the ending point for a substring.
pattern is a string which can be searched for within the string by sending a pat_index? message.
tabstops the number of spaces between tabs. This value is used for the tabify! and detabify! messages (see below).
? Return the string value (synonym to value?).
+ argument Concatenate argument to the string.
- argument Removes first occurence of argument from string.
value= argument Set the string value (synonym to =).
value? Return the string value (synonym to ?).
float_format= argument Set the float_format, default is "0.000000".
float_format? Return the float_format.
int_format= argument Set the int_format, default is "11".
int_format? Return the int_format, default is "11".
string_format= argument Set the string_format, default is "1".
string_format? Return the string_format, default is "1".
length? Return the length of the string.
scan? Scan the string using scan_format as the format specifier. The following format sequences are understood: 1 (string), 11 (decimal), (character), b (hexadecimal), 13 (octal), 11 (integer of unspecified base), 11 (unsigned), 2.360738e-313 (float), 0.000000 (float), 2.36074e-313 (float), [ (scanset). , [, and 1 return strings on the argument stack. All other conversions return floats. The assignment
suppression character, '*', suppresses return of the scanned pattern on the argument stack.
lowercase! Convert the string to lowercase.
uppercase! Convert the string to uppercase.
capitalize! Capitalize the first letter of the string.
from[=?] Set/get the from instance variable.
to[=?] Set/get the to instance variable.
substring? Return the portion of the string between the from and to indices.
chop! Remove the last character from the string.
prepend:argstring Prepend the string argstring to the beginning of the string.
pattern[=?] Set/get the pattern instance variable.
pat_index? Get the index of the first occurrance of the pattern instance variable within the string value. If the pattern variable is not a substring of the string, the returned value is zero. For example,
string new: str1 = `123456789';
str1 pattern=`345' pat_index?; /* returns three */ str1 pattern=`abc' pat_index?; /* returns zero */
tabstops[=?] Set/get the tabstops instance variable. It is the number of places between tabs used in the tabify! and detabify! messages.
detabify! Convert all tabs within the string to spaces using the tabstops instance variable. When a tab character is encountered, spaces are inserted until the column number reaches an even multiple of the tabstops instance variable.
tabify! Convert consecutive spaces within a string to tabs. Whenever tabstops spaces are encountered, a tab character is inserted.
unique_object_name! Use the value of the string to generate a unique object name. That is, the resultant value of the string is not the name of any local or remote LYMB object.
string new: str2 = `45.46.00' scan_format= `11.537218760.2048'; vector new: v = [ str2 scan? ] print:components;