String


Overview

The data type for strings. The default value is the empty string.



Operations
asBool():Boolean Converts a string into a Boolean provided it has the string value true or false. String can be lower or upper case. An exception is raised if the string is invalid.
asFloat():Float Converts a string into a Float. It splits the string on its decimal point, converts the two strings into integers and passes them to the Float constructor. An execption is raised if the result is not a Float.
asHTML():String Transforms a string literal to HTML replacing any illegal HTML characters so that the string is faithfully printed.
asInt():Integer Converts a string into an Integer. Raises an exception if it cannot be converted.
asSeq():Seq(Integer) Converts a string into a sequence of 8-bit character codes.
asSet():Set(Integer) Converts a string into a set of character codes.
asSymbol():Symbol Converts a string into a Symbol. In general, symbols can be processed more efficiently than strings, e.g. as indexes in table lookups.
asXML():ElementNo Documentation Specified
at(i:Integer):Integer Returns the ith character in a string starting from position 0.
copyFile(file:String):Boolean Copies the contents of the file named by the receiver into the file passed as an argument. The target file is created if necessary.
default():Element Returns the default value for a string: the empty string
deleteFile():Boolean Deletes the file given by a string path. Raises an exception if the file does not exist or cannot be deleted.
drop(n:Integer):Element Removes the first i elements from a string.
exec(args:Seq(String)):Element Currently not supported.
fileExists():Boolean Returns true if the file given by a string path exists, otherwise false.
fileSize():Integer Returns the size of a file given by a string path.
getLastModified():StringNo Documentation Specified
greater(other:String):Boolean Returns true if a string is greater than the supplied string. The strings are compared alphabetically.
hasPrefix(prefix:String):Boolean Returns true if a string is prefixed by the string, prefix.
hasSuffix(suffix:String):Boolean Returns true if a string has a suffix, suffix.
indexOf(char:String):Integer Returns the index of a character, char in a string.
indexOf(pattern:String,start:Integer):ElementNo Documentation Specified
isBool():Boolean Returns true when the receiver is either true or false.
isDir():Boolean Returns true when the receiver is a directory.
isOlder(file:String):Boolean Compares the last modified date of the file referenced by a string path with file. Returns true if file is older.
isReadOnly():Boolean Returns true when the receiver is a read-only file.
isValidName():String Returns true if the name is valid, i.e. it only contains valid alpha and numeric characters (and underscore) and starts with a letter.
less(other:String):Boolean Returns true if a string is less than the supplied string. The strings are compared alphabetically.
lift():PerformableNo Documentation Specified
loadBin(verbose:Boolean):Element Load the binary for the file referenced by a string path. Displays loading information if verbose is true. Raises an exception if it does not exist.
loadBin():Element Load the binary for the file referenced by a string path. Raises an exception if it does not exist.
lookup():Element Returns the value of the dynamic variable with the name defined by self or raises an error otherwise.
lookupPath(nameSpace:NameSpace):NamedElement Receiver should be a path X::Y::Z. Result is the value of the path with respect to the supplied name space or null.
lowerCase():String Returns the lower case equivalent of the string.
lowerCaseInitialLetter():String Makes the first letter of a string lower case.
mkDir():Boolean Creates a directory. Returns true when the directory already exists or is successfully created. Returns false when the directory cannot be created.
padFrom(width:Integer,char:Integer):String Pads ups to a string with additional character codes up to width.
padTo(width:Integer,char:Integer):String Pads after a string with additional character codes up to width.
parentDir():String Returns the parent directory of the file referenced by a string path. Returns an exception if it cannot be found.
parseAndEval():Element The receiver should be a valid XOCL expression. It is parsed and the result abstract syntax is evaluated.
readFile():String Reads the file referenced by a string path, provided that it exists.
renameFile(newName:String):Boolean Renames a file referenced by a string path. A rename is only performed if the file exists and there doesnt exist a file with the new name.
repeat(n:Integer):Element Duplicates a string the given number of times.
replaceUnderscoresWithSpaces():ElementNo Documentation Specified
reverse():String Reverses the characters in a string.
setFileLastModified(time:Time):Boolean Sets the last modified date of the file to the supplied instance of Time. Returns true when the update was successful.
size():Integer Returns the size of a string.
splitBy(chars:String,start:Integer,last:Integer):Seq(String) Splits a string into a sequence of strings around some characters. The variables start and last can be used to filter the returned string by returning the characters from start to last. Setting start and last to 0 will return the whole string.
stripIllegalChars():String Strips all illegal characters from a string.
stripInvalidNameChars():String Returns the string resulting be removing all invalid name characters, i.e. those that are not alpha-numeric characters or the underscore character.
stripLeadingWhiteSpace():String Strips any leading whitespace from a string.
stripNonAlphaChars():String Strips all non-alphanumeric characters from a string.
stripTrailingWhiteSpace():String Strips any trailing whitespace from a string.
stripWhiteSpace():String Strips any leading and trailing whitespace from a string.
subString(firstChar:String,pastLastChar:String):String Uses indices to chop up a string. The first index is the starting character and the second index is 1+ the final character.
subst(new:String,old:String,all:Boolean):Element Substitutes the string old in a string with new. If all is set to false, just replaces the first occurrence. If true replaces them all.
toFilePath(directory:Directory,path:Seq(String)):ElementNo Documentation Specified
toFilePath():ElementNo Documentation Specified
toLower():String Converts all characters in a string to lower case.
toString():String Translates the receiver into a string.
toUpper():String Converts all characters in a string to upper case.
truncate(width:Integer):String Truncates a string by width characters.
upperCaseInitialLetter():String Makes the first letter of a string upper case.