|
|
(23 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| === Programmer's Guides === | | === Complete list of var, dim and exoprog functions === |
| | |
| | [[Functions]] |
|
| |
|
| === ICONV/OCONV PATTERNS === | | === ICONV/OCONV PATTERNS === |
|
| |
|
| |
|
| ==== Decimal (MD/MC) ==== | | ==== Decimal (MD/MC) ==== |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0" | | {|class="wikitable" |
| !input!!conversion (string)!!output | | !input!!conversion (string)!!output |
| |- | | |- |
Line 34: |
Line 35: |
| ==== Date (D) ==== | | ==== Date (D) ==== |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0" | | {|class="wikitable" |
| !input!!conversion (string)!!output | | !input!!conversion (string)!!output |
| |- | | |- |
Line 74: |
Line 75: |
| ==== Time (MT) ==== | | ==== Time (MT) ==== |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0" | | {|class="wikitable" |
| !input!!conversion (string)!!output | | !input!!conversion (string)!!output |
| |- | | |- |
Line 96: |
Line 97: |
| ==== Hex (HEX/MX) ==== | | ==== Hex (HEX/MX) ==== |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0" | | {|class="wikitable" |
| !input!!conversion (string)!!output | | !input!!conversion (string)!!output |
| |- | | |- |
Line 120: |
Line 121: |
| ==== Text (L/R/T) ==== | | ==== Text (L/R/T) ==== |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0" | | {|class="wikitable" |
| !input!!conversion!! (string)output | | !input!!conversion!! (string)output |
| |- | | |- |
Line 146: |
Line 147: |
| Exodus dictionaries enable classic multivalue database data definition. Dictionaries are just normal Exodus multivalue files that contain one record for each data column definition. You can use Exodus's edir program to manually edit dictionaries. | | Exodus dictionaries enable classic multivalue database data definition. Dictionaries are just normal Exodus multivalue files that contain one record for each data column definition. You can use Exodus's edir program to manually edit dictionaries. |
|
| |
|
| Dictionary file names must start with the word "dict.". For example, if you have a "books" file, then you will probably have a "dict.books" file. | | Dictionary file names must start with the word "dict_". For example, if you have a "books" file, then you will probably have a "dict_books" file. |
|
| |
|
| You can list the contents of a dictionary by typing "list dict.filename". | | You can list the contents of a dictionary by typing "list dict_filename". |
|
| |
|
| ==== Exodus Dictionary Format ==== | | ==== Exodus Dictionary Format ==== |
Line 216: |
Line 217: |
| } ... | | } ... |
| </pre> | | </pre> |
| | |
| | === Functions and Commands === |
| | |
| | ==== String Commands ==== |
| | |
| | Most string functions like trim() that return a new modified string have a corresponding modify in place command like function like trimmer() that is is usually much faster. |
| | So we have convert and converter, replace and replacer, insert and inserter and so on. |
| | |
| | Therefore by preference use |
| | |
| | trimmer(v1); |
| | // or |
| | v1.trimmer() |
| | |
| | instead of |
| | |
| | v1 = trim(v1); |
| | // or |
| | v1 = v1.trim(); |
|
| |
|
| ==== Function Types ==== | | ==== Function Types ==== |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0" | | {|class="wikitable" |
| !TYPE !!FUNCTION TYPE|| | | !TYPE !!FUNCTION TYPE|| |
| |- | | |- |
Line 233: |
Line 253: |
| ==== Parameters/Argument Types ==== | | ==== Parameters/Argument Types ==== |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0" | | {|class="wikitable" |
| |in|| Parameters that provide data to the function. Can be variables or raw data like 1 or "X"|| | | |in|| Parameters that provide data to the function. Can be variables or raw data like 1 or "X"|| |
| |- | | |- |
Line 246: |
Line 266: |
| Optional Parameters | | Optional Parameters |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0" | | {|class="wikitable" |
| !Key !!Default|| | | !Key !!Default|| |
| |- | | |- |
| |="" ||""|| | | |= "" ||""|| |
| |-
| |
| |=" " ||" "||
| |
| |-
| |
| |="." ||"."||
| |
| |-
| |
| |=1 ||1 ||
| |
| |-
| |
| |=0 ||0||
| |
| |-
| |
| |=true ||true||
| |
| |-
| |
| |=false ||false||
| |
| |}
| |
| | |
| ==== Complete List of Functions ====
| |
| | |
| | |
| | |
| ===== Math/Boolean =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.abs()||var(-12.34) -> 12.34
| |
| |-
| |
| |var=||var.pwr(exponent)||var(2).pwr(8) -> 256;
| |
| |-
| |
| |var=||var.rnd()||var(100).rnd() -> 0 to 99 pseudo random
| |
| |-
| |
| |cmd||var.initrnd()||var(123).initrnd() Set pseudo random seed to 123
| |
| |-
| |
| |var=||var.exp()||var(1).exp() -> 2.718281828459045
| |
| |-
| |
| |var=||var.sqrt()||var(100).sqrt() -> 10
| |
| |-
| |
| |var=||var.sin()||var(30).sin() -> 0.5
| |
| |-
| |
| |var=||var.cos()||var(60).cos() -> 0.5
| |
| |-
| |
| |var=||var.tan()||var(45).tan() -> 1
| |
| |-
| |
| |var=||var.atan()||var(1).atan() -> 45
| |
| |-
| |
| |var=||var.loge()||var(2.718281828459045).loge() -> 1
| |
| |-
| |
| |var=||var.integer()||truncate towards zero.<br>var(2.9).integer() -> 2, var(-2.9).integer -> -2
| |
| |-
| |
| |var=||var.floor()||truncate towards negative<br>var(2.9).floor() -> 2, var(-2.9).floor() -> -3
| |
| |-
| |
| |var=||var.round(ndecimals = 0)||var(23.455).round(2) -> "23.46"
| |
| |-
| |
| |var=||var.mod(divisor)||symmetrical remainder function<br>[0 , limit) if limit is positive<br>(limit, 0] if limit is negative
| |
| |}
| |
| | |
| ===== Locale =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |expr||var.getxlocale()||var().getxlocale() -> "en_US.utf8"
| |
| |-
| |
| |if||var.setxlocale()||"de_DE.utf8"_var.setxlocale() -> true if successful
| |
| |}
| |
| | |
| ===== String Creation =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.chr(num)||var().chr(255) -> "\xFF"
| |
| |-
| |
| |var=||var.textchr(num)||UTF8 code points, var().textchr(171416) -> "𩶘" -> "\x{F0A9B698}");
| |
| |-
| |
| |var=||var.str(num)||"ab"_var.str(3) -> "ababab"
| |
| |-
| |
| |var=||var.space()||var(3).space() -> "␣␣␣"
| |
| |-
| |
| |var=||var.numberinwords(languagename_or_locale_id = "")||var(123.45).numberinwords("de_DE").outputl()<br>-> "einhundertdreiundzwanzig Komma vier fünf"
| |
| |}
| |
| | |
| ===== String Info =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.seq()||Decimal number of first char.<br>"abc"_var.seq() -> 61
| |
| |-
| |
| |var=||var.textseq()||Decimal number of first unicode code point.<br>"Γ"_var.textseq() -> 915 U+0393: Greek Capital Letter Gamma (Unicode Character)
| |
| |-
| |
| |var=||var.len()||Length of text in chars (bytes)
| |
| |-
| |
| |var=||var.textwidth()||Number of output columns on terminal. Not accurate in many cases.
| |
| |}
| |
| | |
| ===== String Scanning =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.textlen()||Length of text in unicode code points<br>"Γιάννης"_var.textlen() -> "7"
| |
| |-
| |
| |var=||var.fcount(sepstr)||Number of fields separated by sepstr present<br>"a1*b2*c3"_var.fcount("*") -> 3
| |
| |-
| |
| |var=||var.count(sepstr)||Number of sepstr found<br>"a1*b2*c3"_var.count("*") -> 3;
| |
| |-
| |
| |var=||var.match(regex, regex_options = "")||Returns results of regex matching with multiple matches in fields and any groups in multivalues<br>"abc1abc2"_var.match("bc(\\d)"_rex) -> "bc1]1^bc2]2"
| |
| |-
| |
| |var=||var.match(regex)||Ditto
| |
| |-
| |
| |if||var.starts(prefix)||True if starts with prefix<br>"abc"_var.starts("ab") -> true
| |
| |-
| |
| |if||var.ends(suffix)||True if ends with suffix<br>"abc"_var.ends("bc") -> true
| |
| |-
| |
| |if||var.contains(substr)||True if starts, ends or contains substr<br>"abcd"_var.contains("bc") -> true
| |
| |-
| |
| |var=||var.index(substr, startchar1 = 1)||return byte no if found or 0 if not. startchar1 is byte no to start at.<br>"abcd"_var.index("bc") -> 2
| |
| |-
| |
| |var=||var.indexn(substr, occurrence)||ditto. occurrence 1 = find first occurrence<br>"abcabc"_var.index("bc", 2) -> 5
| |
| |-
| |
| |var=||var.indexr(substr, startchar1 = -1)||ditto. reverse search. startchar1 -1 starts from the last byte<br>"abcabc"_var.indexr("bc") -> "5"
| |
| |-
| |
| |var=||var.search(regex, io startchar1, regex_options = "")||Returns the first match given a starting point and startchar1 set ready for the next search<br>var startchar1 = 1; "abc1abc2"_var.search("bc(\\d)", startchar1) -> "bc1]1" and startchar1 becomes 5 ready for the next search
| |
| |-
| |
| |var=||var.search(regex)||Ditto just finds the first match from the beginning
| |
| |-
| |
| |var=||var.search(regex, io startchar1)||Ditto given a rex
| |
| |-
| |
| |var=||var.search(regex)||Ditto just finds the first match from the beginning
| |
| |}
| |
| | |
| ===== String Conversion - Non-Mutating =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.ucase()||Upper case<br>"Γιάννης"_var.ucase() -> "ΓΙΆΝΝΗΣ"
| |
| |-
| |
| |var=||var.lcase()||Lower case<br>"ΓΙΆΝΝΗΣ"_var.lcase() -> "γιάννης"
| |
| |-
| |
| |var=||var.tcase()||Title case (first letters)<br>"γιάννης"_var.tcase()="Γιάννης"
| |
| |-
| |
| |var=||var.fcase()||Fold case (lower case and remove accents for indexing)
| |
| |-
| |
| |var=||var.normalize()||Normalise Unicode to NFC to eliminate different code combinations of the same character
| |
| |-
| |
| |var=||var.invert()||Simple reversible disguising of text<br>"abc"_var.invert() -> "\x{C29EC29DC29C}"
| |
| |-
| |
| |var=||var.lower()||Convert all FM to VM, VM to SM etc.<br>"a1^b2^c3"_var.lower() -> "a1]b2]c3"
| |
| |-
| |
| |var=||var.raise()||Convert all VM to FM, SM to VM etc.<br>"a1]b2]c3"_var.raise() -> "a1^b2^c3"
| |
| |-
| |
| |var=||var.crop()||Remove any redundant FM, VM etc. characters (Trailing FM; VM before FM etc.)<br>"a1^b2]]^c3^^"_var.crop() -> "a1^b2^c3"
| |
| |-
| |
| |var=||var.quote()||Wrap in double quotes<br>"abc"_var.quote() -> ""abc""
| |
| |-
| |
| |var=||var.squote()||Wrap in single quotes<br>"abc".squote() -> "'abc'"
| |
| |-
| |
| |var=||var.unquote()||Remove one pair of double or single quotes<br>"'abc'"_var -> "abc"
| |
| |-
| |
| |var=||var.trim(trimchars = " ")||Remove leading, trailing and excessive inner bytes<br>"␣␣a1␣␣b2␣c3␣␣"_var.trim() -> "a1␣b2␣c3"
| |
| |-
| |
| |var=||var.trimfirst(trimchars = " ")||Ditto leading<br>"␣␣a1␣␣b2␣c3␣␣"_var.trimfirst() -> "a1␣␣b2␣c3␣␣"
| |
| |-
| |
| |var=||var.trimlast(trimchars = " ")||Ditto trailing<br>"␣␣a1␣␣b2␣c3␣␣")_var.trimlast() -> "␣␣a1␣␣b2␣c3"
| |
| |-
| |
| |var=||var.trimboth(trimchars = " ")||Ditto leading, trailing but not inner<br>"␣␣a1␣␣b2␣c3␣␣")_var.trimboth() -> "a1␣␣b2␣c3"
| |
| |-
| |
| |var=||var.first()||Extract first char or "" if empty<br>"abc"_var.first() -> "a"
| |
| |-
| |
| |var=||var.last()||Extract last char or "" if empty<br>"abc"_var.last() => "c"
| |
| |-
| |
| |var=||var.first(std::size_t length)||Extract up to length leading chars<br>"abc"_var.first(2) -> "ab"
| |
| |-
| |
| |var=||var.last(std::size_t length)||Extract up to length trailing chars<br>"abc"_var.last(2) -> "bc"
| |
| |-
| |
| |var=||var.cut(length)||Remove length leading chars<br>"abcd"_var.cut(2) -> "cd"
| |
| |-
| |
| |var=||var.paste(pos1, length, insertstr)||Insert text at char position overwriting length chars<br>"abcd"_var.paste(2, 2, "XYZ") -> "aXYZd"
| |
| |-
| |
| |var=||var.paste(pos1, insertstr)||Insert text at char position without overwriting any following characters<br>"abcd"_var.paste(2, "XYZ") -> "aXYbcd"
| |
| |-
| |
| |var=||var.prefix(insertstr)||Insert text at the beginning<br>"abc"_var.prefix("XY") -> "XYabc"
| |
| |-
| |
| |var=||var.pop()||Remove one trailing char<br>"abc"_var -> "ab"
| |
| |-
| |
| |var=||var.fieldstore(separator, fieldno, nfields, replacement)||Replace nfields of subfield(s) in a string.<br>"aa*bb*cc*dd"_var.fieldstore("*", 2, 3, "X*Y") -> "aa*X*Y*"<br>If nfields is 0 then insert fields before fieldno<br>"a1*b2*c3*d4"_var.fieldstore("*", 2, 0, "X*Y") -> "a1*X*Y*b2*c3*d4"<br>If nfields is negative then delete nfields before inserting.<br>"a1*b2*c3*d4"_var.fieldstore("*", 2, -3, "X*Y") -> "a1*X*Y"
| |
| |-
| |
| |var=||var.substr(startindex1, length)||substr version 1. Extract length chars starting at startindex1<br>"abcd"_var.substr(2, 2) -> "bc"<br>If length is negative then work backwards and return chars reversed<br>"abcd"_var.substr(3, -2) -> "cb"
| |
| |-
| |
| |var=||var.substr(startindex1)||substr version 2. Extract all chars from startindex1 up to the end<br>"abcd"_var.substr(2) -> "bcd"
| |
| |-
| |
| |var=||var.b(pos1, length)||Same as substr version 1.
| |
| |-
| |
| |var=||var.b(pos1)||Same as substr version 2.
| |
| |-
| |
| |var=||var.convert(fromchars, tochars)||Convert chars to other chars one for one or delete where tochars is shorter.<br>"abcde"_var.convert("aZd", "XY") -> "Xbce" (a is replaced and d is removed)
| |
| |-
| |
| |var=||var.textconvert(fromchars, tochars)||Ditto for Unicode code points.
| |
| |-
| |
| |var=||var.replace(fromstr, tostr)||Replace all occurrences of a substr with another. Case sensitive
| |
| |-
| |
| |var=||var.replace(regex, tostr)||Replace substring(s) using a regular expression.<br>Use $1, $2 in tostr to refer to groups defined in the regex.
| |
| |-
| |
| |var=||var.unique()||Remove duplicate fields in an FM or VM etc. separated list<br>"a1^b2^a1^c2"_var.unique() -> "a1^b2^c2"
| |
| |-
| |
| |var=||var.sort(sepchar = FM)||Reorder fields in an FM or VM etc. separated list in ascending order<br>"20^10^2^1^1.1"_var.sort() -> "1^1.1^2^10^20"<br>"b1^a1^c20^c10^c2^c1^b2"_var.sort() -> "a1^b1^b2^c1^c10^c2^c20"
| |
| |-
| |
| |var=||var.reverse(sepchar = FM)||Reorder fields in an FM or VM etc. separated list in descending order<br>"20^10^2^1^1.1"_var.reverse() -> "1.1^1^2^10^20"
| |
| |-
| |
| |var=||var.shuffle(sepchar = FM)||Randomise the order of fields in an FM, VM separated list<br>"20^10^2^1^1.1"_var.shuffle() -> "2^1^20^1.1^10" (random order depending on initrand())
| |
| |-
| |
| |var=||var.parse(char sepchar = ' ')||Replace separator characters with FM char except inside double or single quotes ignoring escaped quotes \\" \&squot;<br>"abc,\"def,\"123\" fgh\",12.34"_var.parse(',') -> "abc^"def,"123" fgh"^12.34"
| |
| |}
| |
| | |
| ===== String Mutators (All Similar To Non-Mutators) =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |cmd||var.ucaser()||
| |
| |-
| |
| |cmd||var.lcaser()||
| |
| |-
| |
| |cmd||var.tcaser()||
| |
| |-
| |
| |cmd||var.fcaser()||
| |
| |-
| |
| |cmd||var.normalizer()||
| |
| |-
| |
| |cmd||var.inverter()||
| |
| |-
| |
| |cmd||var.quoter()||
| |
| |-
| |
| |cmd||var.squoter()||
| |
| |-
| |
| |cmd||var.unquoter()||
| |
| |-
| |
| |cmd||var.lowerer()||
| |
| |-
| |
| |cmd||var.raiser()||
| |
| |-
| |
| |cmd||var.cropper()||
| |
| |-
| |
| |cmd||var.trimmer(trimchars = " ")||
| |
| |-
| |
| |cmd||var.trimmerfirst(trimchars = " ")||
| |
| |-
| |
| |cmd||var.trimmerlast(trimchars = " ")||
| |
| |-
| |
| |cmd||var.trimmerboth(trimchars = " ")||
| |
| |-
| |
| |cmd||var.firster()||
| |
| |-
| |
| |cmd||var.laster()||
| |
| |-
| |
| |cmd||var.firster(std::size_t length)||
| |
| |-
| |
| |cmd||var.laster(std::size_t length)||
| |
| |-
| |
| |cmd||var.cutter(length)||
| |
| |-
| |
| |cmd||var.paster(pos1, length, insertstr)||
| |
| |-
| |
| |cmd||var.paster(pos1, insertstr)||
| |
| |-
| |
| |cmd||var.prefixer(insertstr)||
| |
| |-
| |
| |cmd||var.popper()||
| |
| |-
| |
| |cmd||var.fieldstorer(sepchar, fieldno, nfields, replacement)||
| |
| |-
| |
| |cmd||var.substrer(pos1, length)||
| |
| |-
| |
| |cmd||var.substrer(startindex1)||
| |
| |-
| |
| |cmd||var.converter(fromchars, tochars)||
| |
| |-
| |
| |cmd||var.textconverter(fromchars, tochars)||
| |
| |-
| |
| |cmd||var.replacer(regex, tostr)||
| |
| |-
| |
| |cmd||var.replacer(fromstr, tostr)||
| |
| |-
| |
| |cmd||var.uniquer()||
| |
| |-
| |
| |cmd||var.sorter(sepchar = FM)||
| |
| |-
| |
| |cmd||var.reverser(sepchar = FM)||
| |
| |-
| |
| |cmd||var.shuffler(sepchar = FM)||
| |
| |-
| |
| |cmd||var.parser(char sepchar = ' ')||
| |
| |}
| |
| | |
| ===== Other String Access =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.hash(std::uint64_t modulus = 0)||MurmurHash3 hashing. "abc"_var.hash() -> 6715211243465481821
| |
| |-
| |
| |var=||var.substr(pos1, delimiterchars, out endindex)||substr version 3. Extract substr starting from pos1 up to any one of some delimiter chars also returning the next pos1 after the delimiter found
| |
| |-
| |
| |var=||var.b(pos1, delimiterchars, out endindex)||Alias of substr version 3.
| |
| |-
| |
| |var=||var.substr2(io startstopindex, io delimiterno)||substr version 4. Returns the substr from a given index offset (0 based) up to the next RM/FM/VM/SM/TM/STM delimiter char. Also returns the next index/offset and the delimiter no. found 1-6 or 0 if not found.
| |
| |-
| |
| |var=||var.b2(io startstopindex, io delimiterno)||Alias of substr version 4
| |
| |-
| |
| |var=||var.field(strx, fieldnx = 1, nfieldsx = 1)||Extract one or more consecutive fields given a delimiter char or substr.<br>"aa*bb*cc"_var.field("*", 2) -> "bb"
| |
| |-
| |
| |var=||var.field2(separator, fieldno, nfields = 1)||Same as var.field() but negative fieldnos work backwards from the last field.<br>"aa*bb*cc"_var.field("*", -1) -> "cc"
| |
| |}
| |
| | |
| ===== I/O Conversion =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.oconv(convstr)||Output conversions.<br>var(30123).oconv("D/E") -> "21/06/2050"
| |
| |-
| |
| |var=||var.iconv(convstr)||Input conversions.<br>"21 JUN 2050"_var.iconv("D/E") -> 30123
| |
| |-
| |
| |var=||var.format(fmt_str, Args&&... args)||Classic format function<br>format("Text and aligned {:9.2f} number", var(123.456)) -> "Text and aligned ␣␣␣123.46 number"
| |
| |-
| |
| |var=||var.from_codepage(codepage)||Converts to UTF-8 from codepage encoded text.<br>Codepage e.g. "CP1251" (Ukranian). Use Linux command "iconv -l" for complete list.
| |
| |-
| |
| |var=||var.to_codepage(codepage)||Converts from codepage encoded text to UTF-8.
| |
| |}
| |
| | |
| ===== Basic Dynamic Array Functions =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.f(fieldno, valueno = 0, subvalueno = 0)||f() is a highly abbreviated alias for the PICK OS field/value/subvalue extract() function.<br>The convenient PICK OS angle bracket symtax is not available in C++ and the extract function is very heavily in source code.<br>"f" mentally stands for "field" although it can extract values and subvalues of specific fields as well.<br>"f1^f2v1]f2v2]f2v3^f2"_var.f(2, 2) -> "f2v2"
| |
| |-
| |
| |var=||var.extract(fieldno, valueno = 0, subvalueno = 0)||Extract a specific field, value or subvalue from a dynamic array.<br>The alias "f" is usually used instead
| |
| |-
| |
| |var=||var.pickreplace(fieldno, valueno, subvalueno, replacement)||Same as var.r() function but returns a new string instead of updating a variable in place.<br>Rarely used.
| |
| |-
| |
| |var=||var.pickreplace(fieldno, valueno, replacement)||Ditto for a specific multivalue
| |
| |-
| |
| |var=||var.pickreplace(fieldno, replacement)||Ditto for a specific field
| |
| |-
| |
| |var=||var.insert(fieldno, valueno, subvalueno, insertion)||Same as var.inserter() function but returns a new string instead of updating a variable in place.
| |
| |-
| |
| |var=||var.insert(fieldno, valueno, insertion)||Ditto for a specific multivalue
| |
| |-
| |
| |var=||var.insert(fieldno, insertion)||Ditto for a specific field
| |
| |-
| |
| |var=||var.remove(fieldno, valueno = 0, subvalueno = 0)||Same as var.remover() function but returns a new string instead of updating a variable in place.<br>"remove" was called "delete" in Pick OS.
| |
| |}
| |
| | |
| ===== Dynamic Array Filters =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.sum()||Sum up multiple values into one higher level<br>"1]2]3^4]5]6"_var.sum() -> "6^15"
| |
| |-
| |
| |var=||var.sumall()||Sum up all levels into a single figure<br>"1]2]3^4]5]6"_var.sum() -> "21"
| |
| |-
| |
| |var=||var.sum(sepchar)||Ditto allowing commas etc.<br>"10,20,33"_var.sum(",") -> "60"
| |
| |-
| |
| |var=||var.mv(opcode, var2)||Binary ops (+, -, *, /) in parallel on multiple values<br>"10]20]30"_var.mv("+","2]3]4") -> "12]23]34"
| |
| |}
| |
| | |
| ===== Dynamic Array Mutators =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |cmd||var.r(fieldno, valueno, subvalueno, replacement)||Replaces a specific subvalue in a dynamic array.<br>var v1 = "f1^v1]v2}s2}s3^f3"_var; v1.r(2, 2, 2, "X"); v1 -> "f1^v1]v2}X}s3^f3"
| |
| |-
| |
| |cmd||var.r(fieldno, valueno, replacement)||Ditto for specific multivalue.<br>var v1 = "f1^v1]v2}s2}s3^f3"_var; v1.r(2, 2, "X"); v1 -> "f1^v1]X^f3"
| |
| |-
| |
| |cmd||var.r(fieldno, replacement)||Ditto for specific field.<br>var v1 = "f1^v1]v2}s2}s3^f3"_var; v1.r(2, 2, "X"); v1 -> "f1^X^f3"
| |
| |-
| |
| |cmd||var.inserter(fieldno, valueno, subvalueno, insertion)||Insert a specific subvalue in a dynamic array, moving all other subvalues up.<br>"f1^v1]v2}s2}s3^f3"_var.insert(2, 2, 2, "X") -> "f1^v1]v2}X}s2}s3^f3"
| |
| |-
| |
| |cmd||var.inserter(fieldno, valueno, insertion)||
| |
| |-
| |
| |cmd||var.inserter(fieldno, insertion)||
| |
| |-
| |
| |cmd||var.remover(fieldno, valueno = 0, subvalueno = 0)||Remove a field, value or subvalue from a dynamic array.<br>"f1^v1]v2}s2}s3^f3"_var.remove(2, 2) -> "f1^v1^f3"
| |
| |}
| |
| | |
| ===== Dynamic Array Search =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |if||var.locate(target)||locate() with only the target argument provided searches values (separated by VM char).<br>Returns true if found. if found.
| |
| |-
| |
| |if||var.locate(target, out setting)||locate() with only the target and setting argument provided searches values and returns the value no in setting if found.<br>Returns true if found.
| |
| |-
| |
| |if||var.locate(target, out setting, fieldno, valueno = 0)||locate() the target in fields if fieldno is 0, or values in a specified fieldno, or subvalues in a specified valueno.<br>returning the field, value or subvalue number in setting.<br>Returns true if found. if found.
| |
| |-
| |
| |if||var.locateusing(usingchar, target, out setting, fieldno = 0, valueno = 0, subvalueno = 0)||locate() the target in a specific field, value or subvalue using a specified delimiter returning the delimited field number found in setting if found. <br>Returns true if found. if found.
| |
| |-
| |
| |if||var.locateusing(usingchar, target)||locate() in the whole string using a given delimiter char returning the delimited field no in setting if found.<br>Returns true if found. if found.
| |
| |-
| |
| |if||var.locateby(ordercode, target, out setting)||locateby() without fieldno or valueno arguments searches values.<br>The order code can be AL, DL, AR, DR meaning Ascending Left, Descending Right, Ascending Right, Ascending Left.<br>Left is used to indicate alphabetic order and Right is used to indicate numeric order.<br>The data must be in the correct order for searching to work rationally.<br>In case the target is not found then the correct value no for inserting the target is returned in setting.<br>Returns true if found. if found.
| |
| |-
| |
| |if||var.locateby(ordercode, target, out setting, fieldno, valueno = 0)||locateby() ordered as above but in fields if fieldno is 0, or values in a specific fieldno, or subvalues in a specific valueno.<br>Returns true if found. if found.
| |
| |-
| |
| |if||var.locatebyusing(ordercode, usingchar, target, out setting, fieldno = 0, valueno = 0, subvalueno = 0)||locatebyusing() supports all the above features in a single function.<br>Returns true if found.
| |
| |}
| |
| | |
| ===== Database Access =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |if||var.connect(conninfo = "")||for all db operations, var() can be a db connection or a default connection.<br>var db="mydb";<br>if (not db.connect()) abort(db.lasterror());<br>db.version().outputl();<br>db.disconnect();
| |
| |-
| |
| |cmd||var.disconnect()||
| |
| |-
| |
| |cmd||var.disconnectall()||
| |
| |-
| |
| |if||var.attach(filenames)||Connect specific filenames on specific databases for the current default session
| |
| |-
| |
| |cmd||var.detach(filenames)||
| |
| |-
| |
| |if||var.begintrans()||
| |
| |-
| |
| |if||var.rollbacktrans()||
| |
| |-
| |
| |if||var.committrans()||
| |
| |-
| |
| |if||var.statustrans()||
| |
| |-
| |
| |if||var.sqlexec(sqlcmd)||
| |
| |-
| |
| |if||var.sqlexec(sqlcmd, io response)||
| |
| |-
| |
| |var=||var.lasterror()||
| |
| |-
| |
| |var=||var.loglasterror(source = "")||
| |
| |}
| |
| | |
| ===== Database Management =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |if||var.dbcreate(dbname)||Create a named database on a particular connection
| |
| |-
| |
| |var=||var.dblist()||Return a list of available databases on a particular connection
| |
| |-
| |
| |if||var.dbcopy(from_dbname, to_dbname)||Create a named database from an existing database
| |
| |-
| |
| |if||var.dbdelete(dbname)||Delete (drop) a named database
| |
| |-
| |
| |if||var.createfile(filename)||Create a named file
| |
| |-
| |
| |if||var.renamefile(filename, newfilename)||Rename a file
| |
| |-
| |
| |if||var.deletefile(filename)||Delete (drop) a file
| |
| |-
| |
| |if||var.clearfile(filename)||Delete all records in a file
| |
| |-
| |
| |var=||var.listfiles()||Return a list of all files in a database
| |
| |-
| |
| |if||var.createindex(fieldname, dictfile = "")||
| |
| |-
| |
| |if||var.deleteindex(fieldname)||
| |
| |-
| |
| |var=||var.listindex(filename = "", fieldname = "")||
| |
| |-
| |
| |var=||var.version()||
| |
| |-
| |
| |var=||var.reccount(filename = "")||
| |
| |-
| |
| |var=||var.flushindex(filename = "")||
| |
| |-
| |
| |if||var.open(dbfilename, connection = "")||
| |
| |-
| |
| |cmd||var.close()||
| |
| |- | | |- |
| |var=||var.lock(key)||Returns 1=ok, 0=failed, ""=already locked | | |= " " ||" "|| |
| |- | | |- |
| |if||var.unlock(key)|| | | |= "." ||"."|| |
| |- | | |- |
| |if||var.unlockall()|| | | |= 1 ||1 || |
| |- | | |- |
| |if||var.read(filehandle, key)||DB file i/o | | |= 0 ||0|| |
| |- | | |- |
| |cmd||var.write(filehandle, key)|| | | |= true ||true|| |
| |- | | |- |
| |if||var.deleterecord(key)|| | | |= false ||false|| |
| |-
| |
| |if||var.updaterecord(filehandle, key)||
| |
| |-
| |
| |if||var.insertrecord(filehandle, key)||
| |
| |-
| |
| |if||var.readf(filehandle, key, fieldno)||Specific db field i/o
| |
| |-
| |
| |cmd||var.writef(filehandle, key, fieldno)||
| |
| |-
| |
| |if||var.readc(filehandle, key)||Cached db file i/o lives in exodus process memory not the database
| |
| |-
| |
| |cmd||var.writec(filehandle, key)||
| |
| |-
| |
| |if||var.deletec(key)||
| |
| |-
| |
| |cmd||var.cleardbcache()||
| |
| |-
| |
| |var=||var.xlate(filename, fieldno, mode)||
| |
| |} | | |} |
|
| |
|
| ===== Database Sort/Select ===== | | ==== Field mark characters ==== |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0"
| | Exodus implements a PICK OS data structure called a "dynamic array". This is simply any string which uses six specific unprintable ASCII delimiter characters (\x1A to \x1F) to separate its various parts. The parts are referred to as records, fields, values, subvalues, text, and subtext and fall within each other. |
| !Usage!!Function!!Comment
| |
| |-
| |
| |if||var.select(sortselectclause = "")||
| |
| |-
| |
| |cmd||var.clearselect()||
| |
| |-
| |
| |if||var.hasnext()||
| |
| |-
| |
| |if||var.readnext(out key)||
| |
| |-
| |
| |if||var.readnext(out key, out valueno)||
| |
| |-
| |
| |if||var.readnext(out record, out key, out valueno)||
| |
| |-
| |
| |if||var.savelist(listname)||
| |
| |-
| |
| |if||var.getlist(listname)||
| |
| |-
| |
| |if||var.makelist(listname, keys)||
| |
| |-
| |
| |if||var.deletelist(listname)||
| |
| |-
| |
| |if||var.formlist(keys, fieldno = 0)||
| |
| |}
| |
| | |
| ===== OS Time/Date =====
| |
| | |
| {|border="1" cellpadding="10" cellspacing="0"
| |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.date()||int days since pick epoch 1967-12-31
| |
| |-
| |
| |var=||var.time()||int seconds since last midnight
| |
| |-
| |
| |var=||var.ostime()||
| |
| |-
| |
| |var=||var.timestamp()||floating point fractional days since pick epoch 1967-12-31 00:00:00
| |
| |-
| |
| |var=||var.timestamp(ostime)||construct a timestamp from a date and time
| |
| |-
| |
| |cmd||var.ossleep(milliseconds)||
| |
| |-
| |
| |var=||var.oswait(milliseconds, directory)||
| |
| |}
| |
|
| |
|
| ===== OS Files =====
| | Dynamic arrays therefore implement sparse six dimensional arrays. |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0"
| | Typical CPU caching architecture favours similar values being adjacent in memory therefore implementing them as strings of values separated by delimiter characters can have performance advantages over more complex structures. |
| !Usage!!Function!!Comment
| |
| |-
| |
| |if||var.osopen(filename, locale = "")||
| |
| |-
| |
| |if||var.osbread(osfilevar, io offset, length)||
| |
| |-
| |
| |if||var.osbwrite(osfilevar, io offset)||
| |
| |-
| |
| |cmd||var.osclose()||
| |
| |-
| |
| |if||var.osread(osfilename, codepage = "")||
| |
| |-
| |
| |if||var.oswrite(osfilename, codepage = "")||
| |
| |-
| |
| |if||var.osremove()||
| |
| |-
| |
| |if||var.osrename(new_dirpath_or_filepath)||
| |
| |-
| |
| |if||var.oscopy(to_osfilename)||
| |
| |-
| |
| |if||var.osmove(to_osfilename)||
| |
| |}
| |
|
| |
|
| ===== OS Directories =====
| | In practice the vast majority of dynamic arrays consist of "fields" separated by the FM character (\x1E) but it is very common for fields to have values separated by the VM character (\x1D) and values to have subvalues using SM (\x1D). |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0"
| | Since the six delimiter characters fall in the unprintable character range certain other characters have been designated as usable for coding and printing. For example the FM character is represented as ^ and can be entered in source code appended with _var to indicate that the string must be converted to internal format. |
| !Usage!!Function!!Comment
| |
| |-
| |
| |var=||var.oslist(globpattern = "", mode = 0)||
| |
| |-
| |
| |var=||var.oslistf(globpattern = "")||
| |
| |-
| |
| |var=||var.oslistd(globpattern = "")||
| |
| |-
| |
| |var=||var.osinfo(mode)||
| |
| |-
| |
| |var=||var.osfile()||
| |
| |-
| |
| |var=||var.osdir()||
| |
| |-
| |
| |var=||var.osinfo()||
| |
| |-
| |
| |if||var.osmkdir()||
| |
| |-
| |
| |if||var.osrmdir(evenifnotempty = false)||
| |
| |-
| |
| |var=||var.oscwd()||
| |
| |-
| |
| |if||var.oscwd(newpath)||
| |
| |-
| |
| |cmd||var.osflush()||
| |
| |}
| |
|
| |
|
| ===== OS Shell/Environment ===== | | var v1 = "f1^f2^f3"_var; // Three fields |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0"
| | var v2 = "f1^v1]v2]v3^f3"_var; // Three fields, 2nd field has 3 values. It is "multivalued". |
| !Usage!!Function!!Comment
| |
| |-
| |
| |if||var.osshell()||
| |
| |-
| |
| |if||var.osshellread(oscmd)||
| |
| |-
| |
| |if||var.osshellwrite(oscmd)||
| |
| |-
| |
| |var=||var.ostempdirpath()||
| |
| |-
| |
| |var=||var.ostempfilename()||
| |
| |-
| |
| |if||var.osgetenv(envcode)||
| |
| |-
| |
| |cmd||var.ossetenv(envcode)||
| |
| |-
| |
| |var=||var.ospid()||
| |
| |-
| |
| |var=||var.ostid()||
| |
| |}
| |
|
| |
|
| ===== Output =====
| | Anything which contains a collection of fields can be considered as a "record" and records can be stored in files with a unique primary key. The fields might represent different columns of a traditional database table. So anonymous field number 1 might be a contact name, field 2 the contact address, field 3 a multivalued list of contact points. etc. |
|
| |
|
| {|border="1" cellpadding="10" cellspacing="0" | | {|class="wikitable" |
| !Usage!!Function!!Comment | | !Delimiter<br>name!!var||Hex!!Display!!cstr " "||char ' ' |
| |-
| |
| |expr||var.output()||stdout no new line, buffered
| |
| |-
| |
| |expr||var.outputl()||stdout starts a new line, flushed
| |
| |-
| |
| |expr||var.outputt()||stdout adds a tab, buffered
| |
| |-
| |
| |expr||var.logput()||stdlog no new line, buffered
| |
| |-
| |
| |expr||var.logputl()||stdlog starts a new line, flushed
| |
| |-
| |
| |expr||var.errput()||stderr no new line, flushed
| |
| |-
| |
| |expr||var.errputl()||stderr starts a new line, flushed
| |
| |-
| |
| |expr||var.output(prefix)||stdout with a prefix, no new line, buffered
| |
| |-
| |
| |expr||var.outputl(prefix)||stdout with a prefix, starts a new line, flushed
| |
| |- | | |- |
| |expr||var.outputt(prefix)||stdout with a prefix, adds a tab, buffered | | |Record Mark ||RM||\x1F|| ` || _RM || RM_ |
| |- | | |- |
| |expr||var.logput(prefix)||stdlog with a prefix, no new line, buffered | | |Field Mark ||FM||\x1E|| ^ || _FM || FM_ |
| |- | | |- |
| |expr||var.logputl(prefix)||stdlog with a prefix, starts a new line, flushed | | |Value Mark ||VM||\x1D|| ] || _VM || VM_ |
| |- | | |- |
| |expr||var.errput(prefix)||stderr with a prefix, no new line, flushed | | |Subvalue Mark ||SM||\x1C|| } || _SM || SM_ |
| |- | | |- |
| |expr||var.errputl(prefix)||stderr with a prefix, starts a new line, flushed | | |Text Mark||TM ||\x1B|| | || _TM || TM_ |
| |- | | |- |
| |expr||var.put(std::ostream& ostream1)||Output to a given stream | | |Subtext Mark ||STM||\x1A|| ~ || _STM || STM_ |
| |} | | |} |
|
| |
|
| ===== Standard Input =====
| | {|class="wikitable" style="text-align: center;" |
| | |
| {|border="1" cellpadding="10" cellspacing="0" | |
| !Usage!!Function!!Comment
| |
| |-
| |
| |expr||var.input()||Wait for stdin until cr or eof
| |
| |-
| |
| |expr||var.input(prompt)||Ditto after outputting prompt to stdout
| |
| |-
| |
| |expr||var.inputn(nchars)||Wait for nbytes from stdin
| |
| |- | | |- |
| |if||var.isterminal()||true if terminal is available | | |align=right|<b> Delimiter Name :</b> ||Record Mark||Field Mark||Value Mark||Subvalue Mark||Text Mark||Subtext Mark |
| |- | | |- |
| |if||var.hasinput(milliseconds = 0)||true if stdin bytes available within milliseconds | | |align=right|<b>var :</b> || RM ||FM ||VM ||SM ||TM ||STM |
| |- | | |- |
| |if||var.eof()||true if stdin is at end of file | | |align=right|<b>Display :</b>||` ||^ || ] || } || | || ~ |
| |- | | |- |
| |if||var.echo(on_off)||Reflect all stdin to stdout if terminal available | | |align=right|<b>Hex :</b> ||\x1F||\x1E||\x1D||\x1C||\x1B||\x1A |
| |- | | |- |
| |cmd||var.breakon()||Allow interrupt Ctrl+C | | |align=right|<b>cstr " " :</b> ||_RM ||_FM ||_VM ||_SM ||_TM ||_STM |
| |- | | |- |
| |cmd||var.breakoff()||Prevent interrupt Ctr+C | | |align=right|<b>char ' ' :</b> ||RM_ ||FM_ ||VM_ ||SM_ ||TM_ ||STM_ |
| |} | | |} |