Manual: Difference between revisions

From NEOSYS Dev Wiki
Jump to navigationJump to search
No edit summary
Line 281: Line 281:


==== Complete List of Functions ====
==== Complete List of Functions ====


===== Math/Boolean =====
===== Math/Boolean =====
Line 288: Line 291:
|-
|-
|var=||var.abs()||Absolute value
|var=||var.abs()||Absolute value
<syntaxhighlight lang="c++">var(-12.34).abs(); // 12.34</syntaxhighlight>
<syntaxhighlight lang="c++">
var(-12.34).abs(); // 12.34</syntaxhighlight>
|-
|-
|var=||var.pwr(exponent)||Power
|var=||var.pwr(exponent)||Power
<syntaxhighlight lang="c++">var(2).pwr(8); // 256</syntaxhighlight>
<syntaxhighlight lang="c++">
var(2).pwr(8); // 256</syntaxhighlight>
|-
|-
|var=||var.rnd()||Random number generator
|var=||var.rnd()||Random number generator
<syntaxhighlight lang="c++">var(100).rnd(); // 0 to 99 pseudo random</syntaxhighlight>
<syntaxhighlight lang="c++">
var(100).rnd(); // 0 to 99 pseudo random</syntaxhighlight>
|-
|-
|cmd||var.initrnd()||Initialise Random seed
|cmd||var.initrnd()||Initialise Random seed
<syntaxhighlight lang="c++">var(123).initrnd(); // Set pseudo random seed to 123</syntaxhighlight>
<syntaxhighlight lang="c++">
var(123).initrnd(); // Set pseudo random seed to 123</syntaxhighlight>
|-
|-
|var=||var.exp()||Power of e
|var=||var.exp()||Power of e
<syntaxhighlight lang="c++">var(1).exp(); // 2.718281828459045</syntaxhighlight>
<syntaxhighlight lang="c++">
var(1).exp(); // 2.718281828459045</syntaxhighlight>
|-
|-
|var=||var.sqrt()||Square root
|var=||var.sqrt()||Square root
<syntaxhighlight lang="c++">var(100).sqrt(); // 10</syntaxhighlight>
<syntaxhighlight lang="c++">
var(100).sqrt(); // 10</syntaxhighlight>
|-
|-
|var=||var.sin()||Sine of degrees
|var=||var.sin()||Sine of degrees
<syntaxhighlight lang="c++">var(30).sin(); // 0.5</syntaxhighlight>
<syntaxhighlight lang="c++">
var(30).sin(); // 0.5</syntaxhighlight>
|-
|-
|var=||var.cos()||Cosine of degrees
|var=||var.cos()||Cosine of degrees
<syntaxhighlight lang="c++">var(60).cos(); // 0.5</syntaxhighlight>
<syntaxhighlight lang="c++">
var(60).cos(); // 0.5</syntaxhighlight>
|-
|-
|var=||var.tan()||Tangent of degrees
|var=||var.tan()||Tangent of degrees
<syntaxhighlight lang="c++">var(45).tan(); // 1</syntaxhighlight>
<syntaxhighlight lang="c++">
var(45).tan(); // 1</syntaxhighlight>
|-
|-
|var=||var.atan()||Arctangent of degrees
|var=||var.atan()||Arctangent of degrees
<syntaxhighlight lang="c++">var(1).atan(); // 45</syntaxhighlight>
<syntaxhighlight lang="c++">
var(1).atan(); // 45</syntaxhighlight>
|-
|-
|var=||var.loge()||Natural logarithm
|var=||var.loge()||Natural logarithm
<syntaxhighlight lang="c++">var(2.718281828459045).loge(); // 1</syntaxhighlight>
<syntaxhighlight lang="c++">
var(2.718281828459045).loge(); // 1</syntaxhighlight>
|-
|-
|var=||var.integer()||Truncate decimal numbers towards zero.
|var=||var.integer()||Truncate decimal numbers towards zero.
<syntaxhighlight lang="c++">var(2.9).integer(); // 2
<syntaxhighlight lang="c++">
var(2.9).integer(); // 2
var(-2.9).integer(); // -2</syntaxhighlight>
var(-2.9).integer(); // -2</syntaxhighlight>
|-
|-
|var=||var.floor()||Truncate decimal numbers towards negative
|var=||var.floor()||Truncate decimal numbers towards negative
<syntaxhighlight lang="c++">var(2.9).floor(); // 2
<syntaxhighlight lang="c++">
var(2.9).floor(); // 2
var(-2.9).floor(); // -3</syntaxhighlight>
var(-2.9).floor(); // -3</syntaxhighlight>
|-
|-
|var=||var.round(ndecimals = 0)||Round decimal numbers to a desired number of decimal places<br>
|var=||var.round(ndecimals = 0)||Round decimal numbers to a desired number of decimal places<br>
.5 rounds away from zero.
.5 rounds away from zero.
<syntaxhighlight lang="c++">var(23.455).round(2); // "23.46"
<syntaxhighlight lang="c++">
var(23.455).round(2); // "23.46"
var(-23.455).round(2); // "-23.46"</syntaxhighlight>
var(-23.455).round(2); // "-23.46"</syntaxhighlight>
|-
|-
Line 336: Line 353:
Result is between [0 , limit) if limit is positive<br>
Result is between [0 , limit) if limit is positive<br>
Result is between (limit, 0] if limit is negative
Result is between (limit, 0] if limit is negative
<syntaxhighlight lang="c++">var(7).mod(5); // 2
<syntaxhighlight lang="c++">
var(7).mod(5); // 2
mod(7, 5); // ditto</syntaxhighlight>
mod(7, 5); // ditto</syntaxhighlight>
|}
|}
Line 346: Line 364:
|-
|-
|expr||var.getxlocale()||Gets the current thread's default locale codepage code
|expr||var.getxlocale()||Gets the current thread's default locale codepage code
<syntaxhighlight lang="c++">var().getxlocale(); // e.g. "en_US.utf8"
<syntaxhighlight lang="c++">
var().getxlocale(); // e.g. "en_US.utf8"
getxlocale(); // ditto</syntaxhighlight>
getxlocale(); // ditto</syntaxhighlight>
|-
|-
|if||var.setxlocale()||Sets the current thread's default locale codepage code
|if||var.setxlocale()||Sets the current thread's default locale codepage code
<syntaxhighlight lang="c++">"de_DE.utf8"_var.setxlocale(); // true if successful
<syntaxhighlight lang="c++">
"de_DE.utf8"_var.setxlocale(); // true if successful
setxlocale("de_DE.utf8"); // ditto</syntaxhighlight>
setxlocale("de_DE.utf8"); // ditto</syntaxhighlight>
|}
|}
Line 361: Line 381:
|var=||var.chr(num)||Create a string of a single char (byte) given an integer 0-255.<br>
|var=||var.chr(num)||Create a string of a single char (byte) given an integer 0-255.<br>
0-127 -> ASCII, 128-255 -> invalid UTF-8 so cannot be written to database or used various exodus string operations
0-127 -> ASCII, 128-255 -> invalid UTF-8 so cannot be written to database or used various exodus string operations
<syntaxhighlight lang="c++">var().chr(0x61); // "a"
<syntaxhighlight lang="c++">
var().chr(0x61); // "a"
chr(0x61); // ditto</syntaxhighlight>
chr(0x61); // ditto</syntaxhighlight>
|-
|-
Line 368: Line 389:
Not providing implicit constructor from var to unsigned int due to getting ambigious conversions<br>
Not providing implicit constructor from var to unsigned int due to getting ambigious conversions<br>
since int and unsigned int are parallel priority in c++ implicit conversions
since int and unsigned int are parallel priority in c++ implicit conversions
<syntaxhighlight lang="c++">var().textchr(171416); // "𩶘" or "\xF0A9B698"
<syntaxhighlight lang="c++">
var().textchr(171416); // "𩶘" or "\xF0A9B698"
textchr(171416); // ditto</syntaxhighlight>
textchr(171416); // ditto</syntaxhighlight>
|-
|-
|var=||var.str(num)||Create a string by repeating a given character or string
|var=||var.str(num)||Create a string by repeating a given character or string
<syntaxhighlight lang="c++">"ab"_var.str(3); // "ababab"
<syntaxhighlight lang="c++">
"ab"_var.str(3); // "ababab"
str("ab"_var, 3); // ditto</syntaxhighlight>
str("ab"_var, 3); // ditto</syntaxhighlight>
|-
|-
|var=||var.space()||Create string of space characters.
|var=||var.space()||Create string of space characters.
<syntaxhighlight lang="c++">var(3).space(); // "␣␣␣"
<syntaxhighlight lang="c++">
var(3).space(); // "␣␣␣"
space(3); // ditto</syntaxhighlight>
space(3); // ditto</syntaxhighlight>
|-
|-
|var=||var.numberinwords(languagename_or_locale_id = "")||Create a string describing a given number in words
|var=||var.numberinwords(languagename_or_locale_id = "")||Create a string describing a given number in words
<syntaxhighlight lang="c++">var(123.45).numberinwords("de_DE").outputl();
<syntaxhighlight lang="c++">
var(123.45).numberinwords("de_DE").outputl();
//"ein­hundert­drei­und­zwanzig Komma vier fünf"</syntaxhighlight>
//"ein­hundert­drei­und­zwanzig Komma vier fünf"</syntaxhighlight>
|}
|}
Line 390: Line 415:
|-
|-
|var=||var.seq()||Returns the character number of the first char.
|var=||var.seq()||Returns the character number of the first char.
<syntaxhighlight lang="c++">"abc"_var.seq(); // 0x61 97
<syntaxhighlight lang="c++">
"abc"_var.seq(); // 0x61 97
seq("abc"_var); // 0x61 97</syntaxhighlight>
seq("abc"_var); // 0x61 97</syntaxhighlight>
|-
|-
|var=||var.textseq()||Returns the Unicode character number of the first unicode code point.
|var=||var.textseq()||Returns the Unicode character number of the first unicode code point.
<syntaxhighlight lang="c++">"Γ"_var.textseq(); // 915 U+0393: Greek Capital Letter Gamma (Unicode Character)
<syntaxhighlight lang="c++">
"Γ"_var.textseq(); // 915 U+0393: Greek Capital Letter Gamma (Unicode Character)
textseq("Γ"); // ditto</syntaxhighlight>
textseq("Γ"); // ditto</syntaxhighlight>
|-
|-
|var=||var.len()||Returns the length of a string in number of chars
|var=||var.len()||Returns the length of a string in number of chars
<syntaxhighlight lang="c++">"abc"_var.len(); // 3
<syntaxhighlight lang="c++">
"abc"_var.len(); // 3
len("abc"_var); // ditto</syntaxhighlight>
len("abc"_var); // ditto</syntaxhighlight>
|-
|-
Line 404: Line 432:
Allows multi column unicode and reduces combining characters etc. like e followed by grave accent<br>
Allows multi column unicode and reduces combining characters etc. like e followed by grave accent<br>
Possibly does not properly calculate combining sequences of graphemes e.g. face followed by colour
Possibly does not properly calculate combining sequences of graphemes e.g. face followed by colour
<syntaxhighlight lang="c++">"🤡x🤡"_var.textwidth(); // 5
<syntaxhighlight lang="c++">
"🤡x🤡"_var.textwidth(); // 5
textwidth("🤡x🤡"_var); // ditto</syntaxhighlight>
textwidth("🤡x🤡"_var); // ditto</syntaxhighlight>
|-
|-
|var=||var.textlen()||Returns the number of Unicode code points
|var=||var.textlen()||Returns the number of Unicode code points
<syntaxhighlight lang="c++">"Γιάννης"_var.textlen(); // 7
<syntaxhighlight lang="c++">
"Γιάννης"_var.textlen(); // 7
textlen("Γιάννης"_var); // ditto</syntaxhighlight>
textlen("Γιάννης"_var); // ditto</syntaxhighlight>
|-
|-
|var=||var.fcount(sepstr)||Returns the number of fields separated by sepstr present.<br>
|var=||var.fcount(sepstr)||Returns the number of fields separated by sepstr present.<br>
It is the same as var.count(sepstr) + 1 except that and empty string returns 0
It is the same as var.count(sepstr) + 1 except that and empty string returns 0
<syntaxhighlight lang="c++">"a1**c3"_var.fcount("*"); // 3
<syntaxhighlight lang="c++">
"a1**c3"_var.fcount("*"); // 3
fcount("a1**c3"_var, "*"); // ditto</syntaxhighlight>
fcount("a1**c3"_var, "*"); // ditto</syntaxhighlight>
|-
|-
|var=||var.count(sepstr)||Return the number of sepstr found
|var=||var.count(sepstr)||Return the number of sepstr found
<syntaxhighlight lang="c++">"a1*b2*c3"_var.count("*"); // 3
<syntaxhighlight lang="c++">
"a1*b2*c3"_var.count("*"); // 3
count("a1*b2*c3"_var, "*"); // ditto</syntaxhighlight>
count("a1*b2*c3"_var, "*"); // ditto</syntaxhighlight>
|-
|-
|if||var.starts(prefix)||Returns true if starts with prefix
|if||var.starts(prefix)||Returns true if starts with prefix
<syntaxhighlight lang="c++">"abc"_var.starts("ab"); // true</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.starts("ab"); // true</syntaxhighlight>
|-
|-
|if||var.ends(suffix)||Returns true if ends with suffix
|if||var.ends(suffix)||Returns true if ends with suffix
<syntaxhighlight lang="c++">"abc"_var.ends("bc"); // true</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.ends("bc"); // true</syntaxhighlight>
|-
|-
|if||var.contains(substr)||Return true if starts, ends or contains substr
|if||var.contains(substr)||Return true if starts, ends or contains substr
<syntaxhighlight lang="c++">"abcd"_var.contains("bc"); // true</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcd"_var.contains("bc"); // true</syntaxhighlight>
|-
|-
|var=||var.index(substr, startchar1 = 1)||Returns char no if found or 0 if not. startchar1 is byte no to start at.
|var=||var.index(substr, startchar1 = 1)||Returns char no if found or 0 if not. startchar1 is byte no to start at.
<syntaxhighlight lang="c++">"abcd"_var.index("bc"); // 2</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcd"_var.index("bc"); // 2</syntaxhighlight>
|-
|-
|var=||var.indexn(substr, occurrence)||ditto. Occurrence 1 = find first occurrence
|var=||var.indexn(substr, occurrence)||ditto. Occurrence 1 = find first occurrence
<syntaxhighlight lang="c++">"abcabc"_var.index("bc", 2); // 5</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcabc"_var.index("bc", 2); // 5</syntaxhighlight>
|-
|-
|var=||var.indexr(substr, startchar1 = -1)||ditto. Reverse search.<br>
|var=||var.indexr(substr, startchar1 = -1)||ditto. Reverse search.<br>
startchar1 defaults to -1 meaning start searching from the last byte
startchar1 defaults to -1 meaning start searching from the last byte
<syntaxhighlight lang="c++">"abcabc"_var.indexr("bc"); // 5</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcabc"_var.indexr("bc"); // 5</syntaxhighlight>
|-
|-
|var=||var.match(regex, regex_options = "")||Returns all results of regex matching<br>
|var=||var.match(regex, regex_options = "")||Returns all results of regex matching<br>
Multiple matches are in fields<br>
Multiple matches are in fields<br>
Groups are in values
Groups are in values
<syntaxhighlight lang="c++">"abc1abc2"_var.match("bc(\\d)"_rex); // "bc1]1^bc2]2"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc1abc2"_var.match("bc(\\d)"_rex); // "bc1]1^bc2]2"</syntaxhighlight>
|-
|-
|var=||var.match(regex)||Ditto
|var=||var.match(regex)||Ditto
Line 448: Line 487:
|var=||var.search(regex, io startchar1, regex_options = "")||Search for first match of a regular expression starting at startchar1<br>
|var=||var.search(regex, io startchar1, regex_options = "")||Search for first match of a regular expression starting at startchar1<br>
Updates startchar1 ready to search for the next match
Updates startchar1 ready to search for the next match
<syntaxhighlight lang="c++">var startchar1 = 1;
<syntaxhighlight lang="c++">
var startchar1 = 1;
"abc1abc2"_var.search("bc(\\d)", startchar1); // returns "bc1]1"
"abc1abc2"_var.search("bc(\\d)", startchar1); // returns "bc1]1"
// startchar1 becomes 5 ready for the next search</syntaxhighlight>
// startchar1 becomes 5 ready for the next search</syntaxhighlight>
Line 465: Line 505:
|-
|-
|var=||var.ucase()||To upper case
|var=||var.ucase()||To upper case
<syntaxhighlight lang="c++">"Γιάννης"_var.ucase(); // "ΓΙΆΝΝΗΣ"</syntaxhighlight>
<syntaxhighlight lang="c++">
"Γιάννης"_var.ucase(); // "ΓΙΆΝΝΗΣ"</syntaxhighlight>
|-
|-
|var=||var.lcase()||Lower case
|var=||var.lcase()||Lower case
<syntaxhighlight lang="c++">"ΓΙΆΝΝΗΣ"_var.lcase(); // "γιάννης"</syntaxhighlight>
<syntaxhighlight lang="c++">
"ΓΙΆΝΝΗΣ"_var.lcase(); // "γιάννης"</syntaxhighlight>
|-
|-
|var=||var.tcase()||Title case (first letters)
|var=||var.tcase()||Title case (first letters)
<syntaxhighlight lang="c++">"γιάννης"_var.tcase(); // "Γιάννης"</syntaxhighlight>
<syntaxhighlight lang="c++">
"γιάννης"_var.tcase(); // "Γιάννης"</syntaxhighlight>
|-
|-
|var=||var.fcase()||Fold case (lower case and remove accents for indexing)
|var=||var.fcase()||Fold case (lower case and remove accents for indexing)
Line 478: Line 521:
|-
|-
|var=||var.invert()||Simple reversible disguising of text
|var=||var.invert()||Simple reversible disguising of text
<syntaxhighlight lang="c++">"abc"_var.invert(); // "\x{C29EC29DC29C}"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.invert(); // "\x{C29EC29DC29C}"</syntaxhighlight>
|-
|-
|var=||var.lower()||Convert all FM to VM, VM to SM etc.
|var=||var.lower()||Convert all FM to VM, VM to SM etc.
<syntaxhighlight lang="c++">"a1^b2^c3"_var.lower(); // "a1]b2]c3"</syntaxhighlight>
<syntaxhighlight lang="c++">
"a1^b2^c3"_var.lower(); // "a1]b2]c3"</syntaxhighlight>
|-
|-
|var=||var.raise()||Convert all VM to FM, SM to VM etc.
|var=||var.raise()||Convert all VM to FM, SM to VM etc.
<syntaxhighlight lang="c++">"a1]b2]c3"_var.raise(); // "a1^b2^c3"</syntaxhighlight>
<syntaxhighlight lang="c++">
"a1]b2]c3"_var.raise(); // "a1^b2^c3"</syntaxhighlight>
|-
|-
|var=||var.crop()||Remove any redundant FM, VM etc. characters (Trailing FM; VM before FM etc.)
|var=||var.crop()||Remove any redundant FM, VM etc. characters (Trailing FM; VM before FM etc.)
<syntaxhighlight lang="c++">"a1^b2]]^c3^^"_var.crop(); // "a1^b2^c3"</syntaxhighlight>
<syntaxhighlight lang="c++">
"a1^b2]]^c3^^"_var.crop(); // "a1^b2^c3"</syntaxhighlight>
|-
|-
|var=||var.quote()||Wrap in double quotes
|var=||var.quote()||Wrap in double quotes
<syntaxhighlight lang="c++">"abc"_var.quote(); // ""abc""</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.quote(); // ""abc""</syntaxhighlight>
|-
|-
|var=||var.squote()||Wrap in single quotes
|var=||var.squote()||Wrap in single quotes
<syntaxhighlight lang="c++">"abc"_var.squote(); // "'abc'"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.squote(); // "'abc'"</syntaxhighlight>
|-
|-
|var=||var.unquote()||Remove one pair of double or single quotes
|var=||var.unquote()||Remove one pair of double or single quotes
<syntaxhighlight lang="c++">"'abc'"_var.unquote(); // "abc"</syntaxhighlight>
<syntaxhighlight lang="c++">
"'abc'"_var.unquote(); // "abc"</syntaxhighlight>
|-
|-
|var=||var.trim(trimchars = " ")||Remove leading, trailing and excessive inner bytes
|var=||var.trim(trimchars = " ")||Remove leading, trailing and excessive inner bytes
<syntaxhighlight lang="c++">"␣␣a1␣␣b2␣c3␣␣"_var.trim(); // "a1␣b2␣c3"</syntaxhighlight>
<syntaxhighlight lang="c++">
"␣␣a1␣␣b2␣c3␣␣"_var.trim(); // "a1␣b2␣c3"</syntaxhighlight>
|-
|-
|var=||var.trimfirst(trimchars = " ")||Ditto leading
|var=||var.trimfirst(trimchars = " ")||Ditto leading
<syntaxhighlight lang="c++">"␣␣a1␣␣b2␣c3␣␣"_var.trimfirst(); // "a1␣␣b2␣c3␣␣"</syntaxhighlight>
<syntaxhighlight lang="c++">
"␣␣a1␣␣b2␣c3␣␣"_var.trimfirst(); // "a1␣␣b2␣c3␣␣"</syntaxhighlight>
|-
|-
|var=||var.trimlast(trimchars = " ")||Ditto trailing
|var=||var.trimlast(trimchars = " ")||Ditto trailing
<syntaxhighlight lang="c++">"␣␣a1␣␣b2␣c3␣␣"_var.trimlast(); // "␣␣a1␣␣b2␣c3"</syntaxhighlight>
<syntaxhighlight lang="c++">
"␣␣a1␣␣b2␣c3␣␣"_var.trimlast(); // "␣␣a1␣␣b2␣c3"</syntaxhighlight>
|-
|-
|var=||var.trimboth(trimchars = " ")||Ditto leading, trailing but not inner
|var=||var.trimboth(trimchars = " ")||Ditto leading, trailing but not inner
<syntaxhighlight lang="c++">"␣␣a1␣␣b2␣c3␣␣"_var.trimboth(); // "a1␣␣b2␣c3"</syntaxhighlight>
<syntaxhighlight lang="c++">
"␣␣a1␣␣b2␣c3␣␣"_var.trimboth(); // "a1␣␣b2␣c3"</syntaxhighlight>
|-
|-
|var=||var.first()||Extract first char or "" if empty
|var=||var.first()||Extract first char or "" if empty
<syntaxhighlight lang="c++">"abc"_var.first(); // "a"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.first(); // "a"</syntaxhighlight>
|-
|-
|var=||var.last()||Extract last char or "" if empty
|var=||var.last()||Extract last char or "" if empty
<syntaxhighlight lang="c++">"abc"_var.last(); // "c"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.last(); // "c"</syntaxhighlight>
|-
|-
|var=||var.first(std::size_t length)||Extract up to length leading chars
|var=||var.first(std::size_t length)||Extract up to length leading chars
<syntaxhighlight lang="c++">"abc"_var.first(2); // "ab"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.first(2); // "ab"</syntaxhighlight>
|-
|-
|var=||var.last(std::size_t length)||Extract up to length trailing chars
|var=||var.last(std::size_t length)||Extract up to length trailing chars
<syntaxhighlight lang="c++">"abc"_var.last(2); // "bc"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.last(2); // "bc"</syntaxhighlight>
|-
|-
|var=||var.cut(length)||Remove length leading chars
|var=||var.cut(length)||Remove length leading chars
<syntaxhighlight lang="c++">"abcd"_var.cut(2); // "cd"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcd"_var.cut(2); // "cd"</syntaxhighlight>
|-
|-
|var=||var.paste(pos1, length, insertstr)||Insert text at char position overwriting length chars
|var=||var.paste(pos1, length, insertstr)||Insert text at char position overwriting length chars
<syntaxhighlight lang="c++">"abcd"_var.paste(2, 2, "XYZ"); // "aXYZd"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcd"_var.paste(2, 2, "XYZ"); // "aXYZd"</syntaxhighlight>
|-
|-
|var=||var.paste(pos1, insertstr)||Insert text at char position without overwriting any following characters
|var=||var.paste(pos1, insertstr)||Insert text at char position without overwriting any following characters
<syntaxhighlight lang="c++">"abcd"_var.paste(2, "XYZ"); // "aXYbcd"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcd"_var.paste(2, "XYZ"); // "aXYbcd"</syntaxhighlight>
|-
|-
|var=||var.prefix(insertstr)||Insert text at the beginning
|var=||var.prefix(insertstr)||Insert text at the beginning
<syntaxhighlight lang="c++">"abc"_var.prefix("XY"); // "XYabc"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.prefix("XY"); // "XYabc"</syntaxhighlight>
|-
|-
|var=||var.pop()||Remove one trailing char
|var=||var.pop()||Remove one trailing char
<syntaxhighlight lang="c++">"abc"_var.pop(); // "ab"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.pop(); // "ab"</syntaxhighlight>
|-
|-
|var=||var.fieldstore(separator, fieldno, nfields, replacement)||fieldstore() replaces nfields of subfield(s) in a string.
|var=||var.fieldstore(separator, fieldno, nfields, replacement)||fieldstore() replaces nfields of subfield(s) in a string.
<syntaxhighlight lang="c++">"aa*bb*cc*dd"_var.fieldstore("*", 2, 3, "X*Y"); // "aa*X*Y*"</syntaxhighlight>
<syntaxhighlight lang="c++">
"aa*bb*cc*dd"_var.fieldstore("*", 2, 3, "X*Y"); // "aa*X*Y*"</syntaxhighlight>
If nfields is 0 then insert fields before fieldno
If nfields is 0 then insert fields before fieldno
<syntaxhighlight lang="c++">"a1*b2*c3*d4"_var.fieldstore("*", 2, 0, "X*Y"); // "a1*X*Y*b2*c3*d4"</syntaxhighlight>
<syntaxhighlight lang="c++">
"a1*b2*c3*d4"_var.fieldstore("*", 2, 0, "X*Y"); // "a1*X*Y*b2*c3*d4"</syntaxhighlight>
If nfields is negative then delete nfields before inserting.
If nfields is negative then delete nfields before inserting.
<syntaxhighlight lang="c++">"a1*b2*c3*d4"_var.fieldstore("*", 2, -3, "X*Y"); // "a1*X*Y"</syntaxhighlight>
<syntaxhighlight lang="c++">
"a1*b2*c3*d4"_var.fieldstore("*", 2, -3, "X*Y"); // "a1*X*Y"</syntaxhighlight>
|-
|-
|var=||var.substr(startindex1, length)||substr version 1. Extract length chars starting at startindex1
|var=||var.substr(startindex1, length)||substr version 1. Extract length chars starting at startindex1
<syntaxhighlight lang="c++">"abcd"_var.substr(2, 2); // "bc"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcd"_var.substr(2, 2); // "bc"</syntaxhighlight>
If length is negative then work backwards and return chars reversed
If length is negative then work backwards and return chars reversed
<syntaxhighlight lang="c++">"abcd"_var.substr(3, -2); // "cb"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcd"_var.substr(3, -2); // "cb"</syntaxhighlight>
|-
|-
|var=||var.substr(startindex1)||substr version 2. Extract all chars from startindex1 up to the end
|var=||var.substr(startindex1)||substr version 2. Extract all chars from startindex1 up to the end
<syntaxhighlight lang="c++">"abcd"_var.substr(2); // "bcd"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcd"_var.substr(2); // "bcd"</syntaxhighlight>
|-
|-
|var=||var.b(pos1, length)||Same as substr version 1.
|var=||var.b(pos1, length)||Same as substr version 1.
Line 557: Line 626:
|-
|-
|var=||var.convert(fromchars, tochars)||Convert chars to other chars one for one or delete where tochars is shorter.
|var=||var.convert(fromchars, tochars)||Convert chars to other chars one for one or delete where tochars is shorter.
<syntaxhighlight lang="c++">"abcde"_var.convert("aZd", "XY"); // "Xbce" (a is replaced and d is removed)</syntaxhighlight>
<syntaxhighlight lang="c++">
"abcde"_var.convert("aZd", "XY"); // "Xbce" (a is replaced and d is removed)</syntaxhighlight>
|-
|-
|var=||var.textconvert(fromchars, tochars)||Ditto for Unicode code points.
|var=||var.textconvert(fromchars, tochars)||Ditto for Unicode code points.
<syntaxhighlight lang="c++">"🤡😀✌"_var.textconvert("🤡😀", "👋"); // "👋✌ "</syntaxhighlight>
<syntaxhighlight lang="c++">
"🤡😀✌"_var.textconvert("🤡😀", "👋"); // "👋✌ "</syntaxhighlight>
|-
|-
|var=||var.replace(fromstr, tostr)||Replace all occurrences of a substr with another. Case sensitive
|var=||var.replace(fromstr, tostr)||Replace all occurrences of a substr with another. Case sensitive
<syntaxhighlight lang="c++">"Abc Abc"_var.replace("bc", "X"); // "AX AX"</syntaxhighlight>
<syntaxhighlight lang="c++">
"Abc Abc"_var.replace("bc", "X"); // "AX AX"</syntaxhighlight>
|-
|-
|var=||var.replace(regex, tostr)||Replace substring(s) using a regular expression.<br>
|var=||var.replace(regex, tostr)||Replace substring(s) using a regular expression.<br>
Use $0, $1, $2 in tostr to refer to groups defined in the regex.
Use $0, $1, $2 in tostr to refer to groups defined in the regex.
<syntaxhighlight lang="c++">"A a B b"_var.replace("[A-Z]"_rex, "'$0'"); // "'A' a 'B' b"</syntaxhighlight>
<syntaxhighlight lang="c++">
"A a B b"_var.replace("[A-Z]"_rex, "'$0'"); // "'A' a 'B' b"</syntaxhighlight>
|-
|-
|var=||var.unique()||Remove duplicate fields in an FM or VM etc. separated list
|var=||var.unique()||Remove duplicate fields in an FM or VM etc. separated list
<syntaxhighlight lang="c++">"a1^b2^a1^c2"_var.unique(); // "a1^b2^c2"</syntaxhighlight>
<syntaxhighlight lang="c++">
"a1^b2^a1^c2"_var.unique(); // "a1^b2^c2"</syntaxhighlight>
|-
|-
|var=||var.sort(sepchar = FM)||Reorder fields in an FM or VM etc. separated list in ascending order
|var=||var.sort(sepchar = FM)||Reorder fields in an FM or VM etc. separated list in ascending order
<syntaxhighlight lang="c++">"20^10^2^1^1.1"_var.sort(); // "1^1.1^2^10^20"</syntaxhighlight>
<syntaxhighlight lang="c++">
<syntaxhighlight lang="c++">"b1^a1^c20^c10^c2^c1^b2"_var.sort(); // "a1^b1^b2^c1^c10^c2^c20"</syntaxhighlight>
"20^10^2^1^1.1"_var.sort(); // "1^1.1^2^10^20"</syntaxhighlight>
<syntaxhighlight lang="c++">
"b1^a1^c20^c10^c2^c1^b2"_var.sort(); // "a1^b1^b2^c1^c10^c2^c20"</syntaxhighlight>
|-
|-
|var=||var.reverse(sepchar = FM)||Reorder fields in an FM or VM etc. separated list in descending order
|var=||var.reverse(sepchar = FM)||Reorder fields in an FM or VM etc. separated list in descending order
<syntaxhighlight lang="c++">"20^10^2^1^1.1"_var.reverse(); // "1.1^1^2^10^20"</syntaxhighlight>
<syntaxhighlight lang="c++">
"20^10^2^1^1.1"_var.reverse(); // "1.1^1^2^10^20"</syntaxhighlight>
|-
|-
|var=||var.shuffle(sepchar = FM)||Randomise the order of fields in an FM, VM separated list
|var=||var.shuffle(sepchar = FM)||Randomise the order of fields in an FM, VM separated list
<syntaxhighlight lang="c++">"20^10^2^1^1.1"_var.shuffle(); // "2^1^20^1.1^10" (random order depending on initrand())</syntaxhighlight>
<syntaxhighlight lang="c++">
"20^10^2^1^1.1"_var.shuffle(); // "2^1^20^1.1^10" (random order depending on initrand())</syntaxhighlight>
|-
|-
|var=||var.parse(char sepchar = ' ')||Replace separator characters with FM char except inside double or single quotes ignoring escaped quotes \\" \&squot;
|var=||var.parse(char sepchar = ' ')||Replace separator characters with FM char except inside double or single quotes ignoring escaped quotes \\" \&squot;
<syntaxhighlight lang="c++">"abc,\"def,\"123\" fgh\",12.34"_var.parse(','); // "abc^"def,"123" fgh"^12.34"</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc,\"def,\"123\" fgh\",12.34"_var.parse(','); // "abc^"def,"123" fgh"^12.34"</syntaxhighlight>
|}
|}


Line 672: Line 751:
|-
|-
|var=||var.hash(std::uint64_t modulus = 0)||MurmurHash3 hashing.
|var=||var.hash(std::uint64_t modulus = 0)||MurmurHash3 hashing.
<syntaxhighlight lang="c++">"abc"_var.hash(); // 6715211243465481821</syntaxhighlight>
<syntaxhighlight lang="c++">
"abc"_var.hash(); // 6715211243465481821</syntaxhighlight>
|-
|-
|var=||var.substr(pos1, delimiterchars, out endindex)||substr version 3.<br>
|var=||var.substr(pos1, delimiterchars, out endindex)||substr version 3.<br>
Line 685: Line 765:
|-
|-
|var=||var.field(strx, fieldnx = 1, nfieldsx = 1)||Extract one or more consecutive fields given a delimiter char or substr.
|var=||var.field(strx, fieldnx = 1, nfieldsx = 1)||Extract one or more consecutive fields given a delimiter char or substr.
<syntaxhighlight lang="c++">"aa*bb*cc"_var.field("*", 2);m // "bb"</syntaxhighlight>
<syntaxhighlight lang="c++">
"aa*bb*cc"_var.field("*", 2);m // "bb"</syntaxhighlight>
|-
|-
|var=||var.field2(separator, fieldno, nfields = 1)||field2 is a version that treats fieldn -1 as the last field, -2 the penultimate field etc. -<br>
|var=||var.field2(separator, fieldno, nfields = 1)||field2 is a version that treats fieldn -1 as the last field, -2 the penultimate field etc. -<br>
Line 699: Line 780:
|-
|-
|var=||var.oconv(convstr)||Converts to output format
|var=||var.oconv(convstr)||Converts to output format
<syntaxhighlight lang="c++">var(30123).oconv("D/E"); // "21/06/2050"</syntaxhighlight>
<syntaxhighlight lang="c++">
var(30123).oconv("D/E"); // "21/06/2050"</syntaxhighlight>
|-
|-
|var=||var.iconv(convstr)||Converts to input format
|var=||var.iconv(convstr)||Converts to input format
<syntaxhighlight lang="c++">"21 JUN 2050"_var.iconv("D/E"); // 30123</syntaxhighlight>
<syntaxhighlight lang="c++">
"21 JUN 2050"_var.iconv("D/E"); // 30123</syntaxhighlight>
|-
|-
|var=||var.format(fmt_str, Args&&... args)||Classic format function in printf style
|var=||var.format(fmt_str, Args&&... args)||Classic format function in printf style
<syntaxhighlight lang="c++">format("Text and aligned {:9.2f} number", var(123.456)); // "Text and aligned ␣␣␣123.46 number"</syntaxhighlight>
<syntaxhighlight lang="c++">
format("Text and aligned {:9.2f} number", var(123.456)); // "Text and aligned ␣␣␣123.46 number"</syntaxhighlight>
|-
|-
|var=||var.from_codepage(codepage)||Converts from codepage encoded text to UTF-8 encoded text<br>
|var=||var.from_codepage(codepage)||Converts from codepage encoded text to UTF-8 encoded text<br>
Line 723: Line 807:
The convenient PICK OS angle bracket syntax for field extraction (e.g. xxx<20>) is not available in C++.<br>
The convenient PICK OS angle bracket syntax for field extraction (e.g. xxx<20>) is not available in C++.<br>
The abbreviated exodus field extraction function (e.g. xxx.f(20)) is provided instead since field access is extremely heavily used in source code.
The abbreviated exodus field extraction function (e.g. xxx.f(20)) is provided instead since field access is extremely heavily used in source code.
<syntaxhighlight lang="c++">"f1^f2v1]f2v2]f2v3^f2"_var.f(2, 2); // "f2v2"</syntaxhighlight>
<syntaxhighlight lang="c++">
"f1^f2v1]f2v2]f2v3^f2"_var.f(2, 2); // "f2v2"</syntaxhighlight>
|-
|-
|var=||var.extract(fieldno, valueno = 0, subvalueno = 0)||Extract a specific field, value or subvalue from a dynamic array.<br>
|var=||var.extract(fieldno, valueno = 0, subvalueno = 0)||Extract a specific field, value or subvalue from a dynamic array.<br>
Line 750: Line 835:
|-
|-
|var=||var.sum()||Sum up multiple values into one higher level
|var=||var.sum()||Sum up multiple values into one higher level
<syntaxhighlight lang="c++">"1]2]3^4]5]6"_var.sum(); // "6^15"</syntaxhighlight>
<syntaxhighlight lang="c++">
"1]2]3^4]5]6"_var.sum(); // "6^15"</syntaxhighlight>
|-
|-
|var=||var.sumall()||Sum up all levels into a single figure
|var=||var.sumall()||Sum up all levels into a single figure
<syntaxhighlight lang="c++">"1]2]3^4]5]6"_var.sumall(); // "21"</syntaxhighlight>
<syntaxhighlight lang="c++">
"1]2]3^4]5]6"_var.sumall(); // "21"</syntaxhighlight>
|-
|-
|var=||var.sum(sepchar)||Ditto allowing commas etc.
|var=||var.sum(sepchar)||Ditto allowing commas etc.
<syntaxhighlight lang="c++">"10,20,33"_var.sum(","); // "60"</syntaxhighlight>
<syntaxhighlight lang="c++">
"10,20,33"_var.sum(","); // "60"</syntaxhighlight>
|-
|-
|var=||var.mv(opcode, var2)||Binary ops (+, -, *, /) in parallel on multiple values
|var=||var.mv(opcode, var2)||Binary ops (+, -, *, /) in parallel on multiple values
<syntaxhighlight lang="c++">"10]20]30"_var.mv("+","2]3]4"); // "12]23]34"</syntaxhighlight>
<syntaxhighlight lang="c++">
"10]20]30"_var.mv("+","2]3]4"); // "12]23]34"</syntaxhighlight>
|}
|}


Line 768: Line 857:
|-
|-
|cmd||var.r(fieldno, replacement)||Replaces a specific field in a dynamic array
|cmd||var.r(fieldno, replacement)||Replaces a specific field in a dynamic array
<syntaxhighlight lang="c++">var v1 = "f1^v1]v2}s2}s3^f3"_var;
<syntaxhighlight lang="c++">
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.r(2, 2, "X"); // v1 -> "f1^X^f3"</syntaxhighlight>
v1.r(2, 2, "X"); // v1 -> "f1^X^f3"</syntaxhighlight>
|-
|-
|cmd||var.r(fieldno, valueno, replacement)||Ditto for specific value in a specific field.
|cmd||var.r(fieldno, valueno, replacement)||Ditto for specific value in a specific field.
<syntaxhighlight lang="c++">var v1 = "f1^v1]v2}s2}s3^f3"_var;
<syntaxhighlight lang="c++">
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.r(2, 2, "X"); // v1 -> "f1^v1]X^f3"</syntaxhighlight>
v1.r(2, 2, "X"); // v1 -> "f1^v1]X^f3"</syntaxhighlight>
|-
|-
|cmd||var.r(fieldno, valueno, subvalueno, replacement)||Ditto for a specific subvalue in a specific value of a specific field
|cmd||var.r(fieldno, valueno, subvalueno, replacement)||Ditto for a specific subvalue in a specific value of a specific field
<syntaxhighlight lang="c++">var v1 = "f1^v1]v2}s2}s3^f3"_var;
<syntaxhighlight lang="c++">
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.r(2, 2, 2, "X"); // v1 -> "f1^v1]v2}X}s3^f3"</syntaxhighlight>
v1.r(2, 2, 2, "X"); // v1 -> "f1^v1]v2}X}s3^f3"</syntaxhighlight>
|-
|-
|cmd||var.inserter(fieldno, insertion)||Insert a specific field in a dynamic array, moving all other fields up.
|cmd||var.inserter(fieldno, insertion)||Insert a specific field in a dynamic array, moving all other fields up.
<syntaxhighlight lang="c++">var v1 = "f1^v1]v2}s2}s3^f3"_var;
<syntaxhighlight lang="c++">
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.inserter(2, "X"); // v1 -> "f1^X^v1]v2}s2}s3^f3"</syntaxhighlight>
v1.inserter(2, "X"); // v1 -> "f1^X^v1]v2}s2}s3^f3"</syntaxhighlight>
|-
|-
|cmd||var.inserter(fieldno, valueno, insertion)||Ditto for a specific value in a specific field, moving all other fields up.
|cmd||var.inserter(fieldno, valueno, insertion)||Ditto for a specific value in a specific field, moving all other fields up.
<syntaxhighlight lang="c++">var v1 = "f1^v1]v2}s2}s3^f3"_var;
<syntaxhighlight lang="c++">
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.inserter(2, 2, "X"); // v1 -> "f1^v1]X]v2}s2}s3^f3"</syntaxhighlight>
v1.inserter(2, 2, "X"); // v1 -> "f1^v1]X]v2}s2}s3^f3"</syntaxhighlight>
|-
|-
|cmd||var.inserter(fieldno, valueno, subvalueno, insertion)||Ditto for a specific subvalue in a dynamic array, moving all other subvalues up.
|cmd||var.inserter(fieldno, valueno, subvalueno, insertion)||Ditto for a specific subvalue in a dynamic array, moving all other subvalues up.
<syntaxhighlight lang="c++">var v1 = "f1^v1]v2}s2}s3^f3"_var;
<syntaxhighlight lang="c++">
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.inserter(2, 2, 2, "X"); // v1 -> "f1^v1]v2}X}s2}s3^f3"</syntaxhighlight>
v1.inserter(2, 2, 2, "X"); // v1 -> "f1^v1]v2}X}s2}s3^f3"</syntaxhighlight>
|-
|-
|cmd||var.remover(fieldno, valueno = 0, subvalueno = 0)||Remove a specific field (or value, or subvalue) from a dynamic array, moving all other fields (or values, or subvalues) down.
|cmd||var.remover(fieldno, valueno = 0, subvalueno = 0)||Remove a specific field (or value, or subvalue) from a dynamic array, moving all other fields (or values, or subvalues) down.
<syntaxhighlight lang="c++">var v1 = "f1^v1]v2}s2}s3^f3"_var;
<syntaxhighlight lang="c++">
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.remover(2, 2); // v1 -> "f1^v1^f3"</syntaxhighlight>
v1.remover(2, 2); // v1 -> "f1^v1^f3"</syntaxhighlight>
|}
|}
Line 803: Line 899:
|if||var.locate(target)||locate() with only the target substr argument provided searches unordered values separated by VM chars.<br>
|if||var.locate(target)||locate() with only the target substr argument provided searches unordered values separated by VM chars.<br>
Returns true if found and false if not.
Returns true if found and false if not.
<syntaxhighlight lang="c++">if ("UK]US]UA"_var.locate("US")) ... // true</syntaxhighlight>
<syntaxhighlight lang="c++">
if ("UK]US]UA"_var.locate("US")) ... // true</syntaxhighlight>
|-
|-
|if||var.locate(target, out valueno)||locate() with only the target substr and valueno arguments provided searches unordered values separated by VM chars.<br>
|if||var.locate(target, out valueno)||locate() with only the target substr and valueno arguments provided searches unordered values separated by VM chars.<br>
Returns true if found and with the value number in valueno.<br>
Returns true if found and with the value number in valueno.<br>
Returns false if not found and with the max value number + 1 in setting. Suitable for additiom of new values
Returns false if not found and with the max value number + 1 in setting. Suitable for additiom of new values
<syntaxhighlight lang="c++">var valueno; if ("UK]US]UA"_var.locate("US", valueno)) ... // returns true and valueno = 2</syntaxhighlight>
<syntaxhighlight lang="c++">
var valueno; if ("UK]US]UA"_var.locate("US", valueno)) ... // returns true and valueno = 2</syntaxhighlight>
|-
|-
|if||var.locate(target, out setting, fieldno, valueno = 0)||locate() the target in unordered fields if fieldno is 0, or values if a fieldno is specified, or subvalues if the valueno argument is provided.<br>
|if||var.locate(target, out setting, fieldno, valueno = 0)||locate() the target in unordered fields if fieldno is 0, or values if a fieldno is specified, or subvalues if the valueno argument is provided.<br>
Returns true if found and with the field, value or subvalue number in setting.<br>
Returns true if found and with the field, value or subvalue number in setting.<br>
Returns false if not found and with the max field, value or subvalue number found + 1 in setting. Suitable for replacement of new fields, values or subvalues.
Returns false if not found and with the max field, value or subvalue number found + 1 in setting. Suitable for replacement of new fields, values or subvalues.
<syntaxhighlight lang="c++">var setting; if ("f1^f2v1]f2v2]s1}s2}s3}s4^f3^f4"_var.locate("s4", setting, 2, 3)) ... // returns true and setting = 4</syntaxhighlight>
<syntaxhighlight lang="c++">
var setting; if ("f1^f2v1]f2v2]s1}s2}s3}s4^f3^f4"_var.locate("s4", setting, 2, 3)) ... // returns true and setting = 4</syntaxhighlight>
|-
|-
|if||var.locateby(ordercode, target, out valueno)||locateby() without fieldno or valueno arguments searches ordered values separated by VM chars.<br>
|if||var.locateby(ordercode, target, out valueno)||locateby() without fieldno or valueno arguments searches ordered values separated by VM chars.<br>
Line 822: Line 921:
Returns true if found.<br>
Returns true if found.<br>
In case the target is not exactly found then the correct value no for inserting the target is returned in setting.
In case the target is not exactly found then the correct value no for inserting the target is returned in setting.
<syntaxhighlight lang="c++">var valueno; if ("aaa]bbb]ccc"_var.locateby("AL", "bb", valueno)) ... // returns false and valueno = 2 where it could be correctly inserted.</syntaxhighlight>
<syntaxhighlight lang="c++">
var valueno; if ("aaa]bbb]ccc"_var.locateby("AL", "bb", valueno)) ... // returns false and valueno = 2 where it could be correctly inserted.</syntaxhighlight>
|-
|-
|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.
|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.
<syntaxhighlight lang="c++">var setting; if ("f1^f2^aaa]bbb]ccc^f4"_var.locateby("AL", "bb", setting, 3)) ... // returns false and setting = 2 where it could be correctly inserted.</syntaxhighlight>
<syntaxhighlight lang="c++">
var setting; if ("f1^f2^aaa]bbb]ccc^f4"_var.locateby("AL", "bb", setting, 3)) ... // returns false and setting = 2 where it could be correctly inserted.</syntaxhighlight>
|-
|-
|if||var.locateusing(usingchar, target)||locate() a target substr in the whole unordered string using a given delimiter char returning true if found.<br>
|if||var.locateusing(usingchar, target)||locate() a target substr in the whole unordered string using a given delimiter char returning true if found.<br>
Line 834: Line 935:
Returns false if not found and returns in setting the maximum number of delimited fields + 1 if not found.<br>
Returns false if not found and returns in setting the maximum number of delimited fields + 1 if not found.<br>
This is similar to the main locate command but the delimiter char can be specified e.g. a comma or TM etc.
This is similar to the main locate command but the delimiter char can be specified e.g. a comma or TM etc.
<syntaxhighlight lang="c++">var setting; if ("f1^f2^f3c1,f3c2,f3c3^f4"_var.locateusing(",", "f3c2", setting, 3)) ... // returns true and setting = 2</syntaxhighlight>
<syntaxhighlight lang="c++">
var setting; if ("f1^f2^f3c1,f3c2,f3c3^f4"_var.locateusing(",", "f3c2", setting, 3)) ... // returns true and setting = 2</syntaxhighlight>
|-
|-
|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>
|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>
Line 976: Line 1,078:
|-
|-
|var=||var.date()||Number of whole days since pick epoch 1967-12-31 00:00:00 UTC. Negative for dates before.
|var=||var.date()||Number of whole days since pick epoch 1967-12-31 00:00:00 UTC. Negative for dates before.
<syntaxhighlight lang="c++">var().date(); // e.g. was 20821 from 2025-01-01 00:00:00 UTC
<syntaxhighlight lang="c++">
var today = date(); // Typical</syntaxhighlight>
var today1 = var().date(); // e.g. was 20821 from 2025-01-01 00:00:00 UTC
// or just
var today2 = date();</syntaxhighlight>
|-
|-
|var=||var.time()||Number of whole seconds since last 00:00:00 (UTC).
|var=||var.time()||Number of whole seconds since last 00:00:00 (UTC).
<syntaxhighlight lang="c++">var().time(); // 0 - 86399 range since there are 24*60*60 (86400) seconds in a day.
<syntaxhighlight lang="c++">
var now = time(); // Typical</syntaxhighlight>
var now1 = var().time(); // range 0 - 86399 since there are 24*60*60 (86400) seconds in a day.
// or just
var now2 = time();</syntaxhighlight>
|-
|-
|var=||var.ostime()||Number of fractional seconds since last 00:00:00 (UTC).<br>
|var=||var.ostime()||Number of fractional seconds since last 00:00:00 (UTC).<br>
As floating point with approx. nanosecond resolution depending on hardware
As floating point with approx. nanosecond resolution depending on hardware
<syntaxhighlight lang="c++">var().ostime(); // e.g. 23343.704387955 if the time is within one second of 06:29:03
<syntaxhighlight lang="c++">
var now = ostime(); // Typical</syntaxhighlight>
var now1 = var().ostime(); // e.g. 23343.704387955 approx. 06:29:03 UTC
// or just
var now2 = ostime();</syntaxhighlight>
|-
|-
|var=||var.timestamp()||Number of fractional days since pick epoch 1967-12-31 00:00:00 UTC. Negative for dates before.<br>
|var=||var.timestamp()||Number of fractional days since pick epoch 1967-12-31 00:00:00 UTC. Negative for dates before.<br>
As floating point with approx. nanosecond resolution depending on hardware.
As floating point with approx. nanosecond resolution depending on hardware.
<syntaxhighlight lang="c++">var().timestamp(); was 20821.99998842593 around 2025-01-01 23:59:59 UTC
<syntaxhighlight lang="c++">
var now = ostimestamp(); // Typical</syntaxhighlight>
var now1 = var().timestamp(); // was 20821.99998842593 around 2025-01-01 23:59:59 UTC
// or just
var now2 = ostimestamp();</syntaxhighlight>
|-
|-
|var=||var.timestamp(ostime)||construct a timestamp from a date and time
|var=||var.timestamp(ostime)||construct a timestamp from a date and time
|-
|-
|cmd||var.ossleep(milliseconds)||Sleep/pause/wait for a number of milliseconds
|cmd||var.ossleep(milliseconds)||Sleep/pause/wait for a number of milliseconds
<syntaxhighlight lang="c++">var().ossleep(3000); // sleep for 3 seconds
<syntaxhighlight lang="c++">
ossleep(3000); // Typical</syntaxhighlight>
var().ossleep(3000); // sleep for 3 seconds
// or just
ossleep(3000);</syntaxhighlight>
|-
|-
|var=||var.oswait(milliseconds, directory)||Sleep/pause/wait for any activity in a file system directory for a number of milliseconds
|var=||var.oswait(milliseconds, directory)||Sleep/pause/wait for any activity in a file system directory for a number of milliseconds
<syntaxhighlight lang="c++">var().ossleep(3000, "."); // sleep for up to 3 seconds waiting for activity in current dir
<syntaxhighlight lang="c++">
ossleep(3000, "."); // Typical</syntaxhighlight>
var().ossleep(3000, "."); // sleep for up to 3 seconds waiting for activity in current dir
// or just
ossleep(3000, ".");</syntaxhighlight>
|}
|}


Line 1,066: Line 1,180:
|-
|-
|if||var.osshell()||Execute a shell command and return true if the process terminates with error status 0 and false otherwise.
|if||var.osshell()||Execute a shell command and return true if the process terminates with error status 0 and false otherwise.
<syntaxhighlight lang="c++">let cmd = "ls -l xyz";
<syntaxhighlight lang="c++">
if (not cmd.osshell())</syntaxhighlight>
let cmd = "ls -l xyz";
Alternative:
if (not cmd.osshell()) ...
<syntaxhighlight lang="c++">if (not osshell("ls -l xyz"))</syntaxhighlight>
// or
if (not osshell(cmd)) ...</syntaxhighlight>
|-
|-
|if||var.osshellread(oscmd)||Same as osshell but captures stdout
|if||var.osshellread(oscmd)||Same as osshell but captures stdout
<syntaxhighlight lang="c++">var text; if (not text.osshellread("ls -l xyz"))</syntaxhighlight>
<syntaxhighlight lang="c++">
Alternative: Capture stdout but ignore exit status
var intext;
<syntaxhighlight lang="c++">let text2 = osshellread("ls -l xyz");</syntaxhighlight>
if (not intext.osshellread("ls -l xyz")) ...
 
// or just capturing stdout but ignoring exit status
intext = osshellread("ls -l xyz");</syntaxhighlight>
|-
|-
|if||var.osshellwrite(oscmd)||
|if||var.osshellwrite(oscmd)||Same as osshell but provides stdin to the process
<syntaxhighlight lang="c++">
var outtext = ...
if (not outtext.osshellwrite("grep xyz")) ...
// or
if (not osshellwrite(outtext, "grep xyz")) ...</syntaxhighlight>
|-
|-
|var=||var.ostempdirpath()||
|var=||var.ostempdirpath()||Get the path of the tmp dir
<syntaxhighlight lang="c++">
var v1 = var.ostempdirpath(); // "/tmp/"
// or just
var v1 = ostempdirpath();</syntaxhighlight>
|-
|-
|var=||var.ostempfilename()||
|var=||var.ostempfilename()||Create and get a temporary file
<syntaxhighlight lang="c++">
var tempfilename1 = var().ostempfilename(); // "/tmp/~exoEcLj3C"
// or just
var tempfilename2 = ostempfilename();</syntaxhighlight>
|-
|-
|if||var.osgetenv(envcode)||
|if||var.osgetenv(envcode)||Get the value of an environment variable
<syntaxhighlight lang="c++">
var home1;
if (not home1.osgetenv("HOME")) ... // "/home/exodus"
// or just
var home2 = osgetenv("HOME");</syntaxhighlight>
|-
|-
|cmd||var.ossetenv(envcode)||
|cmd||var.ossetenv(envcode)||Set the value of an environment variable code
<syntaxhighlight lang="c++">
envvalue.ossetenv(envcode);
// or just
ossetenv(envcode, envvalue);</syntaxhighlight>
|-
|-
|var=||var.ospid()||
|var=||var.ospid()||Get the os process id
<syntaxhighlight lang="c++">
let pid = var().ospid(); // 663237
// or just
let pid = ospid();</syntaxhighlight>
|-
|-
|var=||var.ostid()||
|var=||var.ostid()||Get the os thread process id
<syntaxhighlight lang="c++">
let tid = var().ostid(); // 663237
// or just
let tid = ostid();</syntaxhighlight>
|}
|}



Revision as of 10:28, 28 January 2025

ICONV/OCONV PATTERNS

Decimal (MD/MC)

input conversion (string) output
1234 MD2 12.34
1234 MD20 1234.00
1234 MD20, 1,234.00
1234.5678 MD2 12.35
1234.5678 MD20 1234.57
1234.5678 MD20, 1,234.57
1234 MC2 12,34
1234 MC20 1234,00
1234 MC20, 1.234,00
1234 MD20- 1234.00

Date (D)

input conversion (string) output
12345 D 18 OCT 2001
12345 D/ 10/18/2001
12345 D- 10-18-2001
12345 D2 18 OCT 01
12345 D/E 18/10/2001
12345 DS 2001 OCT 18
12345 DS/ 2001/10/18
12345 DM 10
12345 DMA OCTOBER
12345 DY 2001
12345 DY2 01
12345 DD 18
12345 DW 4
12345 DWA THURSDAY
12345 DQ 4
12345 DJ 291
12345 DL 31

Time (MT)

input conversion (string) output
234800 MT 17:13
234800 MTH 05:13PM
234800 MTS 17:13:20
234800 MTHS 05:13:20PM
0 MT 00:00
0 MTH 12:00AM
0 MTS 00:00:00
0 MTHS 12:00:00AM

Hex (HEX/MX)

input conversion (string) output
ab HEX (same as HEX8 or HEX4 depending on platform)
ab HEX8 0000006100000062
ab HEX4 00610062
ab HEX2 6162
15 MX F
254 MX FE
255 MX FF
256 MX 100
27354234 MX 1A1647A

Text (L/R/T)

input conversion (string)output
abcd L#3 abc
ab L#3 ab␣
abcd R#3 bcd
ab R#3 ␣ab
ab T#3 ab␣
abcd T#3 abc™d␣␣
42 L(0)#5 42000
42 R(0)#5 00042
42 T(0)#5 42000

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.

You can list the contents of a dictionary by typing "list dict_filename".

Exodus Dictionary Format

0 DICTID Field/Column Code
1 DICTTYPE "F" or "S" : "F" means use Field No (i.e. raw data) and "S" means use Source Code (i.e. a function).
2 FIELDNO Field number (0=key, 1=field 1 etc for "Fields"
3 TITLE Title on reports
4 SM S or M or Mnn : "Single Value" or "Multivalue" or "Multivalue Group nn"
5 KEYPARTNO Multipart keys are separated by * characters.
6
7 CONVERSION Conversion (MD/MT/D etc.)
8 SOURCE Source Code of a subroutine to calculate the field. Multivalues are lines and the result must be placed in a variable "ANS".
9 JUST "L" or "R" or "T" requesting left, right or text justification
10 WIDTH Column Width on fixed width reports

Sort/Select Command

Exodus provides the classic multivalue sort/select command within any Exodus program followed by readnext().

Classic multivalue select/readnext functions only provide the keys of the selected records. Exodus provides the classic select/readnext and also selectrecords/readnextrecord which provides complete records instead of just keys.

The format of the select/sselect command is as follows:

 SELECT|SSELECT

 {max_number_of_records}

 {using filename}

 filename

 {datakeyvalue} ...

 {BY|BY-DSND fieldname} ...
 
 {

  WITH

  {NO|ALL|ANY}

  dict_field_id

  {
   CONTAINING|STARTING|ENDING|LIKE|EQ|NE|NOT|GT|LT|GE|LE=|<>|>|<|>=|<= value(s)
   |
   BETWEEN value AND value
  }

  {AND|OR}

 } ...

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.converter("ab", "cd")

instead of

v1 = trim(v1);
// or
v1 = v1.trim();

Function Types

TYPE FUNCTION TYPE
var= traditional functions that return values and can be used in expressions and be on the right hand side of assignments
if traditional conditional statements that started with "if" or ended with "then/else" (or could have)
cmd traditional commands with no outputs
exp traditional commands that now have outputs and can be used in expressions

Parameters/Argument Types

in Parameters that provide data to the function. Can be variables or raw data like 1 or "X"
unspecified Same as "in". Omission of the most common type de-clutters the documentation. NB When defining your own subroutines and functions "in" cannot be omitted from the source code.
io Parameters that may provide and/or return data. Must be variables. Cannot be raw data like 1 or "X"
out Parameters that return data. Must be variables. Cannot be raw data like 1 or "X"

Optional Parameters

Key Default
="" ""
=" " " "
="." "."
=1 1
=0 0
=true true
=false false

Complete List of Functions

Math/Boolean
Usage Function Comment
var= var.abs() Absolute value
var(-12.34).abs(); // 12.34
var= var.pwr(exponent) Power
var(2).pwr(8); // 256
var= var.rnd() Random number generator
var(100).rnd(); // 0 to 99 pseudo random
cmd var.initrnd() Initialise Random seed
var(123).initrnd(); // Set pseudo random seed to 123
var= var.exp() Power of e
var(1).exp(); // 2.718281828459045
var= var.sqrt() Square root
var(100).sqrt(); // 10
var= var.sin() Sine of degrees
var(30).sin(); // 0.5
var= var.cos() Cosine of degrees
var(60).cos(); // 0.5
var= var.tan() Tangent of degrees
var(45).tan(); // 1
var= var.atan() Arctangent of degrees
var(1).atan(); // 45
var= var.loge() Natural logarithm
var(2.718281828459045).loge(); // 1
var= var.integer() Truncate decimal numbers towards zero.
var(2.9).integer(); // 2
var(-2.9).integer(); // -2
var= var.floor() Truncate decimal numbers towards negative
var(2.9).floor(); // 2
var(-2.9).floor(); // -3
var= var.round(ndecimals = 0) Round decimal numbers to a desired number of decimal places

.5 rounds away from zero.

var(23.455).round(2); // "23.46"
var(-23.455).round(2); // "-23.46"
var= var.mod(divisor) Remainder function

Result is between [0 , limit) if limit is positive
Result is between (limit, 0] if limit is negative

var(7).mod(5); // 2
mod(7, 5); // ditto
Locale
Usage Function Comment
expr var.getxlocale() Gets the current thread's default locale codepage code
var().getxlocale(); // e.g. "en_US.utf8"
getxlocale(); // ditto
if var.setxlocale() Sets the current thread's default locale codepage code
"de_DE.utf8"_var.setxlocale(); // true if successful
setxlocale("de_DE.utf8"); // ditto
String Creation
Usage Function Comment
var= var.chr(num) Create a string of a single char (byte) given an integer 0-255.

0-127 -> ASCII, 128-255 -> invalid UTF-8 so cannot be written to database or used various exodus string operations

var().chr(0x61); // "a"
chr(0x61); // ditto
var= var.textchr(num) Create a string of a single unicode code point in utf8 encoding.

To get utf codepoints > 2^63 you must provide negative ints
Not providing implicit constructor from var to unsigned int due to getting ambigious conversions
since int and unsigned int are parallel priority in c++ implicit conversions

var().textchr(171416); // "𩶘" or "\xF0A9B698"
textchr(171416); // ditto
var= var.str(num) Create a string by repeating a given character or string
"ab"_var.str(3); // "ababab"
str("ab"_var, 3); // ditto
var= var.space() Create string of space characters.
var(3).space(); // "␣␣␣"
space(3); // ditto
var= var.numberinwords(languagename_or_locale_id = "") Create a string describing a given number in words
var(123.45).numberinwords("de_DE").outputl();
//"ein­hundert­drei­und­zwanzig Komma vier fünf"
String Scanning
Usage Function Comment
var= var.seq() Returns the character number of the first char.
"abc"_var.seq(); // 0x61 97
seq("abc"_var); // 0x61 97
var= var.textseq() Returns the Unicode character number of the first unicode code point.
"Γ"_var.textseq(); // 915 U+0393: Greek Capital Letter Gamma (Unicode Character)
textseq("Γ"); // ditto
var= var.len() Returns the length of a string in number of chars
"abc"_var.len(); // 3
len("abc"_var); // ditto
var= var.textwidth() Returns the number of output columns.

Allows multi column unicode and reduces combining characters etc. like e followed by grave accent
Possibly does not properly calculate combining sequences of graphemes e.g. face followed by colour

"🤡x🤡"_var.textwidth(); // 5
textwidth("🤡x🤡"_var); // ditto
var= var.textlen() Returns the number of Unicode code points
"Γιάννης"_var.textlen(); // 7
textlen("Γιάννης"_var); // ditto
var= var.fcount(sepstr) Returns the number of fields separated by sepstr present.

It is the same as var.count(sepstr) + 1 except that and empty string returns 0

"a1**c3"_var.fcount("*"); // 3
fcount("a1**c3"_var, "*"); // ditto
var= var.count(sepstr) Return the number of sepstr found
"a1*b2*c3"_var.count("*"); // 3
count("a1*b2*c3"_var, "*"); // ditto
if var.starts(prefix) Returns true if starts with prefix
"abc"_var.starts("ab"); // true
if var.ends(suffix) Returns true if ends with suffix
"abc"_var.ends("bc"); // true
if var.contains(substr) Return true if starts, ends or contains substr
"abcd"_var.contains("bc"); // true
var= var.index(substr, startchar1 = 1) Returns char no if found or 0 if not. startchar1 is byte no to start at.
"abcd"_var.index("bc"); // 2
var= var.indexn(substr, occurrence) ditto. Occurrence 1 = find first occurrence
"abcabc"_var.index("bc", 2); // 5
var= var.indexr(substr, startchar1 = -1) ditto. Reverse search.

startchar1 defaults to -1 meaning start searching from the last byte

"abcabc"_var.indexr("bc"); // 5
var= var.match(regex, regex_options = "") Returns all results of regex matching

Multiple matches are in fields
Groups are in values

"abc1abc2"_var.match("bc(\\d)"_rex); // "bc1]1^bc2]2"
var= var.match(regex) Ditto
var= var.search(regex, io startchar1, regex_options = "") Search for first match of a regular expression starting at startchar1

Updates startchar1 ready to search for the next match

var startchar1 = 1;
"abc1abc2"_var.search("bc(\\d)", startchar1); // returns "bc1]1"
// startchar1 becomes 5 ready for the next search
var= var.search(regex) Ditto starting from first char
var= var.search(regex, io startchar1) Ditto given a rex
var= var.search(regex) Ditto starting from first char.
String Conversion - Chainable. Non-Mutating
Usage Function Comment
var= var.ucase() To upper case
"Γιάννης"_var.ucase(); // "ΓΙΆΝΝΗΣ"
var= var.lcase() Lower case
"ΓΙΆΝΝΗΣ"_var.lcase(); // "γιάννης"
var= var.tcase() Title case (first letters)
"γιάννης"_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
"abc"_var.invert(); // "\x{C29EC29DC29C}"
var= var.lower() Convert all FM to VM, VM to SM etc.
"a1^b2^c3"_var.lower(); // "a1]b2]c3"
var= var.raise() Convert all VM to FM, SM to VM etc.
"a1]b2]c3"_var.raise(); // "a1^b2^c3"
var= var.crop() Remove any redundant FM, VM etc. characters (Trailing FM; VM before FM etc.)
"a1^b2]]^c3^^"_var.crop(); // "a1^b2^c3"
var= var.quote() Wrap in double quotes
"abc"_var.quote(); // ""abc""
var= var.squote() Wrap in single quotes
"abc"_var.squote(); // "'abc'"
var= var.unquote() Remove one pair of double or single quotes
"'abc'"_var.unquote(); // "abc"
var= var.trim(trimchars = " ") Remove leading, trailing and excessive inner bytes
"␣␣a1␣␣b2␣c3␣␣"_var.trim(); // "a1␣b2␣c3"
var= var.trimfirst(trimchars = " ") Ditto leading
"␣␣a1␣␣b2␣c3␣␣"_var.trimfirst(); // "a1␣␣b2␣c3␣␣"
var= var.trimlast(trimchars = " ") Ditto trailing
"␣␣a1␣␣b2␣c3␣␣"_var.trimlast(); // "␣␣a1␣␣b2␣c3"
var= var.trimboth(trimchars = " ") Ditto leading, trailing but not inner
"␣␣a1␣␣b2␣c3␣␣"_var.trimboth(); // "a1␣␣b2␣c3"
var= var.first() Extract first char or "" if empty
"abc"_var.first(); // "a"
var= var.last() Extract last char or "" if empty
"abc"_var.last(); // "c"
var= var.first(std::size_t length) Extract up to length leading chars
"abc"_var.first(2); // "ab"
var= var.last(std::size_t length) Extract up to length trailing chars
"abc"_var.last(2); // "bc"
var= var.cut(length) Remove length leading chars
"abcd"_var.cut(2); // "cd"
var= var.paste(pos1, length, insertstr) Insert text at char position overwriting length chars
"abcd"_var.paste(2, 2, "XYZ"); // "aXYZd"
var= var.paste(pos1, insertstr) Insert text at char position without overwriting any following characters
"abcd"_var.paste(2, "XYZ"); // "aXYbcd"
var= var.prefix(insertstr) Insert text at the beginning
"abc"_var.prefix("XY"); // "XYabc"
var= var.pop() Remove one trailing char
"abc"_var.pop(); // "ab"
var= var.fieldstore(separator, fieldno, nfields, replacement) fieldstore() replaces nfields of subfield(s) in a string.
"aa*bb*cc*dd"_var.fieldstore("*", 2, 3, "X*Y"); // "aa*X*Y*"

If nfields is 0 then insert fields before fieldno

"a1*b2*c3*d4"_var.fieldstore("*", 2, 0, "X*Y"); // "a1*X*Y*b2*c3*d4"

If nfields is negative then delete nfields before inserting.

"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
"abcd"_var.substr(2, 2); // "bc"

If length is negative then work backwards and return chars reversed

"abcd"_var.substr(3, -2); // "cb"
var= var.substr(startindex1) substr version 2. Extract all chars from startindex1 up to the end
"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.
"abcde"_var.convert("aZd", "XY"); // "Xbce" (a is replaced and d is removed)
var= var.textconvert(fromchars, tochars) Ditto for Unicode code points.
"🤡😀✌"_var.textconvert("🤡😀", "👋"); // "👋✌ "
var= var.replace(fromstr, tostr) Replace all occurrences of a substr with another. Case sensitive
"Abc Abc"_var.replace("bc", "X"); // "AX AX"
var= var.replace(regex, tostr) Replace substring(s) using a regular expression.

Use $0, $1, $2 in tostr to refer to groups defined in the regex.

"A a B b"_var.replace("[A-Z]"_rex, "'$0'"); // "'A' a 'B' b"
var= var.unique() Remove duplicate fields in an FM or VM etc. separated list
"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
"20^10^2^1^1.1"_var.sort(); // "1^1.1^2^10^20"
"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
"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
"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;
"abc,\"def,\"123\" fgh\",12.34"_var.parse(','); // "abc^"def,"123" fgh"^12.34"
String Mutators Not Chainable. All Similar To Non-Mutators
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
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.
"aa*bb*cc"_var.field("*", 2);m // "bb"
var= var.field2(separator, fieldno, nfields = 1) field2 is a version that treats fieldn -1 as the last field, -2 the penultimate field etc. -

TODO Should probably make field() do this (since -1 is basically an erroneous call) and remove field2
Same as var.field() but negative fieldnos work backwards from the last field. `"aa*bb*cc"_var.field("*", -1); // "cc"

I/O Conversion
Usage Function Comment
var= var.oconv(convstr) Converts to output format
var(30123).oconv("D/E"); // "21/06/2050"
var= var.iconv(convstr) Converts to input format
"21 JUN 2050"_var.iconv("D/E"); // 30123
var= var.format(fmt_str, Args&&... args) Classic format function in printf style
format("Text and aligned {:9.2f} number", var(123.456)); // "Text and aligned ␣␣␣123.46 number"
var= var.from_codepage(codepage) Converts from codepage encoded text to UTF-8 encoded text

e.g. Codepage "CP1251" (Ukrainian).
Use Linux command "iconv -l" for complete list of code pages and encodings.

var= var.to_codepage(codepage) Converts to codepage encoded text from UTF-8 encoded text
Basic Dynamic Array Functions
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.

"f()" can be thought of as "field" although the function can extract values and subvalues as well.
The convenient PICK OS angle bracket syntax for field extraction (e.g. xxx<20>) is not available in C++.
The abbreviated exodus field extraction function (e.g. xxx.f(20)) is provided instead since field access is extremely heavily used in source code.

"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.

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.
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.

"remove" was called "delete" in Pick OS.

Dynamic Array Filters
Usage Function Comment
var= var.sum() Sum up multiple values into one higher level
"1]2]3^4]5]6"_var.sum(); // "6^15"
var= var.sumall() Sum up all levels into a single figure
"1]2]3^4]5]6"_var.sumall(); // "21"
var= var.sum(sepchar) Ditto allowing commas etc.
"10,20,33"_var.sum(","); // "60"
var= var.mv(opcode, var2) Binary ops (+, -, *, /) in parallel on multiple values
"10]20]30"_var.mv("+","2]3]4"); // "12]23]34"
Dynamic Array Mutators (Standalone And Cannot Be Chained)
Usage Function Comment
cmd var.r(fieldno, replacement) Replaces a specific field in a dynamic array
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.r(2, 2, "X"); // v1 -> "f1^X^f3"
cmd var.r(fieldno, valueno, replacement) Ditto for specific value in a specific field.
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.r(2, 2, "X"); // v1 -> "f1^v1]X^f3"
cmd var.r(fieldno, valueno, subvalueno, replacement) Ditto for a specific subvalue in a specific value of a specific field
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.r(2, 2, 2, "X"); // v1 -> "f1^v1]v2}X}s3^f3"
cmd var.inserter(fieldno, insertion) Insert a specific field in a dynamic array, moving all other fields up.
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.inserter(2, "X"); // v1 -> "f1^X^v1]v2}s2}s3^f3"
cmd var.inserter(fieldno, valueno, insertion) Ditto for a specific value in a specific field, moving all other fields up.
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.inserter(2, 2, "X"); // v1 -> "f1^v1]X]v2}s2}s3^f3"
cmd var.inserter(fieldno, valueno, subvalueno, insertion) Ditto for a specific subvalue in a dynamic array, moving all other subvalues up.
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.inserter(2, 2, 2, "X"); // v1 -> "f1^v1]v2}X}s2}s3^f3"
cmd var.remover(fieldno, valueno = 0, subvalueno = 0) Remove a specific field (or value, or subvalue) from a dynamic array, moving all other fields (or values, or subvalues) down.
var v1 = "f1^v1]v2}s2}s3^f3"_var;
v1.remover(2, 2); // v1 -> "f1^v1^f3"
Dynamic Array Search
Usage Function Comment
if var.locate(target) locate() with only the target substr argument provided searches unordered values separated by VM chars.

Returns true if found and false if not.

if ("UK]US]UA"_var.locate("US")) ... // true
if var.locate(target, out valueno) locate() with only the target substr and valueno arguments provided searches unordered values separated by VM chars.

Returns true if found and with the value number in valueno.
Returns false if not found and with the max value number + 1 in setting. Suitable for additiom of new values

var valueno; if ("UK]US]UA"_var.locate("US", valueno)) ... // returns true and valueno = 2
if var.locate(target, out setting, fieldno, valueno = 0) locate() the target in unordered fields if fieldno is 0, or values if a fieldno is specified, or subvalues if the valueno argument is provided.

Returns true if found and with the field, value or subvalue number in setting.
Returns false if not found and with the max field, value or subvalue number found + 1 in setting. Suitable for replacement of new fields, values or subvalues.

var setting; if ("f1^f2v1]f2v2]s1}s2}s3}s4^f3^f4"_var.locate("s4", setting, 2, 3)) ... // returns true and setting = 4
if var.locateby(ordercode, target, out valueno) locateby() without fieldno or valueno arguments searches ordered values separated by VM chars.

The order code can be AL, DL, AR, DR meaning Ascending Left, Descending Right, Ascending Right, Ascending Left.
Left is used to indicate alphabetic order where 10 < 2.
Right is used to indicate numeric order where 10 > 2.
Data must be in the correct order for searching to work properly.
Returns true if found.
In case the target is not exactly found then the correct value no for inserting the target is returned in setting.

var valueno; if ("aaa]bbb]ccc"_var.locateby("AL", "bb", valueno)) ... // returns false and valueno = 2 where it could be correctly inserted.
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.
var setting; if ("f1^f2^aaa]bbb]ccc^f4"_var.locateby("AL", "bb", setting, 3)) ... // returns false and setting = 2 where it could be correctly inserted.
if var.locateusing(usingchar, target) locate() a target substr in the whole unordered string using a given delimiter char returning true if found.

if (`"AB,EF,CD"_var.locateusing(",", "EF")) ... // true

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 and unordered data

Returns true If found and returns in setting the number of the delimited field found.
Returns false if not found and returns in setting the maximum number of delimited fields + 1 if not found.
This is similar to the main locate command but the delimiter char can be specified e.g. a comma or TM etc.

var setting; if ("f1^f2^f3c1,f3c2,f3c3^f4"_var.locateusing(",", "f3c2", setting, 3)) ... // returns true and setting = 2
if var.locatebyusing(ordercode, usingchar, target, out setting, fieldno = 0, valueno = 0, subvalueno = 0) locatebyusing() supports all the above features in a single function.

Returns true if found.

Database Access
Usage Function Comment
if var.connect(conninfo = "") for all db operations, var() can be a db connection or a default connection.
var db="mydb";
if (not db.connect()) abort(db.lasterror());
db.version().outputl();
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
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()
if var.read(filehandle, key) DB file i/o
cmd var.write(filehandle, key)
if var.deleterecord(key)
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
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
Usage Function Comment
var= var.date() Number of whole days since pick epoch 1967-12-31 00:00:00 UTC. Negative for dates before.
var today1 = var().date(); // e.g. was 20821 from 2025-01-01 00:00:00 UTC
// or just
var today2 = date();
var= var.time() Number of whole seconds since last 00:00:00 (UTC).
var now1 = var().time(); // range 0 - 86399 since there are 24*60*60 (86400) seconds in a day.
// or just
var now2 = time();
var= var.ostime() Number of fractional seconds since last 00:00:00 (UTC).

As floating point with approx. nanosecond resolution depending on hardware

var now1 = var().ostime(); // e.g. 23343.704387955 approx. 06:29:03 UTC
// or just
var now2 = ostime();
var= var.timestamp() Number of fractional days since pick epoch 1967-12-31 00:00:00 UTC. Negative for dates before.

As floating point with approx. nanosecond resolution depending on hardware.

var now1 = var().timestamp(); // was 20821.99998842593 around 2025-01-01 23:59:59 UTC
// or just
var now2 = ostimestamp();
var= var.timestamp(ostime) construct a timestamp from a date and time
cmd var.ossleep(milliseconds) Sleep/pause/wait for a number of milliseconds
var().ossleep(3000); // sleep for 3 seconds
// or just
ossleep(3000);
var= var.oswait(milliseconds, directory) Sleep/pause/wait for any activity in a file system directory for a number of milliseconds
var().ossleep(3000, "."); // sleep for up to 3 seconds waiting for activity in current dir
// or just
ossleep(3000, ".");
OS Files
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
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
Usage Function Comment
if var.osshell() Execute a shell command and return true if the process terminates with error status 0 and false otherwise.
let cmd = "ls -l xyz";
if (not cmd.osshell()) ...
// or
if (not osshell(cmd)) ...
if var.osshellread(oscmd) Same as osshell but captures stdout
var intext;
if (not intext.osshellread("ls -l xyz")) ...

// or just capturing stdout but ignoring exit status
intext = osshellread("ls -l xyz");
if var.osshellwrite(oscmd) Same as osshell but provides stdin to the process
var outtext = ...
if (not outtext.osshellwrite("grep xyz")) ...
// or
if (not osshellwrite(outtext, "grep xyz")) ...
var= var.ostempdirpath() Get the path of the tmp dir
var v1 = var.ostempdirpath(); // "/tmp/"
// or just
var v1 = ostempdirpath();
var= var.ostempfilename() Create and get a temporary file
var tempfilename1 = var().ostempfilename(); // "/tmp/~exoEcLj3C"
// or just
var tempfilename2 = ostempfilename();
if var.osgetenv(envcode) Get the value of an environment variable
var home1;
if (not home1.osgetenv("HOME")) ... // "/home/exodus"
// or just
var home2 = osgetenv("HOME");
cmd var.ossetenv(envcode) Set the value of an environment variable code
envvalue.ossetenv(envcode);
// or just
ossetenv(envcode, envvalue);
var= var.ospid() Get the os process id
let pid = var().ospid(); // 663237
// or just
let pid = ospid();
var= var.ostid() Get the os thread process id
let tid = var().ostid(); // 663237
// or just
let tid = ostid();
Output
Usage Function Comment
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
expr var.logput(prefix) stdlog with a prefix, no new line, buffered
expr var.logputl(prefix) stdlog with a prefix, starts a new line, flushed
expr var.errput(prefix) stderr with a prefix, no new line, flushed
expr var.errputl(prefix) stderr with a prefix, starts a new line, flushed
expr var.put(std::ostream& ostream1) Output to a given stream
Standard Input
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
if var.hasinput(milliseconds = 0) true if stdin bytes available within milliseconds
if var.eof() true if stdin is at end of file
if var.echo(on_off) Reflect all stdin to stdout if terminal available
cmd var.breakon() Allow interrupt Ctrl+C
cmd var.breakoff() Prevent interrupt Ctr+C