| Purpose | The following functions are used in Superx++ within the <expr> clause of the <eval> statement to perform various calculation functions. These functions are not methods because they do not belong to any class or object. | |
| The Calculation Functions | ||
| abs | ||
| returns the absolute value of a number | ||
|
<eval> <expr>abs({number})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>-7</Number> </node> <xout>abs = </xout> <xout> <eval> <parm type="int" name="a_Num"> <eval object="MyStudent/Number" /> </parm> <expr>abs(a_Num)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| asc | ||
| returns the ASCII code of the first character of a string | ||
|
<eval> <expr>asc({string})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>-7</Number> </node> <xout>asc = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Name" /> </parm> <expr>asc(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| base | ||
| converts a number from one base to another and returns the converted number in base specified format | ||
|
<eval> <expr>base({number}, {source base}, {dest base})</expr> </eval>
where:
The resulting number will be rendered in base specified format. Make sure to include the commas around the place for the {source base} parameter even though it is omitted. |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>255</Number> </node> <xout>base = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Number" /> </parm> <expr>base(a_Val, 10, 16)</expr> </eval> </xout> <xout>\r\nbase (again) = </xout> <xout> <eval> <parm type="string" name="a_Val">b2_11111111</parm> <expr>base(a_Val,, 16)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| ceil | ||
| returns the nearest whole number larger than the numerical argument | ||
|
<eval> <expr>ceil({number})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>8.5</Number> </node> <xout>ceil = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Number" /> </parm> <expr>ceil(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| chr | ||
| returns the character represented by an ASCII code value | ||
|
<eval> <expr>chr({number})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>65</Number> </node> <xout>chr = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Number" /> </parm> <expr>chr(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| cos | ||
| returns the cosine of a number | ||
|
<eval> <expr>cos({number})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> </node> <xout>cos = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Number" /> </parm> <expr>cos(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| date | ||
| returns the date from a string | ||
|
<eval> <expr>date({string})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> </node> <xout>date = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Born" /> </parm> <expr>date(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| day | ||
| returns the day of the month from a date | ||
|
<eval> <expr>day({date})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> </node> <xout>day = </xout> <xout> <eval> <parm type="date" name="a_Val"> <eval object="MyStudent/Born" /> </parm> <expr>day(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| dayofweek | ||
| returns the day of the week from a date | ||
|
<eval> <expr>dayofweek({date})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> </node> <xout>day of week = </xout> <xout> <eval> <parm type="date" name="a_Val"> <eval object="MyStudent/Born" /> </parm> <expr>dayofweek(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| dayofyear | ||
| returns the day of the year from a date | ||
|
<eval> <expr>dayofyear({date})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> </node> <xout>day of year = </xout> <xout> <eval> <parm type="date" name="a_Val"> <eval object="MyStudent/Born" /> </parm> <expr>dayofyear(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| find/instr | ||
| returns the index of the first character of a string found within another string, where the search began at a specified index position | ||
|
<eval> <expr>find({string}, {substring}, {index})</expr> </eval>
<eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> </node> <xout>find = </xout> <xout> <eval> <parm type="string" name="a_Str"> <eval object="MyStudent/Name" /> </parm> <parm type="string" name="a_Sub">Good</parm> <expr>find(a_Str, a_Sub, 0)</expr> </eval> </xout> <xout>\r\n2nd find = </xout> <xout> <eval> <parm type="string" name="a_Str"> <eval object="MyStudent/Name" /> </parm> <parm type="string" name="a_Sub">Good</parm> <expr>find(a_Str, a_Sub, 12)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| floor | ||
| returns the nearest whole number smaller than the numerical argument | ||
|
<eval> <expr>floor({number})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>8.5</Number> </node> <xout>floor = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Number" /> </parm> <expr>floor(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| format | ||
| returns a string of a formatted date or number | ||
|
<eval> <expr>format({date}, {format string})</expr> </eval>
<eval>
where:
For details on the format strings for dates click here. |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>27.37</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>format number = </xout> <xout> <eval> <parm type="float" name="a_Val"> <eval object="MyStudent/Number" /> </parm> <expr>format(a_Val, "999.9")</expr> </eval> </xout> <xout>format date = </xout> <xout> <eval> <parm type="date" name="a_Val"> <eval object="MyStudent/LastUpd" /> </parm> <expr>format(a_Val, "%B %d %Y")</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| hour | ||
| returns the hour from the time portion of a date | ||
|
<eval> <expr>hour({date})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>hour = </xout> <xout> <eval> <parm type="date" name="a_Val"> <eval object="MyStudent/LastUpd" /> </parm> <expr>hour(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| isnull | ||
| returns true if the argument evaluates to "" | ||
|
<eval> <expr>isnull({string})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>isnull = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Name" /> </parm> <expr>isnull(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| left | ||
| returns a specific number of characters starting from the beginning of a string | ||
|
<eval> <expr>left({string}, {number of characters})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>left = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Name" /> </parm> <expr>left(a_Val, 4)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| len | ||
| returns the number of characters in a string | ||
|
<eval> <expr>len({string})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>len = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Name" /> </parm> <expr>len(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| lower | ||
| returns the lowercase converted version of a string | ||
|
<eval> <expr>lower({string})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>lower = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Name" /> </parm> <expr>lower(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| ltrim | ||
| strips off the leftmost spaces before the first non-space character in a string and returns the resulting string | ||
|
<eval> <expr>ltrim({string})</expr> </eval>
where: |
||
|
<var type="string" name="MyVar"> A string </var> <xout>ltrim = </xout> <xout> <eval> <parm type="string" name="str"><eval object="MyVar" /></parm> <expr>ltrim(str)</expr> </eval> </xout> <xout>.</xout>
This code sends the following text to the output stream: |
||
| mid | ||
| returns a specific number of characters starting from a specific position in a string | ||
|
<eval> <expr>mid({string}, {position}, {number of characters})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>mid = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Name" /> </parm> <expr>mid(a_Val, 8, 7)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| minute | ||
| returns the minutes from the time portion of a date | ||
|
<eval> <expr>minute({date})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>minutes = </xout> <xout> <eval> <parm type="date" name="a_Val"> <eval object="MyStudent/LastUpd" /> </parm> <expr>minute(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| month | ||
| returns the month from a date | ||
|
<eval> <expr>month({date})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>month = </xout> <xout> <eval> <parm type="date" name="a_Val"> <eval object="MyStudent/LastUpd" /> </parm> <expr>month(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| not | ||
| returns the inversion of a boolean argument | ||
|
<eval> <expr>not({boolean})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> <LikesMusic>true</LikesMusic> </node> <xout>not = </xout> <xout> <eval> <parm type="bool" name="a_Val"> <eval object="MyStudent/LikesMusic" /> </parm> <expr>not(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| now | ||
| returns the current date and time | ||
|
<eval> <expr>now()</expr> </eval> |
||
|
<xout>now = </xout> <xout> <eval> <expr>now(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| replace | ||
| replaces all occurences of string A in string B with string C | ||
|
<eval> <expr>replace({string}, {replacee}, {replacer})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Bald I. Baldwin</Name> </node> <xout>replace = </xout> <xout> <eval> <parm type="string" name="a_Str"> <eval object="MyStudent/Name" /> </parm> <parm type="string" name="a_Replacee">Bald</parm> <parm type="string" name="a_Replacer">Gold</parm> <expr>replace(a_Str, a_Replacee, a_Replacer)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| reverse | ||
| returns the reversed version of a string | ||
|
<eval> <expr>reverse({string})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>reverse = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Name" /> </parm> <expr>reverse(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| right | ||
| returns a specific number of characters starting from the end of a string | ||
|
<eval> <expr>right({string}, {number of characters})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>right = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Name" /> </parm> <expr>right(a_Val, 5)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| round | ||
| returns the rounded version of a number | ||
|
<eval> <expr>round({number}, {dec places})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>27.06</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>round = </xout> <xout> <eval> <parm type="double" name="a_Val"> <eval object="MyStudent/Number" /> </parm> <expr>round(a_Val, 1)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| rtrim | ||
| strips off the rightmost spaces after the last non-space character in a string and returns the resulting string | ||
|
<eval> <expr>rtrim({string})</expr> </eval>
where: |
||
|
<var type="string" name="MyVar"> A string </var> <xout>rtrim = </xout> <xout> <eval> <parm type="string" name="str"><eval object="MyVar" /></parm> <expr>rtrim(str)</expr> </eval> </xout> <xout>.</xout>
This code sends the following text to the output stream: |
||
| second | ||
| returns the seconds from the time portion of a date | ||
|
<eval> <expr>second({date})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>seconds = </xout> <xout> <eval> <parm type="date" name="a_Val"> <eval object="MyStudent/LastUpd" /> </parm> <expr>second(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| sin | ||
| returns the sine of a number | ||
|
<eval> <expr>sin({number})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> </node> <xout>sin = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Number" /> </parm> <expr>sin(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| tan | ||
| returns the tangent of a number | ||
|
<eval> <expr>tan({number})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> </node> <xout>tan = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Number" /> </parm> <expr>tan(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| today | ||
| returns the current date without the time portion | ||
|
<eval> <expr>today()</expr> </eval> |
||
|
<xout>today = </xout> <xout> <eval> <expr>today(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| trunc/truncate | ||
| returns the date portion of a date with the time portion set to midnight | ||
|
<eval> <expr>trunc({datetime})</expr> </eval>
<eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>27.06</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>trunc = </xout> <xout> <eval> <parm type="date" name="a_Val"> <eval object="MyStudent/LastUpd" /> </parm> <expr>trunc(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| upper | ||
| returns the uppercase converted version of a string | ||
|
<eval> <expr>upper({string})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>upper = </xout> <xout> <eval> <parm type="string" name="a_Val"> <eval object="MyStudent/Name" /> </parm> <expr>upper(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||
| year | ||
| returns the year from a date | ||
|
<eval> <expr>year({date})</expr> </eval>
where: |
||
|
<node name="MyStudent"> <Name>Johnnie B. Goode</Name> <Number>0</Number> <Born>10-Jan-1980</Born> <LastUpd>24-May-2002 18:56:31</LastUpd> </node> <xout>year = </xout> <xout> <eval> <parm type="date" name="a_Val"> <eval object="MyStudent/LastUpd" /> </parm> <expr>year(a_Val)</expr> </eval> </xout>
This code sends the following text to the output stream: |
||