sdleiF | ||
string ESC RO | Escape character | |
string NBSP RO | Non-breaking space character | |
string SERIALIZATION_PREFIX RO | Serialization prefixString prefix used in the Framsticks file format to indicate object fields that contain serialized objects. | |
snoitcnuF | ||
function char(int)returns string | Character from ASCII | |
function code(string)returns int | ASCII code of the character | |
function deserialize(string)returns untyped | DeserializeExtracts objects from textual representation. Error object is returned if deserialization fails. Example: var ret=String.deserialize(something); if (typeof(ret)=="Error") Simulator.print("something is wrong: "+ret.message); | |
function diff(string, string)returns Vector | Calculate string differenceReturns the vector of minimal differences between two strings. The vector contains either 2-element subvectors with differing substrings ["text-1","text-2"] or strings "same". For example, String.diff("thisisatest", "testing123testing") returns [t,[hi,e],s,[,t],i,[sa,ng123],test,[,ing]]. Use this function for short strings, as it requires 4*length(string1)*length(string2) bytes of memory. | |
function endsWith(string string, string substring)returns int | Test if ends with substring | |
function format(string format_string, untyped value_or_vector)returns string | Formatted string conversionWorks like the standard C library "sprintf()". The '%' operator can be used as a shortcut, e.g. String.format("%x",123) is equivalent of "%x" % 123 Character seqences beginning with % found in the format string are replaced by formatted values produced according to their corresponding format specifiers: %[-][+][0][width[.precision]]type -: left adjust (default is right adjust) +: place a sign (+ or -) before a number 0: the value should be zero padded width: minimum field width precision: minimum number of decimal digits type: d=decimal integer, x/X=hexadecimal integer, f/g=floating point number, e="scientific" style floating point, c=character of a given ascii code, t=time, %=special case, outputs the literal % character Multiple values can be formatted in one call, by passing a vector as the second argument: String.format("a=%03d b=%.2f c=%s",[a,b,c]) or "a=%03d b=%.2f c=%s" % [a,b,c] Alternatively, if no % characters are required in the output string, the chained call can be used: "a=%03d b=%.2f c=%s" % a % b % c The above expression works as expected, because, unlike the regular sprintf, the formatting function preserves % characters left after using all input arguments: input: "a=%03d b=%.2f c=%s" % a % b % c actual meaning: (("a=%03d b=%.2f c=%s" % a) % b) % c phase 1: ("a=000 b=%.2f c=%s" % b) % c phase 2: "a=000 b=0.00 c=%s" % c result: "a=000 b=0.00 c=0" Examples: String.format("|%07.2f|",Math.pi) == "|0003.14|" String.format("|%04x|",255) == "|00ff|" String.format("|%7s|","text") == "| text|" String.format("|%-7d|",12345) == "|12345 |" String.format("%t",Math.time) == "Sun Apr 29 19:22:02 2007" String.format("%T",Math.time) == "2007-05-29 19:22:02" String.format("x=%d%%",100) == "100%" | |
function hash(string)returns int | Compute 32-bit hash | |
function indexOf(string, string substring)returns int | Search for substringString.indexOf("abcdef","cd") == 2 String.indexOf("abcdef","dc") == -1 | |
function indexOfStart(string, string substring, int start_index)returns int | Search for substringString.indexOfStart("abcdef","cd",1) == 2 String.indexOfStart("abcdef","cd",3) == -1 | |
function left(string, int number_of_characters)returns string | Left substringString.left("abcdef",3) == "abc" | |
function len(string)returns int | String lengthString.len("abcdef") == 6 | |
function parseFloat(string)returns float | Parse floating pointIf the supplied string is not a number, returns 0.0 and posts an error message. | |
function parseInt(string)returns int | Parse integerIf the supplied string is not an integer, returns 0 and posts an error message. | |
function parseNumber(string)returns untyped | Parse integer or floating pointReturns an integer, a floating point, or null if the string cannot be parsed as a number. The 'typeof' operator can be used to distinguish between an integer and a floating point value: typeof(String.parseNumber("qwerty")) == "null" typeof(String.parseNumber("1234")) == "int" typeof(String.parseNumber("3.14")) == "float" | |
function quoteEof(string)returns string | quote eofAdd leading backslash to lines containing just 'eof' (or previously quoted 'eof') (for use in the network protocol implementation) | |
function replace(string input_string, string search, string substitute)returns string | ReplaceString.replace("abcdef","cd","X") == "abXef" | |
function right(string, int number_of_characters)returns string | Right substringString.right("abcdef",3) == "def" | |
function serialize(untyped)returns string | SerializeConverts to textual representation, preserving object hierarchy. | |
function split(string text_to_split, string word_separator)returns Vector | Splitreturn the vector of substrings, cut at separator positions. subsequent separators give empty words: split("word1---word2-word3","-") returns ["word1","","","word2","word3"] | |
function split2(string text_to_split, string word_separator)returns Vector | Split, merging separators firstreturn the vector of substrings, cut at separator positions. subsequent separators are treated as one: split2("word1---word2-word3","-") returns ["word1","word2","word3"] | |
function startsWith(string string, string substring)returns int | Test if starts with substring | |
function substr(string, int first_character, int number_of_characters)returns string | SubstringString.substr("abcdef",3,2) == "de" | |
function substr(string, int first_character)returns string | substringString.substr("abcdef",3) == "def" | |
function toJSON(untyped)returns string | JSON serializationExports to JSON format, preserving object hierarchy (excluding recursion). | |
function toLower(string)returns string | Make lowercase version | |
function toUpper(string)returns string | Make uppercase version | |
function trim(string)returns string | Removes whitespace from both sides of a string. | |
function unquoteEof(string)returns string | unquote eofRemove one level of backslash quoting from lines containing quoted 'eof' (for use in the network protocol implementation) | |
function urlDecode(string)returns string | URL decode | |
function urlEncode(string)returns string | URL encode |
Global context |