The mscript runtime consists of a small set of functions at your disposal.
Once you master Programming, and these functions here, check out Database Programming.
You get the following math functions:
abs sqrt ceil floor round exp log log2 log10 sin cos tan asin acos atan sinh cosh tanh
Here are the basic functions:
number(input): attempts to convert any input into a number string(input): converts any input into a string; booleans become "true" and "false" getType(input): returns a string describing what kind of value its input is, like "number" or "string" or "bool" or "list" or "index" or "null" for the null value
collection.length(): returns number of characters in a string, or items in a list, or pairs in an index When I say "collection.something(...)", this is a shorthand for "something(collection, ...)". This shorthand only works for variables, so you can say... > my_list.length() ...but you cannot say... > list(1, 2, 3).length() Sorry, too tricky to parse. So you can either use a variable, or pass the expression into the function as its first parameter.: > length(list(1, 2, 3)) ...would print "3".
list(items): creates a new list, taking optional input items, like list(1, 2, 3)
index(pairs): creates a new index, taking an initial list of keys and values, each pair listed one after the other, like index("key1", "value1", "key2", "value2")
collection.add(items): appends new items to a list, and key-value pairs to an index. Sorry, no add'ing to strings, or even +=, just... & s = s + " to add" Maybe better to use a list and then use the join function later.
collection.get(key): access a character in a string by index, or an item in a list by index, or the value for the key in an index
collection.has(key): see if a substring is in a string, or an element is in a list, or an index has a key
index.keys(): returns a list of the keys of an index
index.values(): returns a list of the values of an index
collection.reversed(): return a copy of a string, list, or index in reverse order
collection.sorted(): return a copy of a string, list, or index in sorted order
collection.join(delimiter): take the items of a list or the keys of an index and join them into a string with a delimiter. Use index.values() to get a joined string of index values.
> join(list(1, 2, 3), ", ")
1, 2, 3
string.split(delimiter): take a string and split it into a list using a delimiter
> get(split("1, 2, 3", ", "), 1)
...would output 2.
string.toUpper(): return an uppercase copy of a string
string.toLower(): return a lowercase copy of a string
collection.firstLocation(item): return the first location in a string of a substring, or the index in a list of an item, or index in the keys of an index of an item. Think indexOf().
> firstLocation("foobar", "b")
...would output 3.
collection.lastLocation(item): return the last location in a string or list or keys of an index of an item. Think lastIndexOf().
> lastLocation("foobar", "a")
...would output 4. Think lastIndexOf.
collection.subset(start, length): returns a range of characters in a string or elements or keys in a list or an index, with a start location and a desired length. This substring().
> subset("foobar", 1, 3)
...would output "oob". This substring.
string.isMatch(pattern): returns whether a string matches a pattern, a .NET regular expression.
> isMatch("foobar", "^[a-z]+$")
...would output "true"
htmlEncode(input): return a copy of a string safe for including in HTML
> htmlEncode("< great! >") ...would output "< great! >" When working with < statements and the "inner" attribute, htmlEncode must be considered as the value is taken and output literally.
urlEncode(input): return a copy of a string safe for including in a URL
> urlEncode("foo bar")
...would output "foo%20bar" uniqueId(): return a globally unique string, Guid.NewGuid().ToString(). This is useful for database programming.
mscript does not have a data type dedicated to representing dates or times. Instead, it provides functions for working with strings that represent dates. Only dates are processed, keeping things simple.
today() returns a string representing the current day, in yyyy/MM/dd format.
string.year() returns the year part of the date represented by the string.
string.month() returns the month part of the date represented by the string.
string.day() returns the day part of the date represented by the string.
string.addDays(numberOfDays) returns a new string representing the date of the string with the number of days added. numberOfDays can be positive or negative, but must be a whole number, nothing after the decimal point.
daysBetween(dateString1, dateString2) returns the number of days between the first and second argument, like dateString1 - dateString2. string.toPrettyDate() returns the full format of the data, "January 1, 1970"
Those are all of the functions of the mscript programming system...except for Database Programming.