back to index

String

Inheritance

Object -> String

Properties

length - number of chars (including ASCIIZ)

Methods

            abbrev                  (int _length)                   - abbreviate the string so that it becomes _length chars long (without ASCIIZ)
int         alloc                   (int _num)                      - allocate string buffer
            append                  (Object | String _s)            - append string _s resp. convert generic object to string and append it.
int         charsetIndexOf          (String _charset, int _off)     - return index of character that matches any character in 
                                                                      _charset or -1
boolean     compare                 (String _src)                   - compare this string to _src (same as ==)
boolean     compareIgnoreCase       (String _src)                   - case insensitive comparison with _src 
            copy                    (String _src)                   - copy string _s
            deleteRegion            (int _off, int _num)            - remove given region from this string.
            empty                   ()                              - reset the number of used chars in the string buffer
int         endsWith                (String _s)                     - test if string ends with _s
            free                    ()                              - free char sequence 
            freeStack               ()                              - free string stack (successive to words(), split()) 
int         getc                    (int _off)                      - get a single char, you can also use the [] operator, e.g. s[1]
int         getLength               ()                              - number of chars including ASCIIZ
String      getString               ()                              - return "string"
String      getWord                 (int _nr)                       - return an element from the string stack
int         indexOf                 (String _s, int _startoff)      - return offset of first occurence of String _s
int         indexOfChar             (int _c, int _startoff)         - return offset of first occurence of char _c
int         indexOfControlCharacter (int _off)                      - return index of character 
                                                                      less or equal than ASCII ' ' (32) or -1
int         indexOfWordStart        (int _off)                      - return start index of word at index _off
int         indexOfWordEnd          (int _off)                      - return end index of word at index _off
            insert                  (int _off, Object | String _s)  - insert string _s at the given offset resp. convert generic object to string then insert it
int         isBlank                 ()                              - return true if string only contains blank characters 
                                                                      (whitespace,newline,tab) 
int         lastIndexOf             (String _s)                     - return offset of last occurence of _s
int         load                    (String _name, int _b_ascii)    - load a file from the VFS, 
                                                                      replace MS-DOS carriage return by ' ' if _b_ascii==1
int         loadLocal               (String _name, int _b_ascii)    - load a local file, replace MS-DOS carriage return by ' ' if _b_ascii==1
String      New                     (String _s)                     - return a copy of _s
int         numIndicesOf            (String _s)                     - count number of occurences of _s
TreeNode    parseXML                ()                              - parse XML-style file and create tree of hashtables
int         patternMatch            (String _p)                     - match String to "wild card" pattern, '*' 
                                                                      substitutes 0..n character, 
                                                                      '?' matches exactly one character
            putc                    (int _off, int _c)              - alternative call to set a char, you may also use s[1]='a';
int         realloc                 (int _num)                      - re-allocate string buffer. preserve previous content if possible.
int         replace                 (String _s, String _t)          - replace all occurences of _s by _t
int         replaceChar             (int _a, int _b)                - replace all occurences of _a by _b. if b is 0 then delete all occurences of a.
int         replaceIncludes         (YAC_String *_filePrefix)       - replace `/some/file` by actual file content. Return number of replacements or -1 if the local file coult not be opened.
            replaceRegion           (int _startOff, int _endOff, String _s) - replace the given region by String _s
int         saveLocal               (String _name)                  - save string to local file
int         split                   (int _char)                     - split string at each occurence of _char and create string stack
StringArray splitSpace              (int _includeembeddedstrings)   - split string into words and return string array
StringArray splitChar               (int _char)                     - split string at _char and return string array
StringArray splitCharset            (String _charset)               - split string at any char in _charset and return string array
int         startsWith              (String _s)                     - test if string starts with substring _s
            substring               (String _d, int _off, int _len) - extract a substring 
            toLower                 ()                              - convert chars to lower case
            toUpper                 ()                              - convert chars to upper case
            trim                    ()                              - strip leading/trailing blanks
            visit                   (String _s, int _off, int _len) - create a view into string _s (i.e. share char buffer)
int         words                   (int _includeembeddedstrings)   - split string into words, create string stack 
                                                                      and return number of words

Example

int n=40000;
String str="";
loop(n)
   str.append("hello\n");
int len = str.length; 

Example


back to index