This file documents the LoLa Runtime Library, a set of basic I/O routines to enable standalone LoLa programs.
The API in this document is meant for the standalone LoLa interpreter and functions listed here are not necessarily available in embedded programs!
Exit(code: number): noreturnThis function will stop execution of the program and will return code to the OS.
ReadFile(path: string): string|voidReads in the contents of a file located at path as a string or returns void when the file does not exist or the given path is not a file.
WriteFile(path: string, contents: string): voidWrites contents to the file located at path. If the file does not exist, it will be created.
FileExists(path: string): booleanReturns true if a file exists at the given path, else otherwise.
Print(…): voidWill print every argument to the standard output. All arguments of type string will be printed verbatim, non-string arguments are converted into a human-readable form and will then be printed.
After all arguments are printed, a line break will be outputted.
ReadLine(): string|voidReads a line of text from the standard input and returns it as a string. If the standard input is in the end of file state, void will be returned.
CreateList([init: array]): objectReturns a new object that implements a dynamic list.
If init is given, the list will be initialized with the contents of init.
This list has the following API:
list.Add(item): voidAppends a new item to the back of the list.
list.Remove(item): booleanRemoves all occurrances of item in the list.
list.RemoveAt(index): voidRemoves the item at index. Indices start at 0. When the index is out of range, nothing will happen.
list.GetCount(): numberReturns the current number of elements in the list.
list.GetItem(index): anyReturns the item at index or panics with OutOfRange;
list.SetItem(index, value): voidReplaces the item at index with value.
list.ToArray(): arrayReturns the current list as an array.
list.IndexOf(item): numberReturns first the index of item in the list or void if the item was not found.
list.Resize(size): voidResizes the list to size items. New items will be set to void.
list.Clear(): voidRemoves all items from the list.
CreateDictionary(): objectReturns a new object that implements a key-value store.
dict.Get(key): anyReturns the value associated with key or returns void if key does not have a associated value.
dict.Set(key, value): voidSets the associated value for key to value. If value is void, the key will be removed.
dict.Remove(key): booleanRemoves any value associated with key. Returns true when a key was removed else false.
dict.Contains(key): booleanReturns true if the dictionary contains a value associated with key.
dict.GetKeys(): arrayReturns an array with all keys stored in the dictionary.
dict.GetValues(): arrayReturns an array with all values stored in the dictionary.
dict.Clear(): voidRemoves all values from the dictionary.
dict.GetCount(): numberReturns the number of keys currently stored in the list.