Fast/Unload standard functions: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (# in page title)
m (more conversion cleanup)
Line 9: Line 9:
and types of its arguments and the result (or "output value"),
and types of its arguments and the result (or "output value"),
one or more examples, any error conditions, and special notes.
one or more examples, any error conditions, and special notes.
<p></p>
 
Unless otherwise indicated, all arguments shown are required and are
Unless otherwise indicated, all arguments shown are required and are
input arguments, and any arguments with the <code>MISSING</code> value are treated
input arguments, and any arguments with the <code>MISSING</code> value are treated
Line 16: Line 16:
See [[Fast/Unload Extraction Language (FUEL)#funcall|#Function calls]] for an explanation of required/optional,
See [[Fast/Unload Extraction Language (FUEL)#funcall|#Function calls]] for an explanation of required/optional,
output, and other types of arguments.
output, and other types of arguments.
<p></p>
 
In some instances the behavior of a #function will be compared to
In some instances the behavior of a #function will be compared to
the behavior of a corresponding <var class="product">SOUL</var> [[List of $functions|$function]].
the behavior of a corresponding <var class="product">SOUL</var> [[List of $functions|$function]].
<p></p>
 
FUEL also contains program entities called "special variables" that
FUEL also contains program entities called "special variables" that
might be initially mistaken for #functions.
might be initially mistaken for #functions.
Similar to #functions in appearance and syntax, special variables
Similar to #functions in appearance and syntax, special variables
are described in [[Fast/Unload Extraction Language (FUEL)#spvars|Special variables]].
are described in [[Fast/Unload Extraction Language (FUEL)#spvars|Special variables]].
<p></p>
 
Unless otherwise indicated, all input strings of the
Unless otherwise indicated, all input strings of the
standard #functions are treated as non-DBCS, and all output strings
standard #functions are treated as non-DBCS, and all output strings
have type of non-DBCS.
have type of non-DBCS.
<p></p>
In addition to the reference material in this wiki page, the index
contains a major heading labelled <b>#Function prototypes</b>.
Under this heading are minor headings containing the form of the
<nowiki>#functions</nowiki>, for your convenient reference.
<!-- .im funfunc-->
<!-- .im funfunc-->
   
   
Line 39: Line 34:
<!--Caution: <div> above-->
<!--Caution: <div> above-->
   
   
<p></p>
The default approach for handling errors in calls to standard
The default approach for handling errors in calls to standard
<nowiki>#functions</nowiki> is strict:
<nowiki>#functions</nowiki> is strict:
Line 46: Line 40:
avoid as serious and
avoid as serious and
terminates the run, if you have not provided for checking of
terminates the run, if you have not provided for checking of
the error.
the error. </li>
 
<li>At termination, <var class="product">Fast/Unload</var> will issue a message describing
<li>At termination, <var class="product">Fast/Unload</var> will issue a message describing
the nature of the error, the input program line number being
the nature of the error, the input program line number being
executed and, if the error occurred during the execution of
executed and, if the error occurred during the execution of
a #function, a dump of the current value of each #function
a #function, a dump of the current value of each #function
argument.
argument. </li>
</ul>
</ul>
<p></p>
 
<var class="product">Fast/Unload</var> provides an optional
<var class="product">Fast/Unload</var> provides an optional
output "return code" argument for some #functions.
output "return code" argument for some #functions.
Line 64: Line 59:
If you omit the return code argument and there is an error
If you omit the return code argument and there is an error
in the value of an argument, the program is cancelled.
in the value of an argument, the program is cancelled.
<p></p>
 
For example, since 'ONE WEEK' isn't numeric, the following fragment:
For example, since 'ONE WEEK' isn't numeric, the following fragment:
<p class="code"><nowiki>%NEW_DT = #DATECHG('MM/DD/YY', '01/01/96', 'ONE WEEK',, -
<p class="code"><nowiki>%NEW_DT = #DATECHG('MM/DD/YY', '01/01/96', 'ONE WEEK',, -
Line 80: Line 75:
</nowiki></p>
</nowiki></p>
will cause <var class="product">Fast/Unload</var> to immediately terminate,
will cause <var class="product">Fast/Unload</var> to immediately terminate,
<p></p>
issuing an error message that a value is non-numeric, as shown in the
issuing an error message that a value is non-numeric, as shown in the
following sample from FUNPRINT:
following sample from FUNPRINT:
Line 92: Line 86:
FUNL0129 03=ONE WEEK.
FUNL0129 03=ONE WEEK.
</nowiki></p>
</nowiki></p>
<p></p>
 
Each #function description in this wiki page has a figure showing
Each #function description in this wiki page has a figure showing
the error conditions for the #function and, if there is a "return
the error conditions for the #function and, if there is a "return
Line 104: Line 98:
<!--Caution: <div> above-->
<!--Caution: <div> above-->
   
   
<p></p>
The #ABDUMP function accepts a numeric argument, and causes the
The #ABDUMP function accepts a numeric argument, and causes the
<var class="product">Fast/Unload</var> job to terminate with user abend code equal to that argument,
<var class="product">Fast/Unload</var> job to terminate with user abend code equal to that argument,
Line 110: Line 103:
<p class="code"><nowiki>%junk = #ABDUMP(ccode)
<p class="code"><nowiki>%junk = #ABDUMP(ccode)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>ccode</th><td>Condition code for user ABEND; optional, defaults to 0.</td></tr>
<tr><th>ccode</th><td>Condition code for user ABEND; optional, defaults to 0.</td></tr>
<tr><th>%junk</th><td>This #function does not return, but the FUEL syntax requires a place to store the #function result.</td></tr>
<tr><th>%junk</th><td>This #function does not return, but the FUEL syntax requires a place to store the #function result.</td></tr>
</table>
</table>
<p></p>
<p>For example, the following fragment abends the job
For example, the following fragment abends the job
when the input record number is 12345:
when the input record number is 12345:
</p>
<p class="code"><nowiki>IF #RECIN EQ 12345
<p class="code"><nowiki>IF #RECIN EQ 12345
   %FOO = #ABDUMP(99)
   %FOO = #ABDUMP(99)
END IF
END IF
</nowiki></p>
</nowiki></p>
<p></p>
 
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>The purpose of this #function is to assist in problem diagnosis;
<li>The purpose of this #function is to assist in problem diagnosis;
Technical Support will direct you if ever it needs to be used.
Technical Support will direct you if ever it needs to be used. </li>
</ul>
</ul>
<p></p>
 
This #function is new in <var class="product">Fast/Unload</var> version 4.1.
This #function is new in <var class="product">Fast/Unload</var> version 4.1.
   
   
Line 135: Line 128:
<!--Caution: <div> above-->
<!--Caution: <div> above-->
   
   
<p></p>
The #CONCAT function accepts two or more arguments
The #CONCAT function accepts two or more arguments
and returns a string value that is the concatenation of all of its
and returns a string value that is the concatenation of all of its
Line 141: Line 133:
<p class="code"><nowiki>%out = #CONCAT(stra, strb ...)
<p class="code"><nowiki>%out = #CONCAT(stra, strb ...)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>stra</th><td>First input string (required).</td></tr>
<tr><th>stra</th><td>First input string (required).</td></tr>
Line 148: Line 140:
<tr><th>%out</th><td>Concatenation of inputs.</td></tr>
<tr><th>%out</th><td>Concatenation of inputs.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the line
For example, the following fragment prints the line
<code>Bugs Bunny</code> on the FUNPRINT dataset:
<code>Bugs Bunny</code> on the FUNPRINT dataset:
Line 154: Line 146:
REPORT %RABBIT
REPORT %RABBIT
</nowiki></p>
</nowiki></p>
<p></p>
 
<p></p>
The <var class="product">Fast/Unload</var> run is cancelled with a return
The <b><i>Fast/Unload</i></b> run is cancelled with a return
code of 8 when:
code of 8 when:
<ul>
<ul>
<li>Total length of input strings exceeds 255 and <var class="product">Fast/Unload</var> version is less than 4.3.
<li>Total length of input strings exceeds 255 and <var class="product">Fast/Unload</var> version is less than 4.3. </li>
<li>Argument missing (see "Notes" below).
<li>Argument missing (see "Notes" below). </li>
</ul>
</ul>
<p><b>Notes</b></p>
<p>
<b>Notes</b></p>
<ul>
<ul>
<li>If the <i>n</i>th argument is present, where <i>n</i> is
<li>If the <i>n</i>th argument is present, where <i>n</i> is
Line 170: Line 162:
in a run-time error, because the third argument is absent:
in a run-time error, because the third argument is absent:
<p class="code"><nowiki>%X = #CONCAT(%A, %B, , %D)
<p class="code"><nowiki>%X = #CONCAT(%A, %B, , %D)
</nowiki></p>
</nowiki></p> </li>
 
<li>See [[#concatt|#CONCAT_TRUNC: Concatenate strings, allowing truncation]] if your version of <var class="product">Fast/Unload</var> is earlier than 4.3 and
<li>See [[#concatt|#CONCAT_TRUNC: Concatenate strings, allowing truncation]] if your version of <var class="product">Fast/Unload</var> is earlier than 4.3 and
if you cannot ensure that the total
if you cannot ensure that the total
length of the #CONCAT input strings is less than 256.
length of the #CONCAT input strings is less than 256. </li>
</ul>
</ul>
   
   
Line 180: Line 173:
<!--Caution: <div> above-->
<!--Caution: <div> above-->
   
   
<p></p>
The #CONCAT_TRUNC function accepts an optional output argument
The #CONCAT_TRUNC function accepts an optional output argument
and two or more string arguments
and two or more string arguments
Line 191: Line 183:
<p class="code"><nowiki>%out = #CONCAT_TRUNC(%lenrc, stra, strb ...)
<p class="code"><nowiki>%out = #CONCAT_TRUNC(%lenrc, stra, strb ...)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>%lenrc</th><td>Optional %variable, set to total length of <i>stra</i>, <i>strb</i>, ..., or to the negative of that length, if it exceeds 255.</td></tr>
<tr><th>%lenrc</th><td>Optional %variable, set to total length of <i>stra</i>, <i>strb</i>, ..., or to the negative of that length, if it exceeds 255.</td></tr>
Line 199: Line 191:
<tr><th>%out</th><td>Concatenation of <i>stra</i>, <i>strb</i>, ..., or the first 255 bytes of that concatenation, if it exceeds 255.</td></tr>
<tr><th>%out</th><td>Concatenation of <i>stra</i>, <i>strb</i>, ..., or the first 255 bytes of that concatenation, if it exceeds 255.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment
For example, the following fragment
<p class="code"><nowiki>%FOO = #CONCAT_TRUNC(%LEN, 'Hello,', -
<p class="code"><nowiki>%FOO = #CONCAT_TRUNC(%LEN, 'Hello,', -
Line 209: Line 201:
<p class="code"><nowiki>Hello, World! length is 13
<p class="code"><nowiki>Hello, World! length is 13
</nowiki></p>
</nowiki></p>
<p></p>
 
<p></p>
The <var class="product">Fast/Unload</var> run is cancelled with a return
The <b><i>Fast/Unload</i></b> run is cancelled with a return
code of 8 when:
code of 8 when:
<ul>
<ul>
<li>Argument missing (see "Notes" below).
<li>Argument missing (see "Notes" below). </li>
</ul>
</ul>
<p><b>Notes</b></p>
<p><b>Notes</b></p>
Line 224: Line 215:
in a run-time error, because the fourth argument is absent:
in a run-time error, because the fourth argument is absent:
<p class="code"><nowiki>%X = #CONCAT_TRUNC(%L, %A, %B, , %D)
<p class="code"><nowiki>%X = #CONCAT_TRUNC(%L, %A, %B, , %D)
</nowiki></p>
</nowiki></p> </li>
 
<li>See [[#conc|#CONCAT: Concatenate strings]] if you want <var class="product">Fast/Unload</var> to terminate
<li>See [[#conc|#CONCAT: Concatenate strings]] if you want <var class="product">Fast/Unload</var> to terminate
if the total length of the input strings is greater than 255.
if the total length of the input strings is greater than 255. </li>
</ul>
</ul>
<p></p>
 
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
==#C2X: Convert character string to hex representation==
==#C2X: Convert character string to hex representation==
<p></p>
The #C2X function expects one required argument and returns a
The #C2X function expects one required argument and returns a
string containing the hexadecimal representation of the value in
string containing the hexadecimal representation of the value in
Line 240: Line 232:
<p class="code"><nowiki>%hex = #C2X(str)
<p class="code"><nowiki>%hex = #C2X(str)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>String to convert.  Must be 127 bytes or less.</td></tr>
<tr><th>str</th><td>String to convert.  Must be 127 bytes or less.</td></tr>
<tr><th>%hex</th><td>String containing hex digits.</td></tr>
<tr><th>%hex</th><td>String containing hex digits.</td></tr>
</table>
</table>
<p></p>
 
For example, the code fragment
For example, the code fragment
<p class="code"><nowiki>%JUNK = #C2X('ABabc')
<p class="code"><nowiki>%JUNK = #C2X('ABabc')
Line 255: Line 247:
</nowiki></p>
</nowiki></p>
would produce <b>X'40F140'</b>.
would produce <b>X'40F140'</b>.
<p></p>
 
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:
<ul>
<ul>
<li>Length of <i>str</i> exceeds 127.
<li>Length of <i>str</i> exceeds 127. </li>
</ul>
</ul>
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>The inverse of this #function is #X2C.
<li>The inverse of this #function is #X2C. </li>
 
<li>The User Language $C2X function (http://m204wiki.rocketsoftware.com/index.php/$C2X)
<li>The User Language $C2X function (http://m204wiki.rocketsoftware.com/index.php/$C2X)
allows a maximum input length of 126, and an error causes the null string to be
allows a maximum input length of 126, and an error causes the null string to be
returned.
returned. </li>
 
<li>The User Language $IHEXA function (http://m204wiki.rocketsoftware.com/index.php/$IHexA)
<li>The User Language $IHEXA function (http://m204wiki.rocketsoftware.com/index.php/$IHexA)
ignores any input characters after the first 127.
ignores any input characters after the first 127. </li>
</ul>
</ul>
==#DATE: Current date and/or time==
==#DATE: Current date and/or time==
<p></p>
The #DATE function accepts an optional datetime format argument
The #DATE function accepts an optional datetime format argument
and an optional output return code argument
and an optional output return code argument
Line 278: Line 272:
<p class="code"><nowiki>%dat = #DATE(fmt, %rc)
<p class="code"><nowiki>%dat = #DATE(fmt, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>fmt</th><td>Optional format for returned date, default is <b>YYYY-MM-DD</b>.</td></tr>
<tr><th>fmt</th><td>Optional format for returned date, default is <b>YYYY-MM-DD</b>.</td></tr>
Line 284: Line 278:
<tr><th>%dat</th><td>Datetime string with indicated format.</td></tr>
<tr><th>%dat</th><td>Datetime string with indicated format.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment stores the current date
For example, the following fragment stores the current date
in the last occurrence of the REORG_DATE field:
in the last occurrence of the REORG_DATE field:
<p class="code"><nowiki>ADD REORG_DATE = #DATE()
<p class="code"><nowiki>ADD REORG_DATE = #DATE()
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 304: Line 298:
<ul>
<ul>
<li>The only difference between #TIME and #DATE is the default value
<li>The only difference between #TIME and #DATE is the default value
for <i>fmt</i>.
for <i>fmt</i>. </li>
 
<li>The default format returned by the
<li>The default format returned by the
User Language $DATE and $SIR_DATE functions is "YY&ndash;MM&ndash;DD";
User Language $DATE and $SIR_DATE functions is "YY&ndash;MM&ndash;DD";
the default format returned by #DATE is "YYYY&ndash;MM&ndash;DD".
the default format returned by #DATE is "YYYY&ndash;MM&ndash;DD". </li>
 
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats.
</ul>
</ul>
==#DATECHG: Add some days to datetime==
==#DATECHG: Add some days to datetime==
<p></p>
The #DATECHG function adds a specified number of days to an input
The #DATECHG function adds a specified number of days to an input
datetime, returning the incremented datetime.
datetime, returning the incremented datetime.
Line 324: Line 320:
<p class="code"><nowiki>%odat = #DATECHG(fmt, dat, n, span, %rc)
<p class="code"><nowiki>%odat = #DATECHG(fmt, dat, n, span, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>fmt</th><td>Format of <i>dat</i> and <i>%odat</i>.</td></tr>
<tr><th>fmt</th><td>Format of <i>dat</i> and <i>%odat</i>.</td></tr>
Line 333: Line 329:
<tr><th>%odat</th><td>Set to <i>dat</i> plus <i>n</i> days.</td></tr>
<tr><th>%odat</th><td>Set to <i>dat</i> plus <i>n</i> days.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the date one week after
For example, the following fragment prints the date one week after
the run date on the FUNPRINT dataset:
the run date on the FUNPRINT dataset:
Line 340: Line 336:
REPORT %X
REPORT %X
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 356: Line 352:
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
 
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments. </li>
 
<li>The User Language $DATECHG function (http://m204wiki.rocketsoftware.com/index.php/$DATECHG)
<li>The User Language $DATECHG function (http://m204wiki.rocketsoftware.com/index.php/$DATECHG)
does not provide a call-level
does not provide a call-level
argument for interpreting two-digit years, the thread-level CENTSPLT/DEFCENT
argument for interpreting two-digit years, the thread-level CENTSPLT/DEFCENT
parameters are used instead.
parameters are used instead. </li>
 
<li>The User Language $SIR_DATECHG function (http://m204wiki.rocketsoftware.com/index.php/$Sir_Datechg)
<li>The User Language $SIR_DATECHG function (http://m204wiki.rocketsoftware.com/index.php/$Sir_Datechg)
provides a CENTSPAN argument in the same fashion as #DATECHG.
provides a CENTSPAN argument in the same fashion as #DATECHG. </li>
</ul>
</ul>
==#DATECHK: Check if datetime matches format==
==#DATECHK: Check if datetime matches format==
<p></p>
The #DATECHK function verifies that a specific datetime value is valid
The #DATECHK function verifies that a specific datetime value is valid
for a given datetime format.
for a given datetime format.
Line 378: Line 377:
<p class="code"><nowiki>%tst = #DATECHK(fmt, dat, span, %rc)
<p class="code"><nowiki>%tst = #DATECHK(fmt, dat, span, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>fmt</th><td>Datetime format string for <i>dat</i>.</td></tr>
<tr><th>fmt</th><td>Datetime format string for <i>dat</i>.</td></tr>
Line 386: Line 385:
<tr><th>%tst</th><td>Set to 1 if <i>dat</i> matches <i>fmt</i>, 0 otherwise.</td></tr>
<tr><th>%tst</th><td>Set to 1 if <i>dat</i> matches <i>fmt</i>, 0 otherwise.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the string <code>Bad</code>
For example, the following fragment prints the string <code>Bad</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 396: Line 395:
END IF
END IF
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 411: Line 410:
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
 
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments. </li>
 
<li>The SOUL $DateChk function does not provide a call-level argument
<li>The SOUL $DateChk function does not provide a call-level argument
for interpreting two-digit years, the thread-level CENTSPLT/DEFCENT parameters are
for interpreting two-digit years, the thread-level CENTSPLT/DEFCENT parameters are
used instead.
used instead. </li>
 
<li>The <var class="product">SOUL</var> $Sir_DateChk function provides a CENTSPAN
<li>The <var class="product">SOUL</var> $Sir_DateChk function provides a CENTSPAN
argument in the same fashion as #DATECHK.
argument in the same fashion as #DATECHK.
</ul>
</ul>
==#DATECNV: Convert datetime to different format==
==#DATECNV: Convert datetime to different format==
The #DATECNV function converts a datetime value from one datetime
The #DATECNV function converts a datetime value from one datetime
Line 432: Line 435:
<p class="code"><nowiki>%odat = #DATECNV(infmt, outfmt, dat, span, %rc)
<p class="code"><nowiki>%odat = #DATECNV(infmt, outfmt, dat, span, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>infmt</th><td>Datetime format string for <i>dat</i>.</td></tr>
<tr><th>infmt</th><td>Datetime format string for <i>dat</i>.</td></tr>
Line 441: Line 444:
<tr><th>%odat</th><td>Set to the value of <i>dat</i>, converted to output format.</td></tr>
<tr><th>%odat</th><td>Set to the value of <i>dat</i>, converted to output format.</td></tr>
</table>
</table>
<p></p>
 
For example, this prints the string <code>19970101</code>
For example, this prints the string <code>19970101</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 447: Line 450:
REPORT %X
REPORT %X
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 465: Line 468:
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
 
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments. </li>
</ul>
</ul>
==#DATEDIF: Difference between two dates==
==#DATEDIF: Difference between two dates==
The #DATEDIF function subtracts a second date from a first date and
The #DATEDIF function subtracts a second date from a first date and
Line 480: Line 485:
                 span, %rc)
                 span, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>fmta</th><td>Datetime format string for <i>data</i>.</td></tr>
<tr><th>fmta</th><td>Datetime format string for <i>data</i>.</td></tr>
Line 490: Line 495:
<tr><th>%dif</th><td>Set to the number of days obtained by subtracting the second date from the first date, ignoring any time components of both dates.</td></tr>
<tr><th>%dif</th><td>Set to the number of days obtained by subtracting the second date from the first date, ignoring any time components of both dates.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the string <code>7 days</code>
For example, the following fragment prints the string <code>7 days</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 496: Line 501:
REPORT %X AND 'days'
REPORT %X AND 'days'
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 513: Line 518:
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>Time is ignored in the subtraction.
<li>Time is ignored in the subtraction. </li>
 
<li>In the example above, even though the input dates have 2-digit years,
<li>In the example above, even though the input dates have 2-digit years,
there is no need for a <i>span</i> argument, since the dates are
there is no need for a <i>span</i> argument, since the dates are
in the same year.
in the same year. </li>
 
<li>As in the SOUL $DATEDIF function,
<li>As in the SOUL $DATEDIF function,
the single <b>span</b> argument is used for
the single <b>span</b> argument is used for
Line 522: Line 529:
dates which both have 2-digit years and are in different 100-year
dates which both have 2-digit years and are in different 100-year
windows, you must first use #DATECNV to convert one of them to some
windows, you must first use #DATECNV to convert one of them to some
4-digit year format.
4-digit year format. </li>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
 
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
 
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments. </li>
</ul>
</ul>
==#DATEFMT: Validate datetime format string==
==#DATEFMT: Validate datetime format string==
The #DATEFMT function is used to validate a datetime format string.
The #DATEFMT function is used to validate a datetime format string.
Line 533: Line 543:
<p class="code"><nowiki>%tst = #DATEFMT(fmt)
<p class="code"><nowiki>%tst = #DATEFMT(fmt)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>fmt</th><td>Datetime format string to be validated.</td></tr>
<tr><th>fmt</th><td>Datetime format string to be validated.</td></tr>
<tr><th>%tst</th><td>Set to 1 if <i>fmt</i> is a valid format string, else set to 0.</td></tr>
<tr><th>%tst</th><td>Set to 1 if <i>fmt</i> is a valid format string, else set to 0.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the string <code>Good</code>
For example, the following fragment prints the string <code>Good</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 548: Line 558:
END IF
END IF
</nowiki></p>
</nowiki></p>
<p></p>
 
This #function has no terminating conditions.
This #function has no terminating conditions.
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats. </li>
</ul>
</ul>
==#DATE2N: Convert datetime string to number of seconds*300==
==#DATE2N: Convert datetime string to number of seconds*300==
The #DATE2N function converts a datetime value in a string format into
The #DATE2N function converts a datetime value in a string format into
Line 566: Line 577:
<p class="code"><nowiki>%num = #DATE2N(dat, fmt, span, %rc)
<p class="code"><nowiki>%num = #DATE2N(dat, fmt, span, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>dat</th><td>Datetime value string.</td></tr>
<tr><th>dat</th><td>Datetime value string.</td></tr>
Line 574: Line 585:
<tr><th>%num</th><td>Set to the number of seconds*300 since 1 Jan 1900 12:00 AM that corresponds to the datetime value of <i>dat</i>.</td></tr>
<tr><th>%num</th><td>Set to the number of seconds*300 since 1 Jan 1900 12:00 AM that corresponds to the datetime value of <i>dat</i>.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the value <code>BEFORE</code>
For example, the following fragment prints the value <code>BEFORE</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 582: Line 593:
END IF
END IF
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 599: Line 610:
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>Values returned by #DATE2N
<li>Values returned by #DATE2N </li>
 
will often exceed the range that can be represented
will often exceed the range that can be represented
in a 4-byte integer, so you should probably avoid storing the
in a 4-byte integer, so you should probably avoid storing the
value in a BINARY or FLOAT4 field.
value in a BINARY or FLOAT4 field. </li>
<li>Dates prior to 1 January 1900 will return a negative number.
 
<li>The inverse of this #function is #N2DATE.
<li>Dates prior to 1 January 1900 will return a negative number. </li>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
 
<li>The inverse of this #function is #N2DATE. </li>
 
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
 
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
</ul>
</ul>
==#DATE2ND: Convert datetime string to number of days==
==#DATE2ND: Convert datetime string to number of days==
The #DATE2ND function converts a datetime value in a string format into
The #DATE2ND function converts a datetime value in a string format into
Line 620: Line 637:
<p class="code"><nowiki>%num = #DATE2ND(dat, fmt, span, %rc)
<p class="code"><nowiki>%num = #DATE2ND(dat, fmt, span, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>dat</th><td>Datetime value string.</td></tr>
<tr><th>dat</th><td>Datetime value string.</td></tr>
Line 628: Line 645:
<tr><th>%num</th><td>Set to the number of days since 1 Jan 1900 12:00 AM that corresponds to the datetime value of <i>dat</i>.</td></tr>
<tr><th>%num</th><td>Set to the number of days since 1 Jan 1900 12:00 AM that corresponds to the datetime value of <i>dat</i>.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the value <code>BEFORE</code>
For example, the following fragment prints the value <code>BEFORE</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 636: Line 653:
END IF
END IF
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 653: Line 670:
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>Dates prior to 1 January 1900 will return a negative number.
<li>Dates prior to 1 January 1900 will return a negative number. </li>
<li>The inverse of this #function is #ND2DATE.
<li>The inverse of this #function is #ND2DATE. </li>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments. </li>
</ul>
</ul>
==#DATE2NM: Convert datetime string to number of milliseconds==
==#DATE2NM: Convert datetime string to number of milliseconds==
The #DATE2NM function converts a datetime value in a string format into
The #DATE2NM function converts a datetime value in a string format into
Line 670: Line 688:
<p class="code"><nowiki>%num = #DATE2NM(dat, fmt, span, %rc)
<p class="code"><nowiki>%num = #DATE2NM(dat, fmt, span, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>dat</th><td>Datetime value string.</td></tr>
<tr><th>dat</th><td>Datetime value string.</td></tr>
Line 678: Line 696:
<tr><th>%num</th><td>Set to the number of milliseconds since 1 Jan 1900 12:00 AM that corresponds to the datetime value of <i>dat</i>.</td></tr>
<tr><th>%num</th><td>Set to the number of milliseconds since 1 Jan 1900 12:00 AM that corresponds to the datetime value of <i>dat</i>.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the value 'BEFORE'
For example, the following fragment prints the value 'BEFORE'
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 686: Line 704:
END IF
END IF
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 706: Line 724:
will often exceed the range that can be represented
will often exceed the range that can be represented
in a 4-byte integer, so you should probably avoid storing the
in a 4-byte integer, so you should probably avoid storing the
value in a BINARY or FLOAT4 field.
value in a BINARY or FLOAT4 field. </li>
<li>Dates prior to 1 January 1900 will return a negative number.
 
<li>The inverse of this #function is #NM2DATE.
<li>Dates prior to 1 January 1900 will return a negative number. </li>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
 
<li>The inverse of this #function is #NM2DATE. </li>
 
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
 
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
</ul>
</ul>
==#DATE2NS: Convert datetime string to number of seconds==
==#DATE2NS: Convert datetime string to number of seconds==
The #DATE2NS function converts a datetime value in a string format into
The #DATE2NS function converts a datetime value in a string format into
Line 724: Line 747:
<p class="code"><nowiki>%num = #DATE2NS(dat, fmt, span, %rc)
<p class="code"><nowiki>%num = #DATE2NS(dat, fmt, span, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>dat</th><td>Datetime value string.</td></tr>
<tr><th>dat</th><td>Datetime value string.</td></tr>
Line 732: Line 755:
<tr><th>%num</th><td>Set to the number of seconds since 1 Jan 1900 12:00 AM that corresponds to the datetime value of <i>dat</i>.</td></tr>
<tr><th>%num</th><td>Set to the number of seconds since 1 Jan 1900 12:00 AM that corresponds to the datetime value of <i>dat</i>.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the value 'BEFORE'
For example, the following fragment prints the value 'BEFORE'
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 740: Line 763:
END IF
END IF
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 760: Line 783:
will often exceed the range that can be represented
will often exceed the range that can be represented
in a 4-byte integer, so you should probably avoid storing the
in a 4-byte integer, so you should probably avoid storing the
value in a BINARY or FLOAT4 field.
value in a BINARY or FLOAT4 field. </li>
<li>Dates prior to 1 January 1900 will return a negative number.
 
<li>The inverse of this #function is #NS2DATE.
<li>Dates prior to 1 January 1900 will return a negative number. </li>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
 
<li>The inverse of this #function is #NS2DATE. </li>
 
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
 
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
<li>[[Fast/Unload datetime processing considerations#cspan|CENTSPAN]] explains <b>CENTSPAN</b> arguments.
</ul>
</ul>
Line 778: Line 805:
<p class="code"><nowiki>%out = #DEBLANK(str, pos, len)
<p class="code"><nowiki>%out = #DEBLANK(str, pos, len)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>String to be deblanked; required.</td></tr>
<tr><th>str</th><td>String to be deblanked; required.</td></tr>
<tr><th>pos</th><td>Optional position within <i>str</i> to start deblanking. Must be numeric greater than or equal to 1, default is 1.</td></tr>
<tr><th>pos</th><td>Optional position within <i>str</i> to start deblanking. Must be numeric greater than or equal to 1, default is 1.</td></tr>
<tr><th>len</th><td>Optional length, starting at <i>pos</i> of string to deblank. Must be numeric greater than or equal to 0, default is the remainder of the input string.</td></tr>
<tr><th>len</th><td>Optional length, starting at <i>pos</i> of string to deblank. Must be numeric greater than or equal to 0, default is the remainder of the input string.</td></tr>
<tr><th>%out</th><td>Set to the substring within <i>str</i>, starting at <i>pos</i> for length <i>len</i>; leading and trailing blanks are then removed from this substring. Intermediate blanks within the substring are not affected.</td></tr>
<tr><th>%out</th><td>Set to the substring within <i>str</i>, starting at <i>pos</i> for length <i>len</i>; leading and trailing blanks are then removed from this substring. Intermediate blanks within the substring are not affected.</td></tr>
</table>
</table>
<p></p>
 
<p></p>
Examples:
Examples:
<p class="code"><nowiki>#DEBLANK(' ABC ')        returns  'ABC'
<p class="code"><nowiki>#DEBLANK(' ABC ')        returns  'ABC'
Line 792: Line 821:
#DEBLANK(' A  BC ', 2, 4) returns  'A  B'
#DEBLANK(' A  BC ', 2, 4) returns  'A  B'
</nowiki></p>
</nowiki></p>
<p></p>
 
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:
<ul>
<ul>
<li><i>pos</i> is not numeric, or less than 1.
<li><i>pos</i> is not numeric, or less than 1. </li>
<li><i>len</i> is not numeric, or less than 0.
<li><i>len</i> is not numeric, or less than 0. </li>
</ul>
</ul>
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>This #function is similar to the #STRIP function ([[##strip|#STRIP: Remove leading and/or trailing copies of pad character]]).
<li>This #function is similar to the #STRIP function ([[##strip|#STRIP: Remove leading and/or trailing copies of pad character]]). </li>
</ul>
</ul>
<p></p>
 
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
==#DELWORD: Remove blank-delimited words from string==
==#DELWORD: Remove blank-delimited words from string==
The #DELWORD function removes one or more blank-delimited words from a string.
The #DELWORD function removes one or more blank-delimited words from a string.
Line 811: Line 841:
<p class="code"><nowiki>%out = #DELWORD(str, word, count)
<p class="code"><nowiki>%out = #DELWORD(str, word, count)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>String containing words to be deleted; required.</td></tr>
<tr><th>str</th><td>String containing words to be deleted; required.</td></tr>
Line 818: Line 848:
<tr><th>%out</th><td>Set to <i>str</i> with the substring removed which starts with the first character of word number <i>word</i> and ends with the last blank character before word number <i>word+count</i>.</td></tr>
<tr><th>%out</th><td>Set to <i>str</i> with the substring removed which starts with the first character of word number <i>word</i> and ends with the last blank character before word number <i>word+count</i>.</td></tr>
</table>
</table>
<p></p>
 
<p></p>
Examples:
Examples:
<p class="code"><nowiki>#DELWORD('A B C', 1)      returns  ''
<p class="code"><nowiki>#DELWORD('A B C', 1)      returns  ''
Line 830: Line 859:
#DELWORD('A B C', 2, 2)  returns  'A '
#DELWORD('A B C', 2, 2)  returns  'A '
</nowiki></p>
</nowiki></p>
<p></p>
 
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:
<ul>
<ul>
<li><i>word</i> is not numeric, or less than 1.
<li><i>word</i> is not numeric, or less than 1. </li>
<li><i>count</i> is not numeric, or less than 0.
<li><i>count</i> is not numeric, or less than 0. </li>
</ul>
</ul>
<p></p>
 
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
   
   
Line 850: Line 879:
<p class="code"><nowiki>%pos = #FIND(haystack, words)
<p class="code"><nowiki>%pos = #FIND(haystack, words)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>haystack</th><td>String containing words to be searched within; required.</td></tr>
<tr><th>haystack</th><td>String containing words to be searched within; required.</td></tr>
Line 856: Line 885:
<tr><th>%pos</th><td>Set to the word position, within <i>haystack</i>, of the first word of a sequence of words that matches the sequence in <i>words</i>. If <i>words</i> is not found, <i>%pos</i> is set to 0.</td></tr>
<tr><th>%pos</th><td>Set to the word position, within <i>haystack</i>, of the first word of a sequence of words that matches the sequence in <i>words</i>. If <i>words</i> is not found, <i>%pos</i> is set to 0.</td></tr>
</table>
</table>
<p></p>
 
<p></p>
Examples:
Examples:
<p class="code"><nowiki>#FIND('A B C', 'B')          returns  2
<p class="code"><nowiki>#FIND('A B C', 'B')          returns  2
Line 868: Line 896:
#FIND(' A  A  B  ', 'A B')  returns  2
#FIND(' A  A  B  ', 'A B')  returns  2
</nowiki></p>
</nowiki></p>
<p></p>
 
This #function has no cancelling conditions.
This #function has no cancelling conditions.
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>Multiple blanks in both input arguments are ignored.
<li>Multiple blanks in both input arguments are ignored. </li>
 
<li>This #function is similar to the #ONEOF function ([[##oneof|#ONEOF: See if string is in delimited list of strings]]).
<li>This #function is similar to the #ONEOF function ([[##oneof|#ONEOF: See if string is in delimited list of strings]]).
Note, however, that both #FIND and #ONEOF are inferior to the
Note, however, that both #FIND and #ONEOF are inferior to the
SELECT statement, when the only purpose is to test whether an
SELECT statement, when the only purpose is to test whether an
entity has one of several values (see [[Fast/Unload Extraction Language (FUEL)#sel|SELECT entity]]).
entity has one of several values (see [[Fast/Unload Extraction Language (FUEL)#sel|SELECT entity]]). </li>
</ul>
</ul>
<p></p>
 
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
   
   
Line 884: Line 913:
==#FLOAT8: Get 8-byte float, padding 4-byte input with 0==
==#FLOAT8: Get 8-byte float, padding 4-byte input with 0==
<!--Caution: <div> above-->
<!--Caution: <div> above-->
 
<p></p>
The #FLOAT8 function accepts a numeric argument, and it returns the
The #FLOAT8 function accepts a numeric argument, and it returns the
value of the argument as an 8-byte floating point value.
value of the argument as an 8-byte floating point value.
Line 893: Line 921:
<p class="code"><nowiki>%out = #FLOAT8(in)
<p class="code"><nowiki>%out = #FLOAT8(in)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>%out</th><td>Set to 8-byte floating point value of input argument.</td></tr>
<tr><th>%out</th><td>Set to 8-byte floating point value of input argument.</td></tr>
Line 901: Line 929:
<ul>
<ul>
<li>See [[Fast/Unload floating point arithmetic and numeric conversion]] for a specification of conversions to floating
<li>See [[Fast/Unload floating point arithmetic and numeric conversion]] for a specification of conversions to floating
point values.
point values. </li>
 
<li>Numeric operations in FUEL and in <var class="product">SOUL</var> are based on <b>decimal</b>,
<li>Numeric operations in FUEL and in <var class="product">SOUL</var> are based on <b>decimal</b>,
not <b>binary</b>, interpretation of floating point values, so
not <b>binary</b>, interpretation of floating point values, so
this #function is seldom used.
this #function is seldom used.
<p></p>
<p>
However, #FLOAT8 may be useful in unusual situations, in particular to
However, #FLOAT8 may be useful in unusual situations, in particular to
perform a file reorganization that expands a FLOAT LEN 4 field to
perform a file reorganization that expands a FLOAT LEN 4 field to
a FLOAT LEN 8 field, using the "raw" floating point conversion
a FLOAT LEN 8 field, using the "raw" floating point conversion
(such as can be done in a structured file reorganization using
(such as can be done in a structured file reorganization using
the <code>X'0080'</code> mode bit in FLOD).
the <code>X'0080'</code> mode bit in FLOD).</p>
<p></p>
<p>
For example, if field FLT is defined in the input as FLOAT LEN
For example, if field FLT is defined in the input as FLOAT LEN
4, and you want to convert it to a FLOAT LEN 8 or FLOAT LEN 16
4, and you want to convert it to a FLOAT LEN 8 or FLOAT LEN 16
in a UAI/LAI file reorganization in such a way that the new
in a UAI/LAI file reorganization in such a way that the new
field's values consist of the old ones with binary zeros added,
field's values consist of the old ones with binary zeros added,
you can use the following:
you can use the following:</p>
<p class="code"><nowiki>  OPEN PRODFILE
<p class="code"><nowiki>  OPEN PRODFILE
   UAI
   UAI
Line 926: Line 955:
   END FOR
   END FOR
</nowiki></p>
</nowiki></p>
<p></p>
<p>
In this example, if the input value of FLT is 411028F6, which is the
In this example, if the input value of FLT is 411028F6, which is the
closest 4-byte floating point value to the decimal value 1.01, it is
closest 4-byte floating point value to the decimal value 1.01, it is
converted on output to 411028F600000000, which <var class="product">SOUL</var> will display as
converted on output to 411028F600000000, which <var class="product">SOUL</var> will display as
1.01000022888184 (demonstrating that #FLOAT8 is only to be used in
1.01000022888184 (demonstrating that #FLOAT8 is only to be used in
special circumstances).
special circumstances).</p>
<p></p>
<p>
A "normal"
A "normal"
UAI/LAI conversion of 411028F6 to a FLOAT LEN 8 field would be to
UAI/LAI conversion of 411028F6 to a FLOAT LEN 8 field would be to
the hexadecimal value 411028F5C28F5C28, which <var class="product">SOUL</var> will display as
the hexadecimal value 411028F5C28F5C28, which <var class="product">SOUL</var> will display as
1.01.
1.01.</p> </li>
</ul>
</ul>
<p></p>
 
This #function is new in <var class="product">Fast/Unload</var> version 4.3.
This #function is new in <var class="product">Fast/Unload</var> version 4.3.
==#INDEX: Position of second string within first==
==#INDEX: Position of second string within first==
The #INDEX function locates the first occurrence, if any, of a search
The #INDEX function locates the first occurrence, if any, of a search
Line 952: Line 982:
<p class="code"><nowiki>%opos = #INDEX(haystack, needle, pos)
<p class="code"><nowiki>%opos = #INDEX(haystack, needle, pos)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>haystack</th><td>String to be searched; required.</td></tr>
<tr><th>haystack</th><td>String to be searched; required.</td></tr>
Line 959: Line 989:
<tr><th>%opos</th><td>Set to starting position of first occurrence of <i>needle</i> within <i>haystack</i>, with search starting at <i>pos</i>, else 0 if not found or if either string length is zero.</td></tr>
<tr><th>%opos</th><td>Set to starting position of first occurrence of <i>needle</i> within <i>haystack</i>, with search starting at <i>pos</i>, else 0 if not found or if either string length is zero.</td></tr>
</table>
</table>
<p></p>
 
<p></p>
Examples:
Examples:
<p class="code"><nowiki>#INDEX('123xy', '23')    returns  2
<p class="code"><nowiki>#INDEX('123xy', '23')    returns  2
Line 967: Line 996:
#INDEX('123xy', '23', 3)  returns  0
#INDEX('123xy', '23', 3)  returns  0
</nowiki></p>
</nowiki></p>
<p></p>
 
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:
<ul>
<ul>
<li><i>pos</i> is not numeric, or less than 1.
<li><i>pos</i> is not numeric, or less than 1. </li>
</ul>
</ul>
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>If <i>needle</i> or <i>haystack</i> is the null string, 0 is returned.
<li>If <i>needle</i> or <i>haystack</i> is the null string, 0 is returned. </li>
</ul>
</ul>
   
   
Line 994: Line 1,023:
<p class="code"><nowiki>%out = #LEFT(str, len, pad)
<p class="code"><nowiki>%out = #LEFT(str, len, pad)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>Source string.</td></tr>
<tr><th>str</th><td>Source string.</td></tr>
<tr><th>len</th><td>Length of the output string. Must be numeric >= 0.</td></tr>
<tr><th>len</th><td>Length of the output string. Must be numeric >= 0.</td></tr>
<tr><th>pad</th><td>Optional pad character. Default is blank. If supplied, must be a string of length 1.</td></tr>
<tr><th>pad</th><td>Optional pad character. Default is blank. If supplied, must be a string of length 1.</td></tr>
<tr><th>%out</th><td>If <i>len</i> is greater then #LEN(<i>str</i>): <ul>
<tr><th>%out</th><td>If <i>len</i> is greater then #LEN(<i>str</i>):  
<li>all of <i>str</i>, followed by <i>len</i> - <nowiki>#LEN</nowiki>(<i>str</i>) copies of the pad character </ul> <p></p> Otherwise: <ul>
<ul>
<li>substring from <i>str</i> starting at position 1 with length <i>len</i> </ul></td></tr>
<li>all of <i>str</i>, followed by <i>len</i> - <nowiki>#LEN</nowiki>(<i>str</i>) copies of the pad character </li>
</ul>  
<p>Otherwise: </p>  
<ul>
<li>substring from <i>str</i> starting at position 1 with length <i>len</i> </li>
</ul></td></tr>
</table>
</table>
For example:
For example:
Line 1,009: Line 1,043:
#LEFT(4.6, 4, 0)      returns  '4.60'
#LEFT(4.6, 4, 0)      returns  '4.60'
</nowiki></p>
</nowiki></p>
<p></p>
 
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:
<ul>
<ul>
<li><i>Len</i> not numeric, or less than 0.
<li><i>Len</i> not numeric, or less than 0. </li>
<li><i>Pad</i> supplied, and length not 1.
<li><i>Pad</i> supplied, and length not 1. </li>
</ul>
</ul>
<p><b>Notes</b></p>
<p>
<b>Notes</b></p>
<ul>
<ul>
<li>This is the same as the #PADR function, except for the order of
<li>This is the same as the #PADR function, except for the order of
the arguments (see [[##padr|#PADR: Initial substring, followed by pad characters to specified length]]).
the arguments (see [[##padr|#PADR: Initial substring, followed by pad characters to specified length]]). </li>
</ul>
</ul>
<p></p>
 
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
   
   
Line 1,028: Line 1,063:
<!--Caution: <div> above-->
<!--Caution: <div> above-->
   
   
<p></p>
The #LEN function returns the length of a string, in number of bytes.
The #LEN function returns the length of a string, in number of bytes.
It expects a required string argument and returns a numeric result.
It expects a required string argument and returns a numeric result.
<p class="code"><nowiki>%len = #LEN(str)
<p class="code"><nowiki>%len = #LEN(str)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>String whose length you want to know. For <var class="product">Fast/Unload</var> version 4.3 and later. <i>str</i> may be longer than 255 bytes.</td></tr>
<tr><th>str</th><td>String whose length you want to know. For <var class="product">Fast/Unload</var> version 4.3 and later. <i>str</i> may be longer than 255 bytes.</td></tr>
<tr><th>%len</th><td>Set to length of <i>str</i>.</td></tr>
<tr><th>%len</th><td>Set to length of <i>str</i>.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the string <code>Length: 13</code>
For example, the following fragment prints the string <code>Length: 13</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 1,044: Line 1,078:
REPORT 'Length:' AND %X
REPORT 'Length:' AND %X
</nowiki></p>
</nowiki></p>
<p></p>
 
This #function has no cancelling conditions.
This #function has no cancelling conditions.
==#LOWCASE: Change uppercase letters of string to lowercase==
==#LOWCASE: Change uppercase letters of string to lowercase==
Line 1,052: Line 1,086:
<p class="code"><nowiki>%out = #LOWCASE(str)
<p class="code"><nowiki>%out = #LOWCASE(str)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>Source string,  required.</td></tr>
<tr><th>str</th><td>Source string,  required.</td></tr>
Line 1,062: Line 1,096:
#LOWCASE('')        returns  ''
#LOWCASE('')        returns  ''
</nowiki></p>
</nowiki></p>
<p></p>
 
This #function has no cancelling conditions.
This #function has no cancelling conditions.
<p></p>
 
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
==#ND2DATE: Convert number of days to datetime string==
==#ND2DATE: Convert number of days to datetime string==
The #ND2DATE function converts a numeric datetime value expressed as
The #ND2DATE function converts a numeric datetime value expressed as
Line 1,075: Line 1,110:
<p class="code"><nowiki>%dat = #ND2DATE(datn, fmt, %rc)
<p class="code"><nowiki>%dat = #ND2DATE(datn, fmt, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>datn</th><td>Numeric datetime value expressed as the number of days since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.</td></tr>
<tr><th>datn</th><td>Numeric datetime value expressed as the number of days since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.</td></tr>
Line 1,082: Line 1,117:
<tr><th>%dat</th><td>Set to datetime string value, in format specified by <i>fmt</i>, corresponding to <i>datn</i>.</td></tr>
<tr><th>%dat</th><td>Set to datetime string value, in format specified by <i>fmt</i>, corresponding to <i>datn</i>.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the string <code>07/31/84</code>
For example, the following fragment prints the string <code>07/31/84</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 1,090: Line 1,125:
REPORT %X
REPORT %X
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 1,104: Line 1,139:
<tr><th>8</th><td><i>datn</i> is out of range for <i>fmt</i>.</td></tr>
<tr><th>8</th><td><i>datn</i> is out of range for <i>fmt</i>.</td></tr>
</table>
</table>
<p><b>Notes</b></p>
<p>
<b>Notes</b></p>
<ul>
<ul>
<li>The inverse of this #function is #DATE2ND.
<li>The inverse of this #function is #DATE2ND. </li>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
</ul>
</ul>
==#NM2DATE: Convert number of milliseconds to datetime string==
==#NM2DATE: Convert number of milliseconds to datetime string==
The #NM2DATE function converts a numeric datetime value expressed as
The #NM2DATE function converts a numeric datetime value expressed as
Line 1,118: Line 1,155:
<p class="code"><nowiki>%dat = #NM2DATE(datn, fmt, %rc)
<p class="code"><nowiki>%dat = #NM2DATE(datn, fmt, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>datn</th><td>Numeric datetime value expressed as the number of milliseconds since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.</td></tr>
<tr><th>datn</th>
<tr><th>fmt</th><td>Datetime format string to use for creating <i>%dat</i>.</td></tr>
<td>Numeric datetime value expressed as the number of milliseconds since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.</td></tr>
<tr><th>%rc</th><td>Return code (optional, output)</td></tr>
 
<tr><th>%dat</th><td>Set to datetime string value, in format specified by <i>fmt</i>, corresponding to <i>datn</i>.</td></tr>
<tr><th>fmt</th>
<td>Datetime format string to use for creating <i>%dat</i>.</td></tr>
 
<tr><th>%rc</th>
<td>Return code (optional, output)</td></tr>
 
<tr><th>%dat</th>
<td>Set to datetime string value, in format specified by <i>fmt</i>, corresponding to <i>datn</i>.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the string <code>07/31/84</code>
For example, the following fragment prints the string <code>07/31/84</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 1,133: Line 1,177:
REPORT %X
REPORT %X
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 1,147: Line 1,191:
<tr><th>8</th><td><i>datn</i> is out of range for <i>fmt</i>.</td></tr>
<tr><th>8</th><td><i>datn</i> is out of range for <i>fmt</i>.</td></tr>
</table>
</table>
<p><b>Notes</b></p>
<p>
<b>Notes</b></p>
<ul>
<ul>
<p></p>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
<p></p>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
</ul>
</ul>
==#NS2DATE: Convert number of seconds to datetime string==
==#NS2DATE: Convert number of seconds to datetime string==
The #NS2DATE function converts a numeric datetime value expressed as
The #NS2DATE function converts a numeric datetime value expressed as
Line 1,162: Line 1,206:
<p class="code"><nowiki>%dat = #NS2DATE(datn, fmt, %rc)
<p class="code"><nowiki>%dat = #NS2DATE(datn, fmt, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>datn</th><td>Numeric datetime value expressed as the number of seconds since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.</td></tr>
<tr><th>datn</th><td>Numeric datetime value expressed as the number of seconds since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.</td></tr>
Line 1,169: Line 1,213:
<tr><th>%dat</th><td>Set to datetime string value, in format specified by <i>fmt</i>, corresponding to <i>datn</i>.</td></tr>
<tr><th>%dat</th><td>Set to datetime string value, in format specified by <i>fmt</i>, corresponding to <i>datn</i>.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the string <code>07/31/84</code>
For example, the following fragment prints the string <code>07/31/84</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 1,177: Line 1,221:
REPORT %X
REPORT %X
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 1,191: Line 1,235:
<tr><th>8</th><td><i>datn</i> is out of range for <i>fmt</i>.</td></tr>
<tr><th>8</th><td><i>datn</i> is out of range for <i>fmt</i>.</td></tr>
</table>
</table>
<p><b>Notes</b></p>
<p>
<b>Notes</b></p>
<ul>
<ul>
<li>The inverse of this #function is #DATE2NS.
<li>The inverse of this #function is #DATE2NS. </li>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
</ul>
</ul>
   
   
Line 1,211: Line 1,256:
integer area,
integer area,
and the leading pad character for the integer digits area.
and the leading pad character for the integer digits area.
<p></p>
 
The final optional argument is an output argument whose absolute
The final optional argument is an output argument whose absolute
value is set to the
value is set to the
Line 1,223: Line 1,268:
<p class="code"><nowiki>%str = #NUM2STR(num, intw, fracw, opt, pad, %intlen)
<p class="code"><nowiki>%str = #NUM2STR(num, intw, fracw, opt, pad, %intlen)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>num</th><td>Input number to be converted.</td></tr>
<tr><th>num</th><td>Input number to be converted.</td></tr>
<tr><th>intw</th><td>Number of characters used to express the integer portion and leading minus sign, if any, of <i>num</i>. Optional, must be 0 or more if specified. If omitted, only the characters needed are used to represent the integer part: a leading minus sign, if <i>num</i> is negative, is followed by the integer portion with leading zeroes stripped (except if the integer portion is zero, a single digit 0 is used). <p></p> If the fourth argument (<i>opt</i>) contains the letter 'V', <i>intw</i> is the minimal width used for the integer part, and the number of characters needed is used if that exceeds <i>intw</i>.</td></tr>
<tr><th>intw</th><td>Number of characters used to express the integer portion and leading minus sign, if any, of <i>num</i>. Optional, must be 0 or more if specified. If omitted, only the characters needed are used to represent the integer part: a leading minus sign, if <i>num</i> is negative, is followed by the integer portion with leading zeroes stripped (except if the integer portion is zero, a single digit 0 is used).  
<tr><th>fracw</th><td>Number of digits used to express the fraction portion of <i>num</i>. Optional, must be 0 or more if specified. If this argument is omitted: <ul>
<p>If the fourth argument (<i>opt</i>) contains the letter 'V', <i>intw</i> is the minimal width used for the integer part, and the number of characters needed is used if that exceeds <i>intw</i>.</p> </td></tr>
<li>only the characters needed are used to represent the fraction part
 
<li>if the fraction part is 0, no decimal point occurs in the result
<tr><th>fracw</th><td>Number of digits used to express the fraction portion of <i>num</i>. Optional, must be 0 or more if specified. If this argument is omitted:  
<li>if the fraction part is not 0, trailing zeroes are removed </ul></td></tr>
<ul>
<tr><th>%opt</th><td>One or two characters, optional, with one choice from either of the following two pairs: <ul>
<li>only the characters needed are used to represent the fraction part </li>
<li>if the fraction part is 0, no decimal point occurs in the result </li>
<li>if the fraction part is not 0, trailing zeroes are removed </li>
</ul></td></tr>
 
<tr><th>%opt</th><td>One or two characters, optional, with one choice from either of the following two pairs:  
<ul>
<li>R (round) or T (trunc)
<li>R (round) or T (trunc)
<table>
<table>
<tr><th>R</th><td>Round up the final digit of the result, if the most significant discarded fraction digit is 5 or more. This is the default.</td></tr>
<tr><th>R</th><td>Round up the final digit of the result, if the most significant discarded fraction digit is 5 or more. This is the default.</td></tr>
<tr><th>T</th><td>Final digit of result unaffected by any discarded fraction digits.</td></tr>
<tr><th>T</th><td>Final digit of result unaffected by any discarded fraction digits.</td></tr>
</table>
</table>
<p></p> This character has no meaning if argument three (<i>fracw</i>) is omitted, since in that case no fraction digits are discarded.
<p>
This character has no meaning if argument three (<i>fracw</i>) is omitted, since in that case no fraction digits are discarded.</p> </li>
<li>F (fixed width) or V (variable width)
<li>F (fixed width) or V (variable width)
<table>
<table>
<tr><th>F</th><td>The integer portion of the result is fixed width; that is, as many characters are used for the integer (and leading minus sign) as the value of argument two (<i>intw</i>). This is the default.</td></tr>
<tr><th>F</th>
<tr><th>V</th><td>The integer portion of the result is variable/minimal width. That is, if <i>w</i> characters are needed for the integer (and leading minus sign) with leading zeroes removed, then <i>w</i> characters are used for the integer if <i>w</i>><i>intw</i>; <i>intw</i> characters are used otherwise.</td></tr>
<td>The integer portion of the result is fixed width; that is, as many characters are used for the integer (and leading minus sign) as the value of argument two (<i>intw</i>). This is the default.</td></tr>
 
<tr><th>V</th>
<td>The integer portion of the result is variable/minimal width. That is, if <i>w</i> characters are needed for the integer (and leading minus sign) with leading zeroes removed, then <i>w</i> characters are used for the integer if <i>w</i>><i>intw</i>; <i>intw</i> characters are used otherwise.</td></tr>
</table>
</table>
<p></p> This character has no meaning if argument two (<i>intw</i>) is omitted, since in that case exactly the characters needed for the integer are used. </ul></td></tr>
<p>
This character has no meaning if argument two (<i>intw</i>) is omitted, since in that case exactly the characters needed for the integer are used.</p> </li>
</ul></td></tr>
 
<tr><th>pad</th><td>The leading pad character used to fill the integer portion to the width specified by argument two (<i>intw</i>). Optional, must be one character, defaults to blank. If the pad character is blank, a leading minus sign <b>follows</b> any blank pad characters; otherwise a leading minus sign <b>precedes</b> any pad characters.</td></tr>
<tr><th>pad</th><td>The leading pad character used to fill the integer portion to the width specified by argument two (<i>intw</i>). Optional, must be one character, defaults to blank. If the pad character is blank, a leading minus sign <b>follows</b> any blank pad characters; otherwise a leading minus sign <b>precedes</b> any pad characters.</td></tr>
<tr><th>%intlen</th><td>Set to the value <i>len</i>, where the absolute value of <i>len</i> is the number of characters needed for the integer part of the first argument (<i>num</i>), with any leading zeroes stripped (or one zero if the integer part is zero), including one additional character if <i>num</i> is negative. <p></p> If <i>%intlen</i> is returned with a negative value, that indicates truncation of the integer part of <i>num</i>; this occurs if all of the following conditions hold: <ul>
 
<li>Argument two (<i>intw</i>) is specified.
<tr><th>%intlen</th><td>Set to the value <i>len</i>, where the absolute value of <i>len</i> is the number of characters needed for the integer part of the first argument (<i>num</i>), with any leading zeroes stripped (or one zero if the integer part is zero), including one additional character if <i>num</i> is negative.  
<li>The absolute value of <i>len</i> is greater than <i>intw</i>.
<p>If <i>%intlen</i> is returned with a negative value, that indicates truncation of the integer part of <i>num</i>; this occurs if all of the following conditions hold:</p> 
<li><i>Intw</i>>0, or <i>num</i><0, or <i>num</i>>=1.
<ul>
<li>Argument four (<i>opt</i>) does not contain the letter 'V'. </ul> <p></p> If <i>num</i> cannot be converted to a number, then <i>len</i> is returned as zero, and the result (value of <i>%str</i>) of #NUM2STR is the MISSING value. <p></p> Otherwise, <i>len</i> is positive. <p></p> As these rules indicate, <i>%intlen</i>, if supplied, allows the <var class="product">Fast/Unload</var> program to continue when the first argument is non-numeric or the integer part is truncated in the result. If either of these conditions occur and <i>%intlen</i> is omitted, the <var class="product">Fast/Unload</var> program is cancelled.</td></tr>
<li>Argument two (<i>intw</i>) is specified. </li>
<li>The absolute value of <i>len</i> is greater than <i>intw</i>. </li>
<li><i>Intw</i>>0, or <i>num</i><0, or <i>num</i>>=1. </li>
<li>Argument four (<i>opt</i>) does not contain the letter 'V'. </li>  
</ul>  
<p>
If <i>num</i> cannot be converted to a number, then <i>len</i> is returned as zero, and the result (value of <i>%str</i>) of #NUM2STR is the MISSING value.  
<p>
Otherwise, <i>len</i> is positive.
</p>  
<p>
As these rules indicate, <i>%intlen</i>, if supplied, allows the <var class="product">Fast/Unload</var> program to continue when the first argument is non-numeric or the integer part is truncated in the result. If either of these conditions occur and <i>%intlen</i> is omitted, the <var class="product">Fast/Unload</var> program is cancelled.</p> </td></tr>
</table>
</table>
<p></p>
 
<p></p>
Examples:
Examples:
<p class="code"><nowiki>%N_HUMAN = 6 * 1000 * 1000 * 1000
<p class="code"><nowiki>%N_HUMAN = 6 * 1000 * 1000 * 1000
Line 1,289: Line 1,359:
         with  ...    %W = 0
         with  ...    %W = 0
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%intlen</i>, or terminating conditions,
Non-zero values of <i>%intlen</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%intlen</i> present, set to corresponding number;
if <i>%intlen</i> present, set to corresponding number;
Line 1,308: Line 1,378:
output file, you can also use the PUT with the AS STRING or AS DECIMAL
output file, you can also use the PUT with the AS STRING or AS DECIMAL
clauses (see [[Fast/Unload Extraction Language (FUEL)#put|PUT]]).
clauses (see [[Fast/Unload Extraction Language (FUEL)#put|PUT]]).
<p></p>
 
One difference between #NUM2STR and PUT AS STRING or PUT AS DECIMAL
One difference between #NUM2STR and PUT AS STRING or PUT AS DECIMAL
is that all conversion
is that all conversion
Line 1,316: Line 1,386:
digits.
digits.
</blockquote>
</blockquote>
<p></p>
 
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
==#N2DATE: Convert number of seconds*300 to datetime string==
==#N2DATE: Convert number of seconds*300 to datetime string==
The #N2DATE function converts a numeric datetime value expressed as
The #N2DATE function converts a numeric datetime value expressed as
Line 1,327: Line 1,398:
<p class="code"><nowiki>%dat = #N2DATE(datn, fmt, %rc)
<p class="code"><nowiki>%dat = #N2DATE(datn, fmt, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>datn</th><td>Numeric datetime value expressed as 300 times the number of seconds since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.</td></tr>
<tr><th>datn</th><td>Numeric datetime value expressed as 300 times the number of seconds since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.</td></tr>
Line 1,334: Line 1,405:
<tr><th>%dat</th><td>Set to datetime string value, in format specified by <i>fmt</i>, corresponding to <i>datn</i>.</td></tr>
<tr><th>%dat</th><td>Set to datetime string value, in format specified by <i>fmt</i>, corresponding to <i>datn</i>.</td></tr>
</table>
</table>
<p></p>
 
For example, the following fragment prints the string <code>07/31/84</code>
For example, the following fragment prints the string <code>07/31/84</code>
on the FUNPRINT dataset:
on the FUNPRINT dataset:
Line 1,342: Line 1,413:
REPORT %X
REPORT %X
</nowiki></p>
</nowiki></p>
<p></p>
 
Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
 
<b>Errors:</b>
<b>Errors:</b>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
Line 1,358: Line 1,429:
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>The inverse of this #function is #DATE2N.
<li>The inverse of this #function is #DATE2N. </li>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats and valid dates. </li>
</ul>
</ul>
   
   
Line 1,374: Line 1,445:
<p class="code"><nowiki>%test = #ONEOF(str, list, delim)
<p class="code"><nowiki>%test = #ONEOF(str, list, delim)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>String to find; required.</td></tr>
<tr><th>str</th><td>String to find; required.</td></tr>
Line 1,381: Line 1,452:
<tr><th>%test</th><td>Set to 1 if <i>str</i> is one of the strings in <i>list</i>, delimited by <i>delim</i>. Otherwise, <i>%test</i> is set to 0.</td></tr>
<tr><th>%test</th><td>Set to 1 if <i>str</i> is one of the strings in <i>list</i>, delimited by <i>delim</i>. Otherwise, <i>%test</i> is set to 0.</td></tr>
</table>
</table>
<p></p>
 
<p></p>
<p>
Examples:
Examples:
</p>
<p class="code"><nowiki>#ONEOF('HOW', 'HOW NOW', ' ')  returns  1
<p class="code"><nowiki>#ONEOF('HOW', 'HOW NOW', ' ')  returns  1
#ONEOF('NOW', 'HOW;NOW')      returns  1
#ONEOF('NOW', 'HOW;NOW')      returns  1
Line 1,395: Line 1,467:
#ONEOF('', '')                returns  0
#ONEOF('', '')                returns  0
</nowiki></p>
</nowiki></p>
<p></p>
<p>
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:</p>
 
<ul>
<ul>
<li><i>Delim</i> supplied, and length not 1.
<li><i>Delim</i> supplied, and length not 1. </li>
</ul>
</ul>
<p></p>
 
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>If argument 1 (<i>str</i>) contains <i>delim</i>, 0 is returned.
<li>If argument 1 (<i>str</i>) contains <i>delim</i>, 0 is returned. </li>
<li>If argument 2 (<i>list</i>) is the null string, 0 is returned.
 
<li>If argument 2 (<i>list</i>) is the null string, 0 is returned. </li>
 
<li>If argument 1 (<i>str</i>) is the null string, 1 is returned if,
<li>If argument 1 (<i>str</i>) is the null string, 1 is returned if,
and only if, there is a leading, trailing, or two adjacent copies of,
and only if, there is a leading, trailing, or two adjacent copies of,
<i>delim</i>.
<i>delim</i>. </li>
 
<li>This #function is similar to the #FIND function ([[##find|#FIND: Word position of one word sequence within another]]).
<li>This #function is similar to the #FIND function ([[##find|#FIND: Word position of one word sequence within another]]).
Note, however, that both #FIND and #ONEOF are inferior to the
Note, however, that both #FIND and #ONEOF are inferior to the
SELECT statement, when the only purpose is to test whether an
SELECT statement, when the only purpose is to test whether an
entity has one of several values (see [[Fast/Unload Extraction Language (FUEL)#sel|SELECT entity]]).
entity has one of several values (see [[Fast/Unload Extraction Language (FUEL)#sel|SELECT entity]]). </li>
</ul>
</ul>
<p></p>
<p>
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
</p>
   
   
<div id="#pad"></div>
<div id="#pad"></div>
Line 1,433: Line 1,510:
<p class="code"><nowiki>%out = #PAD(str, pad, len)
<p class="code"><nowiki>%out = #PAD(str, pad, len)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>Source string.</td></tr>
<tr><th>str</th><td>Source string.</td></tr>
<tr><th>pad</th><td>Optional pad character. Default is blank. If supplied, must be a string of length 1.</td></tr>
<tr><th>pad</th><td>Optional pad character. Default is blank. If supplied, must be a string of length 1.</td></tr>
<tr><th>len</th><td>Length of the output string. Must be numeric >= 0.</td></tr>
<tr><th>len</th><td>Length of the output string. Must be numeric >= 0.</td></tr>
<tr><th>%out</th><td>If <i>len</i> is greater then #LEN(<i>str</i>): <ul>
<tr><th>%out</th><td>If <i>len</i> is greater then #LEN(<i>str</i>):  
<li><i>len</i> - <nowiki>#LEN</nowiki>(<i>str</i>) copies of the pad character, followed by all of <i>str</i> </ul> <p></p> Otherwise: <ul>
<ul>
<li>substring from <i>str</i> starting at position #LEN(<i>str</i>) - <i>len+1</i> with length <i>len</i> </ul></td></tr>
<li><i>len</i> - <nowiki>#LEN</nowiki>(<i>str</i>) copies of the pad character, followed by all of <i>str</i> </li>
</ul>  
<p>Otherwise:</p>
<ul>
<li>substring from <i>str</i> starting at position #LEN(<i>str</i>) - <i>len+1</i> with length <i>len</i> </li>
</ul></td></tr>
</table>
</table>
For example:
For example:
Line 1,449: Line 1,531:
#PAD(456, 0, 4)        returns  '0456'
#PAD(456, 0, 4)        returns  '0456'
</nowiki></p>
</nowiki></p>
<p></p>
<p>
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:
</p>
<ul>
<ul>
<li><i>Len</i> not numeric, or less than 0.
<li><i>Len</i> not numeric, or less than 0. </li>
<li><i>Pad</i> supplied, and length not 1.
<li><i>Pad</i> supplied, and length not 1. </li>
</ul>
</ul>
<p></p>
 
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>This is the same as the #RIGHT function, except for the order of
<li>This is the same as the #RIGHT function, except for the order of
the arguments ([[##right|#RIGHT: Final substring, preceded by pad characters to specified length]]).
the arguments ([[##right|#RIGHT: Final substring, preceded by pad characters to specified length]]). </li>
</ul>
</ul>
<p></p>
<p>
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
</p>
   
   
<div id="#padr"></div>
<div id="#padr"></div>
Line 1,481: Line 1,565:
<p class="code"><nowiki>%out = #PADR(str, pad, len)
<p class="code"><nowiki>%out = #PADR(str, pad, len)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>Source string.</td></tr>
<tr><th>str</th><td>Source string.</td></tr>
<tr><th>pad</th><td>Optional pad character. Default is blank. If supplied, must be a string of length 1.</td></tr>
<tr><th>pad</th><td>Optional pad character. Default is blank. If supplied, must be a string of length 1.</td></tr>
<tr><th>len</th><td>Length of the output string. Must be numeric >= 0.</td></tr>
<tr><th>len</th><td>Length of the output string. Must be numeric >= 0.</td></tr>
<tr><th>%out</th><td>If <i>len</i> is greater then #LEN(<i>str</i>): <ul>
<tr><th>%out</th><td>If <i>len</i> is greater then #LEN(<i>str</i>):  
<li>all of <i>str</i>, followed by <i>len</i> - <nowiki>#LEN</nowiki>(<i>str</i>) copies of the pad character </ul> <p></p> Otherwise: <ul>
<ul>
<li>substring from <i>str</i> starting at position 1 with length <i>len</i> </ul></td></tr>
<li>all of <i>str</i>, followed by <i>len</i> - <nowiki>#LEN</nowiki>(<i>str</i>) copies of the pad character </li>
</ul>  
<p>Otherwise:
</p>
<ul>
<li>substring from <i>str</i> starting at position 1 with length <i>len</i> </li>
</ul></td></tr>
</table>
</table>
For example:
For example:
Line 1,496: Line 1,586:
#PADR(4.6, 0, 4)      returns  '4.60'
#PADR(4.6, 0, 4)      returns  '4.60'
</nowiki></p>
</nowiki></p>
<p></p>
<p>
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:</p>
<ul>
<ul>
<li><i>Len</i> not numeric, or less than 0.
<li><i>Len</i> not numeric, or less than 0. </li>
<li><i>Pad</i> supplied, and length not 1.
<li><i>Pad</i> supplied, and length not 1. </li>
</ul>
</ul>
<p></p>
 
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>This is the same as the #LEFT function, except for the order of
<li>This is the same as the #LEFT function, except for the order of
the arguments ([[##left|#LEFT: Initial substring, followed by pad characters to specified length]]).
the arguments ([[##left|#LEFT: Initial substring, followed by pad characters to specified length]]). </li>
</ul>
</ul>
<p></p>
<p>
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
</p>
==#REVERSE: Get reverse of string==
==#REVERSE: Get reverse of string==
The #REVERSE function returns a copy of the input string, with the order of
The #REVERSE function returns a copy of the input string, with the order of
Line 1,517: Line 1,609:
<p class="code"><nowiki>%out = #REVERSE(str)
<p class="code"><nowiki>%out = #REVERSE(str)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>Source string; required.</td></tr>
<tr><th>str</th><td>Source string; required.</td></tr>
Line 1,525: Line 1,617:
<p class="code"><nowiki>#REVERSE('abc')    returns  'cba'
<p class="code"><nowiki>#REVERSE('abc')    returns  'cba'
</nowiki></p>
</nowiki></p>
<p></p>
<p>This #function has no cancelling conditions.
This #function has no cancelling conditions.
</p>
<p></p>
<p>This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
</p>
   
   
<div id="#right"></div>
<div id="#right"></div>
Line 1,546: Line 1,638:
<p class="code"><nowiki>%out = #RIGHT(str, len, pad)
<p class="code"><nowiki>%out = #RIGHT(str, len, pad)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>Source string.</td></tr>
<tr><th>str</th><td>Source string.</td></tr>
<tr><th>len</th><td>Length of the output string.</td></tr>
<tr><th>len</th><td>Length of the output string.</td></tr>
<tr><th>pad</th><td>Optional pad character. Default is blank. If supplied, must be a string of length 1. Must be numeric >= 0.</td></tr>
<tr><th>pad</th><td>Optional pad character. Default is blank. If supplied, must be a string of length 1. Must be numeric >= 0.</td></tr>
<tr><th>%out</th><td>If <i>len</i> is greater then #LEN(<i>str</i>): <ul>
<tr><th>%out</th><td>If <i>len</i> is greater then #LEN(<i>str</i>):  
<li><i>len</i> - <nowiki>#LEN</nowiki>(<i>str</i>) copies of the pad character, followed by all of <i>str</i> </ul> <p></p> Otherwise: <ul>
<ul>
<li>substring from <i>str</i> starting at position #LEN(<i>str</i>) - <i>len+1</i> with length <i>len</i> </ul></td></tr>
<li><i>len</i> - <nowiki>#LEN</nowiki>(<i>str</i>) copies of the pad character, followed by all of <i>str</i> </li>
</ul>  
<p>
Otherwise:</p>
<ul>
<li>substring from <i>str</i> starting at position #LEN(<i>str</i>) - <i>len+1</i> with length <i>len</i> </li>
</ul></td></tr>
</table>
</table>
For example:
For example:
Line 1,562: Line 1,660:
#RIGHT(456, 4, 0)      returns  '0456'
#RIGHT(456, 4, 0)      returns  '0456'
</nowiki></p>
</nowiki></p>
<p></p>
<p>
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:</p>
<ul>
<ul>
<li><i>Len</i> not numeric, or less than 0.
<li><i>Len</i> not numeric, or less than 0. </li>
<li><i>Pad</i> supplied, and length not 1.
<li><i>Pad</i> supplied, and length not 1. </li>
</ul>
</ul>
<p></p>
 
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>This is the same as the #PAD function, except for the order of
<li>This is the same as the #PAD function, except for the order of
the arguments (see [[##pad|#PAD: Final substring, preceded by pad characters to specified length]]).
the arguments (see [[##pad|#PAD: Final substring, preceded by pad characters to specified length]]). </li>
</ul>
</ul>
<p></p>
<p>
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
</p>
==#SNDX: Create SOUNDEX code for string==
==#SNDX: Create SOUNDEX code for string==
The #SNDX function calculates a <b>SOUNDEX</b> code for a
The #SNDX function calculates a <b>SOUNDEX</b> code for a
Line 1,584: Line 1,684:
<p class="code"><nowiki>%out = #SNDX(str)
<p class="code"><nowiki>%out = #SNDX(str)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>String, presumed to contain a name.</td></tr>
<tr><th>str</th><td>String, presumed to contain a name.</td></tr>
<tr><th>%out</th><td>Set to the <b>SOUNDEX</b> code corresponding to <i>str</i>.</td></tr>
<tr><th>%out</th><td>Set to the <b>SOUNDEX</b> code corresponding to <i>str</i>.</td></tr>
</table>
</table>
<p></p>
<p>For example, the following fragment will build values for
For example, the following fragment will build values for
an INVISIBLE KEY field which is the $SNDX value of the
an INVISIBLE KEY field which is the $SNDX value of the
field NAME:
field NAME:
</p>
<p class="code"><nowiki>UAI OINDEX
<p class="code"><nowiki>UAI OINDEX
FOR EACH RECORD
FOR EACH RECORD
Line 1,601: Line 1,701:
END FOR
END FOR
</nowiki></p>
</nowiki></p>
<p></p>
<p>This #function has no cancelling conditions.
This #function has no cancelling conditions.
</p>
   
   
<div id="#strip"></div>
<div id="#strip"></div>
Line 1,617: Line 1,717:
<p class="code"><nowiki>%out = #STRIP(str, B|L|T, pad)
<p class="code"><nowiki>%out = #STRIP(str, B|L|T, pad)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>String to be stripped; required.</td></tr>
<tr><th>str</th><td>String to be stripped; required.</td></tr>
<tr><th>B|L|T</th><td>Optional indicator of the type of strip: <ul>
<tr><th>B|L|T</th><td>Optional indicator of the type of strip: <ul>
<li>'B...' (any string beginning with uppercase B): to strip <b>B</b>oth leading and trailing pad characters.
<li>'B...' (any string beginning with uppercase B): to strip <b>B</b>oth leading and trailing pad characters. </li>
<li>'L...' (any string beginning with uppercase L): to strip <b>L</b>eading pad characters only.
<li>'L...' (any string beginning with uppercase L): to strip <b>L</b>eading pad characters only. </li>
<li>'T...' (any string beginning with uppercase T): to strip <b>T</b>railing pad characters only. </ul> <p></p> Defaults to <b>B</b>.</td></tr>
<li>'T...' (any string beginning with uppercase T): to strip <b>T</b>railing pad characters only. </li>
</ul>  
<p>
Defaults to <b>B</b>.
</p> </td></tr>
 
<tr><th>%out</th><td>Set to a copy of <i>str</i>, with leading, trailing, or both, as specified, copies of <i>pad</i> removed.</td></tr>
<tr><th>%out</th><td>Set to a copy of <i>str</i>, with leading, trailing, or both, as specified, copies of <i>pad</i> removed.</td></tr>
</table>
</table>
<p></p>
<p>Examples:
Examples:
</p>
<p class="code"><nowiki>#STRIP('  ABC  ')          returns  'ABC'
<p class="code"><nowiki>#STRIP('  ABC  ')          returns  'ABC'
#STRIP('  ABC  ', 'L')    returns  'ABC  '
#STRIP('  ABC  ', 'L')    returns  'ABC  '
Line 1,633: Line 1,738:
#STRIP('000123', 'L', '0') returns  '123'
#STRIP('000123', 'L', '0') returns  '123'
</nowiki></p>
</nowiki></p>
<p></p>
<p>
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:</p>
<ul>
<ul>
<li><i>B|L|T</i> does not begin with either uppercase B, uppercase L,
<li><i>B|L|T</i> does not begin with either uppercase B, uppercase L,
or uppercase T.
or uppercase T. </li>
<li><i>Pad</i> specified and length is not 1.
 
<li><i>Pad</i> specified and length is not 1. </li>
</ul>
</ul>
<p></p>
 
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>This #function is similar to the #DEBLANK function ([[##deblnk|#DEBLANK: Remove leading and trailing blanks from substring]]).
<li>This #function is similar to the #DEBLANK function ([[##deblnk|#DEBLANK: Remove leading and trailing blanks from substring]]). </li>
</ul>
</ul>
<p></p>
<p>This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
</p>
   
   
<div id="#substr"></div>
<div id="#substr"></div>
Line 1,663: Line 1,769:
<p class="code"><nowiki>%out = #SUBSTR(str, pos, len)
<p class="code"><nowiki>%out = #SUBSTR(str, pos, len)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>Source string. For <var class="product">Fast/Unload</var> version 4.3 and later. <i>str</i> may be longer than 255 bytes.</td></tr>
<tr><th>str</th><td>Source string. For <var class="product">Fast/Unload</var> version 4.3 and later. <i>str</i> may be longer than 255 bytes.</td></tr>
Line 1,677: Line 1,783:
%RIGHT = #SUBSTR(%STR, %RIGHT)
%RIGHT = #SUBSTR(%STR, %RIGHT)
</nowiki></p>
</nowiki></p>
<p></p>
 
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:
<ul>
<ul>
<li><i>Pos</i> not numeric, or less than 1.
<li><i>Pos</i> not numeric, or less than 1. </li>
<li><i>Len</i> not numeric, or less than 0.
<li><i>Len</i> not numeric, or less than 0. </li>
</ul>
</ul>
<p><b>Notes</b></p>
<p>
<b>Notes</b></p>
<ul>
<ul>
<li>You can omit the <code>+</code>&nbsp;<code>1</code> in the "right hand half"
<li>You can omit the <code>+</code>&nbsp;<code>1</code> in the "right hand half"
Line 1,692: Line 1,799:
If it is shorter, omitting the <code>+</code>&nbsp;<code>1</code>
If it is shorter, omitting the <code>+</code>&nbsp;<code>1</code>
will cause your program to terminate, because <i>pos</i>
will cause your program to terminate, because <i>pos</i>
must be 1 or more.
must be 1 or more. </li>
 
<li>The maximum length of <i>%out</i> is
<li>The maximum length of <i>%out</i> is
<nowiki>#LEN</nowiki>(<i>str</i>)&nbsp;-&nbsp;<i>pos</i>&nbsp;+&nbsp;1.
<nowiki>#LEN</nowiki>(<i>str</i>)&nbsp;-&nbsp;<i>pos</i>&nbsp;+&nbsp;1. </li>
 
<li>To take an initial or final substring, you can also use the #functions
<li>To take an initial or final substring, you can also use the #functions
described in [[##left|#LEFT: Initial substring, followed by pad characters to specified length]] or [[##right|#RIGHT: Final substring, preceded by pad characters to specified length]].
described in [[##left|#LEFT: Initial substring, followed by pad characters to specified length]] or [[##right|#RIGHT: Final substring, preceded by pad characters to specified length]]. </li>
</ul>
</ul>
==#TIME: Current time and/or date==
==#TIME: Current time and/or date==
The #TIME function returns the current date and time in a
The #TIME function returns the current date and time in a
Line 1,707: Line 1,817:
<p class="code"><nowiki>%tim = #TIME(fmt, %rc)
<p class="code"><nowiki>%tim = #TIME(fmt, %rc)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>fmt</th><td>Optional datetime format string for <i>%tim</i>. Defaults to <b>HH:MI:SS</b>.</td></tr>
<tr><th>fmt</th><td>Optional datetime format string for <i>%tim</i>. Defaults to <b>HH:MI:SS</b>.</td></tr>
Line 1,717: Line 1,827:
<p class="code"><nowiki>ADD REORG_TIME = #TIME()
<p class="code"><nowiki>ADD REORG_TIME = #TIME()
</nowiki></p>
</nowiki></p>
<p></p>
<p>Non-zero values of <i>%rc</i>, or terminating conditions,
Non-zero values of <i>%rc</i>, or terminating conditions,
are shown in the following figure (see the discussion in
are shown in the following figure (see the discussion in
[[#funerr|Run-time errors during standard #function calls]]).
[[#funerr|Run-time errors during standard #function calls]]).
<p></p>
</p>
<b>Errors:</b>
<p><b>Errors:</b>
</p>
if <i>%rc</i> present, set to corresponding number
if <i>%rc</i> present, set to corresponding number
and set <i>%tim</i> to MISSING;
and set <i>%tim</i> to MISSING;
Line 1,733: Line 1,843:
<ul>
<ul>
<li>The only difference between #TIME and #DATE is the default value
<li>The only difference between #TIME and #DATE is the default value
for <i>fmt</i>.
for <i>fmt</i>. </li>
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats.
<li>[[Fast/Unload datetime processing considerations#dtfmt|Datetime formats]] explains valid datetime formats. </li>
</ul>
</ul>
==#TRANSLATE: Change characters of string using from/to pairings==
==#TRANSLATE: Change characters of string using from/to pairings==
The #TRANSLATE function returns a copy of the input string, with all characters
The #TRANSLATE function returns a copy of the input string, with all characters
Line 1,747: Line 1,858:
<p class="code"><nowiki>%out = #TRANSLATE(str, tbl_out, tbl_in, pad)
<p class="code"><nowiki>%out = #TRANSLATE(str, tbl_out, tbl_in, pad)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>Source string; required.</td></tr>
<tr><th>str</th><td>Source string; required.</td></tr>
Line 1,762: Line 1,873:
#TRANSLATE('ab', '', , 'z')  returns  .zz.
#TRANSLATE('ab', '', , 'z')  returns  .zz.
</nowiki></p>
</nowiki></p>
<p></p>
<p>
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:</p>
<ul>
<ul>
<li>Only <i>str</i> argument supplied.
<li>Only <i>str</i> argument supplied. </li>
<li><i>Pad</i> supplied, and length not 1.
<li><i>Pad</i> supplied, and length not 1. </li>
</ul>
</ul>
<p></p>
<p>
<p><b>Notes</b></p>
<b>Notes</b></p>
<ul>
<ul>
<li>As a consequence of the default rules, if neither <i>tbl_out</i>
<li>As a consequence of the default rules, if neither <i>tbl_out</i>
nor <i>tbl_in</i> are supplied, <i>%out</i> is set to
nor <i>tbl_in</i> are supplied, <i>%out</i> is set to
as many copies of <i>pad</i> as #LEN(<i>str</i>).
as many copies of <i>pad</i> as #LEN(<i>str</i>). </li>
 
<li>If a character occurs more than once in <i>tbl_in</i>,
<li>If a character occurs more than once in <i>tbl_in</i>,
all instances of it after the first are ignored.
all instances of it after the first are ignored. </li>
 
<li>As noted, the default <i>tbl_in</i> is a <b>256</b> byte
<li>As noted, the default <i>tbl_in</i> is a <b>256</b> byte
string; it is not possible to specify such a value in <var class="product">Fast/Unload</var>.
string; it is not possible to specify such a value in <var class="product">Fast/Unload</var>.
Line 1,784: Line 1,897:
%TBL_FF  = ...  /* Value that X'FF' translates to
%TBL_FF  = ...  /* Value that X'FF' translates to
%OUT = #TRANSLATE(%STR, %TBL_OUT, , %TBL_FF)
%OUT = #TRANSLATE(%STR, %TBL_OUT, , %TBL_FF)
</nowiki></p>
</nowiki></p> </li>
</ul>
</ul>
<p></p>
<p>
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
</p>
==#UPCASE: Change lowercase letters of string to uppercase==
==#UPCASE: Change lowercase letters of string to uppercase==
The #UPCASE function returns a copy of the input string, with all lowercase
The #UPCASE function returns a copy of the input string, with all lowercase
Line 1,794: Line 1,909:
<p class="code"><nowiki>%out = #UPCASE(str)
<p class="code"><nowiki>%out = #UPCASE(str)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>Source string; required.</td></tr>
<tr><th>str</th><td>Source string; required.</td></tr>
Line 1,804: Line 1,919:
#UPCASE('')        returns  ''
#UPCASE('')        returns  ''
</nowiki></p>
</nowiki></p>
<p></p>
<p>This #function has no cancelling conditions.
This #function has no cancelling conditions.
</p>
<p></p>
<p>This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
</p>
 
==#VERPOS: Position in string of character not in or in list==
==#VERPOS: Position in string of character not in or in list==
The #VERPOS function scans a search string from an optional starting
The #VERPOS function scans a search string from an optional starting
Line 1,823: Line 1,939:
position in the search string of the first character not in the
position in the search string of the first character not in the
target string, or 0 if all characters in the search string are in
target string, or 0 if all characters in the search string are in
the target string.
the target string. </li>
 
<li>For the <b>M</b>atched search, returns the position in the
<li>For the <b>M</b>atched search, returns the position in the
search string of the first character which is in the target string,
search string of the first character which is in the target string,
or 0 if no characters in the search string are in the target string.
or 0 if no characters in the search string are in the target string. </li>
</ul>
</ul>
<p class="code"><nowiki>%opos = #VERPOS(search, target, NorM, pos)
<p class="code"><nowiki>%opos = #VERPOS(search, target, NorM, pos)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>search</th><td>String to be searched.</td></tr>
<tr><th>search</th><td>String to be searched.</td></tr>
<tr><th>target</th><td>String containing set of target characters.</td></tr>
<tr><th>target</th><td>String containing set of target characters.</td></tr>
<tr><th>NorM</th><td>Optional indicator of the type of search being formed: <ul>
<tr><th>NorM</th><td>Optional indicator of the type of search being formed:  
<li>'N...' (any string beginning with uppercase N): to find position of first character of <i>search</i> not present in <i>target</i>.
<ul>
<li>'M...' (any string beginning with uppercase M): to find position of first character of <i>search</i> present in <i>target</i>. </ul> <p></p> Defaults to <b>N</b>.</td></tr>
<li>'N...' (any string beginning with uppercase N): to find position of first character of <i>search</i> not present in <i>target</i>. </li>
<li>'M...' (any string beginning with uppercase M): to find position of first character of <i>search</i> present in <i>target</i>. </li>
</ul>  
<p>Defaults to <b>N</b>.
</p> </td></tr>
 
<tr><th>pos</th><td>Optional position within <i>search</i> to begin scanning. Must be a positive numeric value, default is 1.</td></tr>
<tr><th>pos</th><td>Optional position within <i>search</i> to begin scanning. Must be a positive numeric value, default is 1.</td></tr>
<tr><th>%opos</th><td>Set to position of first character in <i>search</i> that is not in ('N') or is in ('M') <i>target</i>, at or after the position identified by <i>pos</i>.</td></tr>
<tr><th>%opos</th><td>Set to position of first character in <i>search</i> that is not in ('N') or is in ('M') <i>target</i>, at or after the position identified by <i>pos</i>.</td></tr>
</table>
</table>
<p></p>
<p>Examples:
<p></p>
</p>
Examples:
<p class="code"><nowiki>#VERPOS('SIRIUS', 'ETANOISHRDLU')  returns    0
<p class="code"><nowiki>#VERPOS('SIRIUS', 'ETANOISHRDLU')  returns    0
#VERPOS('HOMER', 'MRH')            returns    2
#VERPOS('HOMER', 'MRH')            returns    2
Line 1,851: Line 1,973:
#VERPOS('WILMA', 'AEIOU', 'M', 3)  returns    5
#VERPOS('WILMA', 'AEIOU', 'M', 3)  returns    5
</nowiki></p>
</nowiki></p>
<p></p>
<p>
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:</p>
<ul>
<ul>
<li><i>NorM</i> does not begin with either uppercase N or uppercase M.
<li><i>NorM</i> does not begin with either uppercase N or uppercase M. </li>
<li><i>Pos</i> not numeric, or less than 1.
<li><i>Pos</i> not numeric, or less than 1. </li>
</ul>
</ul>
<p><b>Notes</b></p>
<p>
<b>Notes</b></p>
<ul>
<ul>
<li>If <i>search</i> is null, #VERPOS returns 0, as long as the
<li>If <i>search</i> is null, #VERPOS returns 0, as long as the
other arguments are not in error.
other arguments are not in error.
If <i>pos</i> is greater than #LEN(<i>search</i>), #VERPOS
If <i>pos</i> is greater than #LEN(<i>search</i>), #VERPOS
returns 0.
returns 0. </li>
 
<li>If <i>search</i> is non-null and <i>target</i>
<li>If <i>search</i> is non-null and <i>target</i>
is null, #VERPOS returns 0 if <i>NorM</i> starts with 'M',
is null, #VERPOS returns 0 if <i>NorM</i> starts with 'M',
otherwise #VERPOS returns :DT.<i>pos</i>.
otherwise #VERPOS returns :DT.<i>pos</i>. </li>
 
<li>The function which performs this service is usually called
<li>The function which performs this service is usually called
"verify", but <code>#VERPOS</code> is used to distinguish it from
"verify", but <code>#VERPOS</code> is used to distinguish it from
Line 1,872: Line 1,997:
<ul>
<ul>
<li>$VERIFY has only a "Boolean" (0 or 1) return; #VERPOS returns a
<li>$VERIFY has only a "Boolean" (0 or 1) return; #VERPOS returns a
position or 0 to indicate search "failed".
position or 0 to indicate search "failed". </li>
<li>$VERIFY only has a "nomatch" type of search.
 
<li>$VERIFY does not have a <i>pos</i> argument.
<li>$VERIFY only has a "nomatch" type of search. </li>
 
<li>$VERIFY does not have a <i>pos</i> argument. </li>
 
<li>$VERIFY returns 0 if there is a character in <i>search</i>
<li>$VERIFY returns 0 if there is a character in <i>search</i>
which is not in <i>target</i>; #VERPOS (Nomatch)
which is not in <i>target</i>; #VERPOS (Nomatch)
returns 0 if there is <i>no</i> such character.
returns 0 if there is <i>no</i> such character. </li>
 
<li>$VERIFY returns "some character in <i>search</i>
<li>$VERIFY returns "some character in <i>search</i>
is not in <i>target</i>" (0) if <i>search</i> is null and
is not in <i>target</i>" (0) if <i>search</i> is null and
<i>target</i> is not null; #VERPOS returns "all characters in
<i>target</i> is not null; #VERPOS returns "all characters in
<i>search</i> are in <i>target</i>" if <i>search</i> is null,
<i>search</i> are in <i>target</i>" if <i>search</i> is null,
whether or not <i>target</i> is null.
whether or not <i>target</i> is null. </li>
</ul>
</ul>
</ul>
</ul>
==#WORD: Return nth blank-delimited word from string==
==#WORD: Return nth blank-delimited word from string==
The #WORD function returns the designated
The #WORD function returns the designated
Line 1,891: Line 2,021:
<p class="code"><nowiki>%out = #WORD(str, word)
<p class="code"><nowiki>%out = #WORD(str, word)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>String containing blank-delimited words; required.</td></tr>
<tr><th>str</th><td>String containing blank-delimited words; required.</td></tr>
<tr><th>word</th><td>Number of word within <i>str</i> to return; required. Must be numeric greater than or equal to 1.</td></tr>
<tr><th>word</th><td>Number of word within <i>str</i> to return; required. Must be numeric greater than or equal to 1.</td></tr>
<tr><th>%out</th><td>Set to the <i>word</i>th blank-delimited word within <i>str</i>. If <i>word</i> is greater than the number of words in <i>str</i>, the null string is returned.</td></tr>
<tr><th>%out</th><td>Set to the <i>word</i>th blank-delimited word within <i>str</i>. If <i>word</i> is greater than the number of words in <i>str</i>, the null string is returned.</td></tr>
</table>
</table>
<p></p>
<p>Examples:
Examples:
</p>
<p class="code"><nowiki>#WORD('A B C', 1)      returns  'A'
<p class="code"><nowiki>#WORD('A B C', 1)      returns  'A'
#WORD('A B C', 2)      returns  'B'
#WORD('A B C', 2)      returns  'B'
Line 1,905: Line 2,037:
#WORD('    ', 1)      returns  ''
#WORD('    ', 1)      returns  ''
</nowiki></p>
</nowiki></p>
<p></p>
<p>
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:</p>
<ul>
<ul>
<li><i>word</i> is not numeric, or less than 1.
<li><i>word</i> is not numeric, or less than 1. </li>
</ul>
</ul>
<p></p>
 
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>The User Language $WORD function also has an optional
<li>The User Language $WORD function also has an optional
delimiter character argument, and its "<i>word</i>"
delimiter character argument, and its "<i>word</i>"
argument is argument number 3.
argument is argument number 3. </li>
</ul>
</ul>
<p></p>
<p>This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
</p>
 
==#WORDS: Count number of blank-delimited word in string==
==#WORDS: Count number of blank-delimited word in string==
The #WORDS function returns the number of
The #WORDS function returns the number of
Line 1,926: Line 2,059:
<p class="code"><nowiki>%count = #WORDS(str)
<p class="code"><nowiki>%count = #WORDS(str)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>str</th><td>String containing blank-delimited words; required.</td></tr>
<tr><th>str</th><td>String containing blank-delimited words; required.</td></tr>
<tr><th>%count</th><td>Set to number of word within <i>str</i>.</td></tr>
<tr><th>%count</th><td>Set to number of word within <i>str</i>.</td></tr>
</table>
</table>
<p></p>
<p>Examples:
Examples:
</p>
<p class="code"><nowiki>#WORDS('A B C')      returns  3
<p class="code"><nowiki>#WORDS('A B C')      returns  3
#WORDS('ABC')        returns  1
#WORDS('ABC')        returns  1
#WORDS('  ')        returns  0
#WORDS('  ')        returns  0
</nowiki></p>
</nowiki></p>
<p></p>
<p>This #function has no cancelling conditions.
This #function has no cancelling conditions.
</p>
<p><b>Notes</b></p>
<p>
<b>Notes</b></p>
<ul>
<ul>
<li>The User Language $WORDS function also has an optional
<li>The User Language $WORDS function also has an optional
delimiter character argument.
delimiter character argument. </li>
</ul>
</ul>
<p></p>
<p>
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
This #function is new in <var class="product">Fast/Unload</var> version 4.0.
</p>
==#X2C: Convert hex representation to character string==
==#X2C: Convert hex representation to character string==
The #X2C function converts a string of hexadecimal characters (the
The #X2C function converts a string of hexadecimal characters (the
Line 1,955: Line 2,091:
<p class="code"><nowiki>%str = #X2C(hex)
<p class="code"><nowiki>%str = #X2C(hex)
</nowiki></p>
</nowiki></p>
where
Where:
<table>
<table>
<tr><th>hex</th><td>String to convert; contains only the characters 0-9 and A-F.</td></tr>
<tr><th>hex</th><td>String to convert; contains only the characters 0-9 and A-F.</td></tr>
Line 1,967: Line 2,103:
</nowiki></p>
</nowiki></p>
%JUNK would be set to EBCDIC X'0102' which is a non-displayable string.
%JUNK would be set to EBCDIC X'0102' which is a non-displayable string.
<p></p>
<p>
The <b><i>Fast/Unload</i></b> run is cancelled with a return
The <var class="product">Fast/Unload</var> run is cancelled with a return
code of 8 when:
code of 8 when:
</p>
<ul>
<ul>
<li>Non-hexadecimal digit character in <i>hex</i>.
<li>Non-hexadecimal digit character in <i>hex</i>. </li>
</ul>
</ul>
<p><b>Notes</b></p>
<p><b>Notes</b></p>
<ul>
<ul>
<li>The inverse of this #function is #C2X.
<li>The inverse of this #function is #C2X. </li>
 
<li>If the number of characters of <i>hex</i> is odd, a leading
<li>If the number of characters of <i>hex</i> is odd, a leading
character 0 is added for the conversion.
character 0 is added for the conversion.
The User Language $X2C function (http://m204wiki.rocketsoftware.com/index.php/$X2C)
The User Language $X2C function (http://m204wiki.rocketsoftware.com/index.php/$X2C)
requires an even number of characters in <i>hex</i>.
requires an even number of characters in <i>hex</i>. </li>
<li>The $X2C function returns the null string if <i>hex</i> has an error.
 
<li>The $X2C function returns the null string if <i>hex</i> has an error. </li>
 
<li>The User Language $IHEXA function (http://m204wiki.rocketsoftware.com/index.php/$IHexA)
<li>The User Language $IHEXA function (http://m204wiki.rocketsoftware.com/index.php/$IHexA)
converts any non-hex characters in <i>hex</i> to 0.
converts any non-hex characters in <i>hex</i> to 0. </li>
</ul>
</ul>
==See also==
==See also==
[[Fast/Unload overview#WIKFUN$$topics|Fast/Unload topics]]
[[Fast/Unload overview#WIKFUN$$topics|Fast/Unload topics]]

Revision as of 20:58, 4 February 2015


This wiki page lists the #functions provided with Fast/Unload. #Functions can be used as the expression in an assignment statement, as described in Assignment statement. Each #function is presented here with a brief phrase denoting its use, a short explanation, the form and types of its arguments and the result (or "output value"), one or more examples, any error conditions, and special notes.

Unless otherwise indicated, all arguments shown are required and are input arguments, and any arguments with the MISSING value are treated as either null strings (for string arguments) or zeroes (for numeric arguments). See #Function calls for an explanation of required/optional, output, and other types of arguments.

In some instances the behavior of a #function will be compared to the behavior of a corresponding SOUL $function.

FUEL also contains program entities called "special variables" that might be initially mistaken for #functions. Similar to #functions in appearance and syntax, special variables are described in Special variables.

Unless otherwise indicated, all input strings of the standard #functions are treated as non-DBCS, and all output strings have type of non-DBCS.

Run-time errors during standard #function calls

The default approach for handling errors in calls to standard #functions is strict:

  • Fast/Unload treats most errors which the programmer can reasonably avoid as serious and terminates the run, if you have not provided for checking of the error.
  • At termination, Fast/Unload will issue a message describing the nature of the error, the input program line number being executed and, if the error occurred during the execution of a #function, a dump of the current value of each #function argument.

Fast/Unload provides an optional output "return code" argument for some #functions. You can test the value set in this argument for errors in the value of the other arguments. Various non-zero values for the return code argument indicate error conditions; unless otherwise indicated, when one of these is set, the #function result is set to the MISSING value. If you omit the return code argument and there is an error in the value of an argument, the program is cancelled.

For example, since 'ONE WEEK' isn't numeric, the following fragment:

%NEW_DT = #DATECHG('MM/DD/YY', '01/01/96', 'ONE WEEK',, - %TST) IF %TST NE 0 THEN REPORT 'Error incrementing date:' AND %TST END IF

will set %NEW_DT to the MISSING value and will produce the following line on the FUNPRINT dataset:

Error incrementing date: 12

while the following fragment:

%NEW_DT = #DATECHG('MM/DD/YY', '01/01/96', 'ONE WEEK')

will cause Fast/Unload to immediately terminate, issuing an error message that a value is non-numeric, as shown in the following sample from FUNPRINT:

FUNL0053 Unload started. FUNL0116 Value is non-numeric or is out of range in line 203; Fast/Unload cancelled. FUNL0127 Fast/Unload cancelled unloading input record number 0 in file PROCFILE. FUNL0130 Fast/Unload cancelled during execution of line 203. FUNL0128 3 argument positions passed to #function; values : FUNL0129 01=MM/DD/YY. FUNL0129 02=01/01/96. FUNL0129 03=ONE WEEK.

Each #function description in this wiki page has a figure showing the error conditions for the #function and, if there is a "return code" argument, the non-zero values for it. Notice that, in general, there are no run-time errors for missing required arguments or too many arguments; this is because such checking is done at compile time.

#ABDUMP: End Fast/Unload with ABEND and dump

The #ABDUMP function accepts a numeric argument, and causes the Fast/Unload job to terminate with user abend code equal to that argument, producing a dump.

%junk = #ABDUMP(ccode)

Where:

ccodeCondition code for user ABEND; optional, defaults to 0.
%junkThis #function does not return, but the FUEL syntax requires a place to store the #function result.

For example, the following fragment abends the job when the input record number is 12345:

IF #RECIN EQ 12345 %FOO = #ABDUMP(99) END IF

Notes

  • The purpose of this #function is to assist in problem diagnosis; Technical Support will direct you if ever it needs to be used.

This #function is new in Fast/Unload version 4.1.

#CONCAT: Concatenate strings

The #CONCAT function accepts two or more arguments and returns a string value that is the concatenation of all of its arguments.

%out = #CONCAT(stra, strb ...)

Where:

straFirst input string (required).
strbSecond input string (required).
...Additional input strings (optional). For versions of Fast/Unload prior to 4.3, total length of all input strings may not exceed 255.
%outConcatenation of inputs.

For example, the following fragment prints the line Bugs Bunny on the FUNPRINT dataset:

%RABBIT = #CONCAT('Bugs', ' ', 'Bunny') REPORT %RABBIT

The Fast/Unload run is cancelled with a return code of 8 when:

  • Total length of input strings exceeds 255 and Fast/Unload version is less than 4.3.
  • Argument missing (see "Notes" below).

Notes

  • If the nth argument is present, where n is greater than 1, then the n-1st argument must be also be present. That is, the following will result in a run-time error, because the third argument is absent:

    %X = #CONCAT(%A, %B, , %D)

  • See #CONCAT_TRUNC: Concatenate strings, allowing truncation if your version of Fast/Unload is earlier than 4.3 and if you cannot ensure that the total length of the #CONCAT input strings is less than 256.

#CONCAT_TRUNC: Concatenate strings, allowing truncation

The #CONCAT_TRUNC function accepts an optional output argument and two or more string arguments and returns a string value that is the concatenation of the string arguments, to a maximum of 255 bytes. It allows the total length of the string arguments to exceed 255, and returns the total length of those arguments as the absolute value of the output argument, setting it to a negative value if the length exceeds 255.

%out = #CONCAT_TRUNC(%lenrc, stra, strb ...)

Where:

%lenrcOptional %variable, set to total length of stra, strb, ..., or to the negative of that length, if it exceeds 255.
straFirst input string (required).
strbSecond input string (required).
...Additional input strings (optional).
%outConcatenation of stra, strb, ..., or the first 255 bytes of that concatenation, if it exceeds 255.

For example, the following fragment

%FOO = #CONCAT_TRUNC(%LEN, 'Hello,', - ' ', 'World!') REPORT %FOO AND 'length is' AND %LEN

prints the following line on the FUNPRINT dataset:

Hello, World! length is 13

The Fast/Unload run is cancelled with a return code of 8 when:

  • Argument missing (see "Notes" below).

Notes

  • If the nth argument is present, where n is greater than 2, then the n-1st argument must be also be present. That is, the following will result in a run-time error, because the fourth argument is absent:

    %X = #CONCAT_TRUNC(%L, %A, %B, , %D)

  • See #CONCAT: Concatenate strings if you want Fast/Unload to terminate if the total length of the input strings is greater than 255.

This #function is new in Fast/Unload version 4.0.

#C2X: Convert character string to hex representation

The #C2X function expects one required argument and returns a string containing the hexadecimal representation of the value in the argument string. Each byte position of the input string is converted to two characters in the result string, using only the characters 0-9 and A-F.

%hex = #C2X(str)

Where:

strString to convert. Must be 127 bytes or less.
%hexString containing hex digits.

For example, the code fragment

%JUNK = #C2X('ABabc') REPORT 'X''' WITH %JUNK WITH ''''

would produce X'C1C2818283', while

%JUNK = #C2X(' 1 ') REPORT 'X''' WITH %JUNK WITH ''''

would produce X'40F140'.

The Fast/Unload run is cancelled with a return code of 8 when:

  • Length of str exceeds 127.

Notes

#DATE: Current date and/or time

The #DATE function accepts an optional datetime format argument and an optional output return code argument and returns the current date and time in the specified (or defaulted) format.

%dat = #DATE(fmt, %rc)

Where:

fmtOptional format for returned date, default is YYYY-MM-DD.
%rcOptional output return code variable.
%datDatetime string with indicated format.

For example, the following fragment stores the current date in the last occurrence of the REORG_DATE field:

ADD REORG_DATE = #DATE()

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %dat to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.

Notes

  • The only difference between #TIME and #DATE is the default value for fmt.
  • The default format returned by the User Language $DATE and $SIR_DATE functions is "YY–MM–DD"; the default format returned by #DATE is "YYYY–MM–DD".
  • Datetime formats explains valid datetime formats.

#DATECHG: Add some days to datetime

The #DATECHG function adds a specified number of days to an input datetime, returning the incremented datetime. It requires a datetime format argument, a datetime value, and a signed number of days. It accepts an optional CENTSPAN value for interpreting datetimes with two digit years. The incremented datetime is returned in the same format as the input datetime. An optional output return code argument allows the FUEL program to intercept error conditions.

%odat = #DATECHG(fmt, dat, n, span, %rc)

Where:

fmtFormat of dat and %odat.
datDatetime string.
nNumber of days to add to dat.
spanOptional CENTSPAN value.
%rcReturn code variable (optional, output).
%odatSet to dat plus n days.

For example, the following fragment prints the date one week after the run date on the FUNPRINT dataset:

%X = #DATE('DAY Month, YYYY') %X = #DATECHG('DAY Month, YYYY', %X, 7) REPORT %X

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %odat to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.
8dat does not match fmt or result date out of range.
12n is not a number or span is invalid.

Notes

#DATECHK: Check if datetime matches format

The #DATECHK function verifies that a specific datetime value is valid for a given datetime format. It requires a datetime format argument and a datetime value. It accepts an optional CENTSPAN value for interpreting datetimes with two digit years. An optional output return code argument allows the FUEL program to intercept error conditions. The #DATECHK function returns 1 if all arguments are valid and consistent, else 0 if all arguments are valid except for the date.

%tst = #DATECHK(fmt, dat, span, %rc)

Where:

fmtDatetime format string for dat.
datDatetime string to be validated against fmt.
spanOptional CENTSPAN value.
%rcReturn code variable (optional, output).
%tstSet to 1 if dat matches fmt, 0 otherwise.

For example, the following fragment prints the string Bad on the FUNPRINT dataset:

%X = #DATECHK('DAY Month, YYYY', '30 February, 1997') IF %X = 1 THEN REPORT 'Good' ELSE REPORT 'Bad' END IF

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %tst to MISSING; if absent, cancel Fast/Unload with return code 8.

4Fmt is not a valid datetime format.
12span is an invalid CENTSPAN value.

Notes

  • Datetime formats explains valid datetime formats and valid dates.
  • CENTSPAN explains CENTSPAN arguments.
  • The SOUL $DateChk function does not provide a call-level argument for interpreting two-digit years, the thread-level CENTSPLT/DEFCENT parameters are used instead.
  • The SOUL $Sir_DateChk function provides a CENTSPAN argument in the same fashion as #DATECHK.

#DATECNV: Convert datetime to different format

The #DATECNV function converts a datetime value from one datetime format to another datetime format. It requires an input datetime value, a corresponding input datetime format string, and an output datetime format string. It accepts an optional CENTSPAN value for interpreting datetimes with two digit years. An optional output return code argument allows the FUEL program to intercept error conditions. The #DATECNV function returns the input datetime value in the format specified by the output datetime format string.

%odat = #DATECNV(infmt, outfmt, dat, span, %rc)

Where:

infmtDatetime format string for dat.
outfmtDatetime format string for odat.
datInput datetime string.
spanOptional CENTSPAN value.
%rcReturn code variable (optional, output).
%odatSet to the value of dat, converted to output format.

For example, this prints the string 19970101 on the FUNPRINT dataset:

%X = #DATECNV('YYMMDD', 'YYYYMMDD', '970101', 1950) REPORT %X

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %odat to MISSING; if absent, cancel Fast/Unload with return code 8.

4infmt or outfmt is not a valid datetime format.
8dat does not match infmt.
12span is an invalid CENTSPAN value.
16Converted datetime value out of range for %outfmt.

Notes

#DATEDIF: Difference between two dates

The #DATEDIF function subtracts a second date from a first date and returns the difference in days, ignoring time portions for both dates. It requires a first datetime format string, a first datetime value, and a second datetime value. It accepts an optional second datetime format string and an optional CENTSPAN value for interpreting datetimes with two digit years. An optional output return code argument allows the FUEL program to intercept error conditions.

%dif = #DATEDIF(fmta, data, fmtb, datb, - span, %rc)

Where:

fmtaDatetime format string for data.
dataFirst datetime string.
fmtbOptional second datetime format string for datb. Default is to use fmta.
datbSecond datetime string.
spanOptional CENTSPAN value.
%rcReturn code variable (optional, output).
%difSet to the number of days obtained by subtracting the second date from the first date, ignoring any time components of both dates.

For example, the following fragment prints the string 7 days on the FUNPRINT dataset:

%X = #DATEDIF('YYMMDD', '970308', , '970301') REPORT %X AND 'days'

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %dif to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmta or fmtb is not a valid datetime format.
8data does not match fmta, or datb does not match fmtb.
12span is an invalid CENTSPAN value.

Notes

  • Time is ignored in the subtraction.
  • In the example above, even though the input dates have 2-digit years, there is no need for a span argument, since the dates are in the same year.
  • As in the SOUL $DATEDIF function, the single span argument is used for both dates; if it is necessary to get the difference between two dates which both have 2-digit years and are in different 100-year windows, you must first use #DATECNV to convert one of them to some 4-digit year format.
  • Datetime formats explains valid datetime formats and valid dates.
  • CENTSPAN explains CENTSPAN arguments.

#DATEFMT: Validate datetime format string

The #DATEFMT function is used to validate a datetime format string. It requires a datetime format string. It returns a value of 1 if the datetime format string is valid, else it returns a value of 0.

%tst = #DATEFMT(fmt)

Where:

fmtDatetime format string to be validated.
%tstSet to 1 if fmt is a valid format string, else set to 0.

For example, the following fragment prints the string Good on the FUNPRINT dataset:

%X = #DATEFMT('CYYDDDHHMISSXXX') IF %X = 1 THEN REPORT 'Good' ELSE REPORT 'Bad' END IF

This #function has no terminating conditions.

Notes

#DATE2N: Convert datetime string to number of seconds*300

The #DATE2N function converts a datetime value in a string format into a numeric form that is the corresponding number of seconds*300 since January 1, 1900. It requires a datetime value string and a corresponding datetime format string. It accepts an optional CENTSPAN value for interpreting datetimes with two digit years. An optional output return code argument allows the FUEL program to intercept error conditions.

%num = #DATE2N(dat, fmt, span, %rc)

Where:

datDatetime value string.
fmtDatetime format string for dat.
spanOptional CENTSPAN value.
%rcReturn code variable (optional, output).
%numSet to the number of seconds*300 since 1 Jan 1900 12:00 AM that corresponds to the datetime value of dat.

For example, the following fragment prints the value BEFORE on the FUNPRINT dataset:

IF #DATE2N('121494', 'MMDDYY') < - #DATE2N('040195', 'MMDDYY') THEN REPORT 'BEFORE' END IF

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %num to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.
8dat does not match fmt or result date out of range.
12span is an invalid CENTSPAN value.

Notes

  • Values returned by #DATE2N
  • will often exceed the range that can be represented in a 4-byte integer, so you should probably avoid storing the value in a BINARY or FLOAT4 field.
  • Dates prior to 1 January 1900 will return a negative number.
  • The inverse of this #function is #N2DATE.
  • Datetime formats explains valid datetime formats and valid dates.
  • CENTSPAN explains CENTSPAN arguments.

#DATE2ND: Convert datetime string to number of days

The #DATE2ND function converts a datetime value in a string format into a numeric form that is the corresponding number of days since January 1, 1900. It requires a datetime value string and a corresponding datetime format string. It accepts an optional CENTSPAN value for interpreting datetimes with two digit years. An optional output return code argument allows the FUEL program to intercept error conditions.

%num = #DATE2ND(dat, fmt, span, %rc)

Where:

datDatetime value string.
fmtDatetime format string for dat.
spanOptional CENTSPAN value.
%rcReturn code variable (optional, output).
%numSet to the number of days since 1 Jan 1900 12:00 AM that corresponds to the datetime value of dat.

For example, the following fragment prints the value BEFORE on the FUNPRINT dataset:

IF #DATE2ND('121494', 'MMDDYY') < - #DATE2ND('040195', 'MMDDYY') THEN REPORT 'BEFORE' END IF

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %num to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.
8dat does not match fmt or result date out of range.
12span is an invalid CENTSPAN value.

Notes

  • Dates prior to 1 January 1900 will return a negative number.
  • The inverse of this #function is #ND2DATE.
  • Datetime formats explains valid datetime formats and valid dates.
  • CENTSPAN explains CENTSPAN arguments.

#DATE2NM: Convert datetime string to number of milliseconds

The #DATE2NM function converts a datetime value in a string format into a numeric form that is the corresponding number of milliseconds since January 1, 1900. It requires a datetime value string and a corresponding datetime format string. It accepts an optional CENTSPAN value for interpreting datetimes with two digit years. An optional output return code argument allows the FUEL program to intercept error conditions.

%num = #DATE2NM(dat, fmt, span, %rc)

Where:

datDatetime value string.
fmtDatetime format string for dat.
spanOptional CENTSPAN value.
%rcReturn code variable (optional, output).
%numSet to the number of milliseconds since 1 Jan 1900 12:00 AM that corresponds to the datetime value of dat.

For example, the following fragment prints the value 'BEFORE' on the FUNPRINT dataset:

IF #DATE2NM('121494', 'MMDDYY') < - #DATE2NM('040195', 'MMDDYY') THEN REPORT 'BEFORE' END IF

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %num to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.
8dat does not match fmt or result date out of range.
12span is an invalid CENTSPAN value.

Notes

  • Values returned by #DATE2NM will often exceed the range that can be represented in a 4-byte integer, so you should probably avoid storing the value in a BINARY or FLOAT4 field.
  • Dates prior to 1 January 1900 will return a negative number.
  • The inverse of this #function is #NM2DATE.
  • Datetime formats explains valid datetime formats and valid dates.
  • CENTSPAN explains CENTSPAN arguments.

#DATE2NS: Convert datetime string to number of seconds

The #DATE2NS function converts a datetime value in a string format into a numeric form that is the corresponding number of seconds since January 1, 1900. It requires a datetime value string and a corresponding datetime format string. It accepts an optional CENTSPAN value for interpreting datetimes with two digit years. An optional output return code argument allows the FUEL program to intercept error conditions.

%num = #DATE2NS(dat, fmt, span, %rc)

Where:

datDatetime value string.
fmtDatetime format string for dat.
spanOptional CENTSPAN value.
%rcReturn code variable (optional, output).
%numSet to the number of seconds since 1 Jan 1900 12:00 AM that corresponds to the datetime value of dat.

For example, the following fragment prints the value 'BEFORE' on the FUNPRINT dataset:

IF #DATE2NS('121494', 'MMDDYY') < - #DATE2NS('040195', 'MMDDYY') THEN REPORT 'BEFORE' END IF

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %num to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.
8dat does not match fmt or result date out of range.
12span is an invalid CENTSPAN value.

Notes

  • Values returned by #DATE2NS will often exceed the range that can be represented in a 4-byte integer, so you should probably avoid storing the value in a BINARY or FLOAT4 field.
  • Dates prior to 1 January 1900 will return a negative number.
  • The inverse of this #function is #NS2DATE.
  • Datetime formats explains valid datetime formats and valid dates.
  • CENTSPAN explains CENTSPAN arguments.

#DEBLANK: Remove leading and trailing blanks from substring

The #DEBLANK function extracts a substring (starting at pos for length len) and returns it, with leading and trailing blanks removed. It requires a string to be deblanked. It accepts an optional starting position within the string to be deblanked, and an optional length.

%out = #DEBLANK(str, pos, len)

Where:

strString to be deblanked; required.
posOptional position within str to start deblanking. Must be numeric greater than or equal to 1, default is 1.
lenOptional length, starting at pos of string to deblank. Must be numeric greater than or equal to 0, default is the remainder of the input string.
%outSet to the substring within str, starting at pos for length len; leading and trailing blanks are then removed from this substring. Intermediate blanks within the substring are not affected.

Examples:

#DEBLANK(' ABC ') returns 'ABC' #DEBLANK(' ABC ', 1, 2) returns 'A' #DEBLANK(' A BC ', 2, 4) returns 'A B'

The Fast/Unload run is cancelled with a return code of 8 when:

  • pos is not numeric, or less than 1.
  • len is not numeric, or less than 0.

Notes

This #function is new in Fast/Unload version 4.0.

#DELWORD: Remove blank-delimited words from string

The #DELWORD function removes one or more blank-delimited words from a string. It requires an input string and a word number within the string. It accepts an optional number of words to delete.

%out = #DELWORD(str, word, count)

Where:

strString containing words to be deleted; required.
wordNumber of first word within str to remove; required. Must be numeric greater than or equal to 1.
countOptional count of words to remove. Must be numeric greater than or equal to 0, default is the remainder of words in the input string.
%outSet to str with the substring removed which starts with the first character of word number word and ends with the last blank character before word number word+count.

Examples:

#DELWORD('A B C', 1) returns '' #DELWORD('A B C', 2) returns 'A ' #DELWORD(' A B C ', 3) returns ' A B ' #DELWORD('A B C', 4) returns 'A B C' #DELWORD(' ', 1) returns ' ' #DELWORD('A B C', 1, 1) returns 'B C' #DELWORD('A B C', 1, 4) returns '' #DELWORD('A B C', 2, 2) returns 'A '

The Fast/Unload run is cancelled with a return code of 8 when:

  • word is not numeric, or less than 1.
  • count is not numeric, or less than 0.

This #function is new in Fast/Unload version 4.0.

#FIND: Word position of one word sequence within another

The #FIND function determines the word position, within a string of blank-delimited words, of one or more blank-delimited words. It requires an input string to search within and an input sequence of words to search for.

%pos = #FIND(haystack, words)

Where:

haystackString containing words to be searched within; required.
wordsString containing one or more blank-delimited words to find; required.
%posSet to the word position, within haystack, of the first word of a sequence of words that matches the sequence in words. If words is not found, %pos is set to 0.

Examples:

#FIND('A B C', 'B') returns 2 #FIND('A B C', 'D') returns 0 #FIND('A B C', 'A B') returns 1 #FIND(' ', ' ') returns 0 #FIND('A B', 'A B C') returns 0 #FIND('B B B A', 'B B A') returns 2 #FIND('A A B', ' A B ') returns 2 #FIND(' A A B ', 'A B') returns 2

This #function has no cancelling conditions.

Notes

  • Multiple blanks in both input arguments are ignored.
  • This #function is similar to the #ONEOF function (#ONEOF: See if string is in delimited list of strings). Note, however, that both #FIND and #ONEOF are inferior to the SELECT statement, when the only purpose is to test whether an entity has one of several values (see SELECT entity).

This #function is new in Fast/Unload version 4.0.

#FLOAT8: Get 8-byte float, padding 4-byte input with 0

The #FLOAT8 function accepts a numeric argument, and it returns the value of the argument as an 8-byte floating point value. If the argument is a 4-byte floating point value, then the conversion is done by appending binary zeroes; otherwise, it is done by the normal FUEL conversion to an 8-byte floating point value.

%out = #FLOAT8(in)

Where:

%outSet to 8-byte floating point value of input argument.
inNumeric input value.

Notes

  • See Fast/Unload floating point arithmetic and numeric conversion for a specification of conversions to floating point values.
  • Numeric operations in FUEL and in SOUL are based on decimal, not binary, interpretation of floating point values, so this #function is seldom used.

    However, #FLOAT8 may be useful in unusual situations, in particular to perform a file reorganization that expands a FLOAT LEN 4 field to a FLOAT LEN 8 field, using the "raw" floating point conversion (such as can be done in a structured file reorganization using the X'0080' mode bit in FLOD).

    For example, if field FLT is defined in the input as FLOAT LEN 4, and you want to convert it to a FLOAT LEN 8 or FLOAT LEN 16 in a UAI/LAI file reorganization in such a way that the new field's values consist of the old ones with binary zeros added, you can use the following:

    OPEN PRODFILE UAI FOR EACH RECORD FOR I FROM 1 TO FLT(#) CHANGE FLT(I) = #FLOAT8(FLT(I)) END FOR UNLOAD END FOR

    In this example, if the input value of FLT is 411028F6, which is the closest 4-byte floating point value to the decimal value 1.01, it is converted on output to 411028F600000000, which SOUL will display as 1.01000022888184 (demonstrating that #FLOAT8 is only to be used in special circumstances).

    A "normal" UAI/LAI conversion of 411028F6 to a FLOAT LEN 8 field would be to the hexadecimal value 411028F5C28F5C28, which SOUL will display as 1.01.

This #function is new in Fast/Unload version 4.3.

#INDEX: Position of second string within first

The #INDEX function locates the first occurrence, if any, of a search string (needle) within a searched string (haystack). It requires a string to be searched and accepts an optional string to locate. It accepts an optional starting position within the string to be searched. #INDEX returns either the starting position within the searched string of the first occurrence of the string to be located (starting at the specified position), or 0.

%opos = #INDEX(haystack, needle, pos)

Where:

haystackString to be searched; required.
needleString to be located, may be omitted.
posOptional starting position within haystack for search. Must be numeric greater than or equal to 1, default is 1.
%oposSet to starting position of first occurrence of needle within haystack, with search starting at pos, else 0 if not found or if either string length is zero.

Examples:

#INDEX('123xy', '23') returns 2 #INDEX('123xy', '45') returns 0 #INDEX('12312', '12', 2) returns 4 #INDEX('123xy', '23', 3) returns 0

The Fast/Unload run is cancelled with a return code of 8 when:

  • pos is not numeric, or less than 1.

Notes

  • If needle or haystack is the null string, 0 is returned.

#LEFT: Initial substring, followed by pad characters to specified length

The #LEFT function returns a padded initial substring from a source string. It expects a source string argument and a numeric length of the output string. It accepts an optional pad character. #LEFT returns the string that begins at the first position of the source string and is of the specified output length. If the output length is less than or equal to the length of the source string, the first length characters of the source are returned. Otherwise, the source string is padded to the output length by following it with sufficient copies of the pad character.

%out = #LEFT(str, len, pad)

Where:

strSource string.
lenLength of the output string. Must be numeric >= 0.
padOptional pad character. Default is blank. If supplied, must be a string of length 1.
%outIf len is greater then #LEN(str):
  • all of str, followed by len - #LEN(str) copies of the pad character

Otherwise:

  • substring from str starting at position 1 with length len

For example:

#LEFT('ABC', 1) returns 'A' #LEFT('ABC', 3) returns 'ABC' #LEFT('ABC', 4) returns 'ABC ' #LEFT(4.6, 4, 0) returns '4.60'

The Fast/Unload run is cancelled with a return code of 8 when:

  • Len not numeric, or less than 0.
  • Pad supplied, and length not 1.

Notes

This #function is new in Fast/Unload version 4.0.

#LEN: Length of string

The #LEN function returns the length of a string, in number of bytes. It expects a required string argument and returns a numeric result.

%len = #LEN(str)

Where:

strString whose length you want to know. For Fast/Unload version 4.3 and later. str may be longer than 255 bytes.
%lenSet to length of str.

For example, the following fragment prints the string Length: 13 on the FUNPRINT dataset:

%X = #LEN('Hello, world!') REPORT 'Length:' AND %X

This #function has no cancelling conditions.

#LOWCASE: Change uppercase letters of string to lowercase

The #LOWCASE function returns a copy of the input string, with all uppercase EBCDIC letters changed to the corresponding lowercase letters. It expects a source string argument.

%out = #LOWCASE(str)

Where:

strSource string, required.
%outCopy of str, with all uppercase EBCDIC letters changed to their lowercase EBCDIC equivalents.

For example:

#LOWCASE('?abc') returns '?abc' #LOWCASE('?ABC') returns '?abc' #LOWCASE('') returns ''

This #function has no cancelling conditions.

This #function is new in Fast/Unload version 4.0.

#ND2DATE: Convert number of days to datetime string

The #ND2DATE function converts a numeric datetime value expressed as the number of days since January 1, 1900 into a datetime string value according to a specified datetime format string. It requires a datetime numeric value and a datetime format string. An optional output return code argument allows the FUEL program to intercept error conditions.

%dat = #ND2DATE(datn, fmt, %rc)

Where:

datnNumeric datetime value expressed as the number of days since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.
fmtDatetime format string to use for creating %dat.
%rcReturn code (optional, output)
%datSet to datetime string value, in format specified by fmt, corresponding to datn.

For example, the following fragment prints the string 07/31/84 on the FUNPRINT dataset:

%X = #DATE2ND('8407301230', 'YYMMDDHHMI') %X = %X + 1 /* Add 1 day %X = #ND2DATE(%X, 'MM/DD/YY') REPORT %X

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %dat to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.
8datn is out of range for fmt.

Notes

  • The inverse of this #function is #DATE2ND.
  • Datetime formats explains valid datetime formats and valid dates.

#NM2DATE: Convert number of milliseconds to datetime string

The #NM2DATE function converts a numeric datetime value expressed as the number of milliseconds since January 1, 1900 into a datetime string value according to a specified datetime format string. It requires a datetime numeric value and a datetime format string. An optional output return code argument allows the FUEL program to intercept error conditions.

%dat = #NM2DATE(datn, fmt, %rc)

Where:

datn Numeric datetime value expressed as the number of milliseconds since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.
fmt Datetime format string to use for creating %dat.
%rc Return code (optional, output)
%dat Set to datetime string value, in format specified by fmt, corresponding to datn.

For example, the following fragment prints the string 07/31/84 on the FUNPRINT dataset:

%X = #DATE2NM('8407301230', 'YYMMDDHHMI') %X = %X + 1000 * 60 * 60 * 15 /* Add 15 hours %X = #NM2DATE(%X, 'MM/DD/YY') REPORT %X

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %dat to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.
8datn is out of range for fmt.

Notes

#NS2DATE: Convert number of seconds to datetime string

The #NS2DATE function converts a numeric datetime value expressed as the number of seconds since January 1, 1900 into a datetime string value according to a specified datetime format string. It requires a datetime numeric value and a datetime format string. An optional output return code argument allows the FUEL program to intercept error conditions.

%dat = #NS2DATE(datn, fmt, %rc)

Where:

datnNumeric datetime value expressed as the number of seconds since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.
fmtDatetime format string to use for creating %dat.
%rcReturn code (optional, output)
%datSet to datetime string value, in format specified by fmt, corresponding to datn.

For example, the following fragment prints the string 07/31/84 on the FUNPRINT dataset:

%X = #DATE2NS('8407301230', 'YYMMDDHHMI') %X = %X + 60 * 60 * 15 /* Add 15 hours %X = #NS2DATE(%X, 'MM/DD/YY') REPORT %X

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %dat to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.
8datn is out of range for fmt.

Notes

  • The inverse of this #function is #DATE2NS.
  • Datetime formats explains valid datetime formats and valid dates.

#NUM2STR: Convert number to string with decimal point

The #NUM2STR function converts a number to a string with an integer part, followed by an optional decimal point and decimal fraction digits, with control over the number of integer and fraction digits, padding, and rounding. It requires a numeric value. Optional arguments specify the width of the resulting integer digits area, the width of the resulting fraction digits area, rounding vs. truncation and fixed width vs. variable/minimal width integer area, and the leading pad character for the integer digits area.

The final optional argument is an output argument whose absolute value is set to the number of integer characters (after leading zeroes are stripped) in the number, plus 1 if the number is negative. Specifying this argument allows the Fast/Unload program to continue if the first argument cannot be represented by the result, either as a result of truncation of the high-order integer digits, or because the first argument can not be converted to a number.

%str = #NUM2STR(num, intw, fracw, opt, pad, %intlen)

Where:

numInput number to be converted.
intwNumber of characters used to express the integer portion and leading minus sign, if any, of num. Optional, must be 0 or more if specified. If omitted, only the characters needed are used to represent the integer part: a leading minus sign, if num is negative, is followed by the integer portion with leading zeroes stripped (except if the integer portion is zero, a single digit 0 is used).

If the fourth argument (opt) contains the letter 'V', intw is the minimal width used for the integer part, and the number of characters needed is used if that exceeds intw.

fracwNumber of digits used to express the fraction portion of num. Optional, must be 0 or more if specified. If this argument is omitted:
  • only the characters needed are used to represent the fraction part
  • if the fraction part is 0, no decimal point occurs in the result
  • if the fraction part is not 0, trailing zeroes are removed
%optOne or two characters, optional, with one choice from either of the following two pairs:
  • R (round) or T (trunc)
    RRound up the final digit of the result, if the most significant discarded fraction digit is 5 or more. This is the default.
    TFinal digit of result unaffected by any discarded fraction digits.

    This character has no meaning if argument three (fracw) is omitted, since in that case no fraction digits are discarded.

  • F (fixed width) or V (variable width)
    F The integer portion of the result is fixed width; that is, as many characters are used for the integer (and leading minus sign) as the value of argument two (intw). This is the default.
    V The integer portion of the result is variable/minimal width. That is, if w characters are needed for the integer (and leading minus sign) with leading zeroes removed, then w characters are used for the integer if w>intw; intw characters are used otherwise.

    This character has no meaning if argument two (intw) is omitted, since in that case exactly the characters needed for the integer are used.

padThe leading pad character used to fill the integer portion to the width specified by argument two (intw). Optional, must be one character, defaults to blank. If the pad character is blank, a leading minus sign follows any blank pad characters; otherwise a leading minus sign precedes any pad characters.
%intlenSet to the value len, where the absolute value of len is the number of characters needed for the integer part of the first argument (num), with any leading zeroes stripped (or one zero if the integer part is zero), including one additional character if num is negative.

If %intlen is returned with a negative value, that indicates truncation of the integer part of num; this occurs if all of the following conditions hold:

  • Argument two (intw) is specified.
  • The absolute value of len is greater than intw.
  • Intw>0, or num<0, or num>=1.
  • Argument four (opt) does not contain the letter 'V'.

If num cannot be converted to a number, then len is returned as zero, and the result (value of %str) of #NUM2STR is the MISSING value.

Otherwise, len is positive.

As these rules indicate, %intlen, if supplied, allows the Fast/Unload program to continue when the first argument is non-numeric or the integer part is truncated in the result. If either of these conditions occur and %intlen is omitted, the Fast/Unload program is cancelled.

Examples:

%N_HUMAN = 6 * 1000 * 1000 * 1000 #NUM2STR(%N_HUMAN) -> "6000000000"

%PI = 3.14159265 #NUM2STR(%PI) -> "3.14159265" #NUM2STR(%PI, , 3) -> "3.142" #NUM2STR(%PI, , 3, 'T') -> "3.141"

%PCT7_5 = 7.5/100 #NUM2STR(%PCT7_5) -> "0.075" #NUM2STR(%PCT7_5, , 4) -> "0.0750" #NUM2STR(%PCT7_5, 0, , , '*', %W) -> ".075" with ... %W = 1 #NUM2STR(%PCT7_5, 2, , , '*', %W) -> "*0.075" with ... %W = 1

%NEGP7_5 = - %PCT7_5 #NUM2STR(%NEGP7_5) -> "-0.075" #NUM2STR(%NEGP7_5, 1, , , '*') -> "-.075" #NUM2STR(%NEGP7_5, 2, , , '*') -> "-0.075" #NUM2STR(%NEGP7_5, 3, , , '*') -> "-*0.075" #NUM2STR(%NEGP7_5, 3, , , ' ') -> " -0.075"

%TBIL = 6.025 %VISA = 18.5 #NUM2STR(%TBIL, 1, 3, , '0') -> "6.025" #NUM2STR(%VISA, 1, 3, , '0', %W) -> "8.500" with ... %W = -2 #NUM2STR(%VISA, 1, 3, 'V', '0', %W) -> "18.500" with ... %W = 2

%BAD = 'PIZZA' #NUM2STR(%BAD, , , , , %W) -> MISSING value with ... %W = 0

Non-zero values of %intlen, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %intlen present, set to corresponding number; if absent, cancel Fast/Unload with return code 8.

-NN is the length required for the integer part of num, and n>intw and opt does not contain the letter "V".
0Num can not be converted to a numeric value (%str is set to MISSING).
**Negative or non-numeric value for intw or fracw (this error always cancels Fast/Unload, regardless of the presence of %intlen).
**Invalid character in opt (this error always cancels Fast/Unload, regardless of the presence of %intlen).
**Length of pad not 1 (this error always cancels Fast/Unload, regardless of the presence of %intlen).

Note: If you are creating a string to place in the Fast/Unload

output file, you can also use the PUT with the AS STRING or AS DECIMAL clauses (see PUT).

One difference between #NUM2STR and PUT AS STRING or PUT AS DECIMAL is that all conversion of fractional values to fixed width output formats in the PUT statement causes low order fraction digits to be dropped without rounding, but #NUM2STR offers rounding of dropped low order digits.

This #function is new in Fast/Unload version 4.0.

#N2DATE: Convert number of seconds*300 to datetime string

The #N2DATE function converts a numeric datetime value expressed as the number of seconds*300 since January 1, 1900 into a datetime string value according to a specified datetime format string. It requires a datetime numeric value and a datetime format string. An optional output return code argument allows the FUEL program to intercept error conditions.

%dat = #N2DATE(datn, fmt, %rc)

Where:

datnNumeric datetime value expressed as 300 times the number of seconds since 1 Jan 1900 12:00 AM. This argument may not have the MISSING value.
fmtDatetime format string to use for creating %dat.
%rcReturn code (optional, output)
%datSet to datetime string value, in format specified by fmt, corresponding to datn.

For example, the following fragment prints the string 07/31/84 on the FUNPRINT dataset:

%X = #DATE2N('8407301230', 'YYMMDDHHMI') %X = %X + 300 * 60 * 60 * 15 /* Add 15 hours %X = #N2DATE(%X, 'MM/DD/YY') REPORT %X

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors: if %rc present, set to corresponding number and set %dat to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.
8datn is out of range for fmt.

Notes

  • The inverse of this #function is #DATE2N.
  • Datetime formats explains valid datetime formats and valid dates.

#ONEOF: See if string is in delimited list of strings

The #ONEOF function determines whether a string is found in a delimited list of strings. It requires an input string to search for and a delimited list of strings to search within. It accepts an optional delimiter character, which is used to separate the strings in the list.

%test = #ONEOF(str, list, delim)

Where:

strString to find; required.
listString containing words to be searched within; required.
delimCharacter used to separate strings in list; optional. Default is semi-colon (;).
%testSet to 1 if str is one of the strings in list, delimited by delim. Otherwise, %test is set to 0.

Examples:

#ONEOF('HOW', 'HOW NOW', ' ') returns 1 #ONEOF('NOW', 'HOW;NOW') returns 1 #ONEOF('ABC', 'ABC') returns 1 #ONEOF('', 'HOW;;NOW') returns 1 #ONEOF('', ';HOW;NOW') returns 1 #ONEOF('', 'HOW;NOW;') returns 1 #ONEOF('', 'HOW;NOW') returns 0 #ONEOF('NO', 'HOW;NOW') returns 0 #ONEOF('HOW;NOW', 'HOW;NOW') returns 0 #ONEOF('', '') returns 0

The Fast/Unload run is cancelled with a return code of 8 when:

  • Delim supplied, and length not 1.

Notes

  • If argument 1 (str) contains delim, 0 is returned.
  • If argument 2 (list) is the null string, 0 is returned.
  • If argument 1 (str) is the null string, 1 is returned if, and only if, there is a leading, trailing, or two adjacent copies of, delim.
  • This #function is similar to the #FIND function (#FIND: Word position of one word sequence within another). Note, however, that both #FIND and #ONEOF are inferior to the SELECT statement, when the only purpose is to test whether an entity has one of several values (see SELECT entity).

This #function is new in Fast/Unload version 4.0.

#PAD: Final substring, preceded by pad characters to specified length

The #PAD function returns a padded final substring from a source string. It expects a source string argument and a numeric length of the output string. It accepts an optional pad character. #PAD returns the string that ends at the last position of the source string and is of the specified output length. If the output length is less than or equal to the length of the source string, the last length characters of the source are returned. Otherwise, the source string is padded to the output length by preceding it with sufficient copies of the pad character.

%out = #PAD(str, pad, len)

Where:

strSource string.
padOptional pad character. Default is blank. If supplied, must be a string of length 1.
lenLength of the output string. Must be numeric >= 0.
%outIf len is greater then #LEN(str):
  • len - #LEN(str) copies of the pad character, followed by all of str

Otherwise:

  • substring from str starting at position #LEN(str) - len+1 with length len

For example:

#PAD('ABC', , 0) returns '' #PAD('ABC', , 1) returns 'C' #PAD('ABC', , 3) returns 'ABC' #PAD('ABC', , 4) returns ' ABC' #PAD(456, 0, 4) returns '0456'

The Fast/Unload run is cancelled with a return code of 8 when:

  • Len not numeric, or less than 0.
  • Pad supplied, and length not 1.

Notes

This #function is new in Fast/Unload version 4.0.

#PADR: Initial substring, followed by pad characters to specified length

The #PADR function returns a padded initial substring from a source string. It expects a source string argument and a numeric length of the output string. It accepts an optional pad character. #PADR returns the string that begins at the first position of the source string and is of the specified output length. If the output length is less than or equal to the length of the source string, the first length characters of the source are returned. Otherwise, the source string is padded to the output length by following it with sufficient copies of the pad character.

%out = #PADR(str, pad, len)

Where:

strSource string.
padOptional pad character. Default is blank. If supplied, must be a string of length 1.
lenLength of the output string. Must be numeric >= 0.
%outIf len is greater then #LEN(str):
  • all of str, followed by len - #LEN(str) copies of the pad character

Otherwise:

  • substring from str starting at position 1 with length len

For example:

#PADR('ABC', , 1) returns 'A' #PADR('ABC', , 3) returns 'ABC' #PADR('ABC', , 4) returns 'ABC ' #PADR(4.6, 0, 4) returns '4.60'

The Fast/Unload run is cancelled with a return code of 8 when:

  • Len not numeric, or less than 0.
  • Pad supplied, and length not 1.

Notes

This #function is new in Fast/Unload version 4.0.

#REVERSE: Get reverse of string

The #REVERSE function returns a copy of the input string, with the order of the bytes reversed. It expects a source string argument.

%out = #REVERSE(str)

Where:

strSource string; required.
%outCopy of str, with all the last input byte first, followed by the next to last input byte, etc.

For example:

#REVERSE('abc') returns 'cba'

This #function has no cancelling conditions.

This #function is new in Fast/Unload version 4.0.

#RIGHT: Final substring, preceded by pad characters to specified length

The #RIGHT function returns a padded final substring from a source string. It expects a source string argument and a numeric length of the output string. It accepts an optional pad character. #RIGHT returns the string that ends at the last position of the source string and is of the specified output length. If the output length is less than or equal to the length of the source string, the last length characters of the source are returned. Otherwise, the source string is padded to the output length by preceding it with sufficient copies of the pad character.

%out = #RIGHT(str, len, pad)

Where:

strSource string.
lenLength of the output string.
padOptional pad character. Default is blank. If supplied, must be a string of length 1. Must be numeric >= 0.
%outIf len is greater then #LEN(str):
  • len - #LEN(str) copies of the pad character, followed by all of str

Otherwise:

  • substring from str starting at position #LEN(str) - len+1 with length len

For example:

#RIGHT('ABC', 0) returns '' #RIGHT('ABC', 1) returns 'C' #RIGHT('ABC', 3) returns 'ABC' #RIGHT('ABC', 4) returns ' ABC' #RIGHT(456, 4, 0) returns '0456'

The Fast/Unload run is cancelled with a return code of 8 when:

  • Len not numeric, or less than 0.
  • Pad supplied, and length not 1.

Notes

This #function is new in Fast/Unload version 4.0.

#SNDX: Create SOUNDEX code for string

The #SNDX function calculates a SOUNDEX code for a string, producing the same result as the Model 204 $SNDX function. It expects a single argument and returns the SOUNDEX code for the string value of the argument.

%out = #SNDX(str)

Where:

strString, presumed to contain a name.
%outSet to the SOUNDEX code corresponding to str.

For example, the following fragment will build values for an INVISIBLE KEY field which is the $SNDX value of the field NAME:

UAI OINDEX FOR EACH RECORD FOR I FROM 1 TO NAME(#) ADD NAME_SNDX = #SNDX(NAME(I)) END FOR UNLOAD END FOR

This #function has no cancelling conditions.

#STRIP: Remove leading and/or trailing copies of pad character

The #STRIP function removes leading, trailing, or both, copies of a pad character from a string. It requires a string to be stripped. It accepts an optional specification of which characters to strip (Leading, Trailing, or Both). It accepts an optional pad character argument, specifying the character to be stripped.

%out = #STRIP(str, B|L|T, pad)

Where:

strString to be stripped; required.
B|L|TOptional indicator of the type of strip:
  • 'B...' (any string beginning with uppercase B): to strip Both leading and trailing pad characters.
  • 'L...' (any string beginning with uppercase L): to strip Leading pad characters only.
  • 'T...' (any string beginning with uppercase T): to strip Trailing pad characters only.

Defaults to B.

%outSet to a copy of str, with leading, trailing, or both, as specified, copies of pad removed.

Examples:

#STRIP(' ABC ') returns 'ABC' #STRIP(' ABC ', 'L') returns 'ABC ' #STRIP(' ABC ', 'T') returns ' ABC' #STRIP('000123', 'L', '0') returns '123'

The Fast/Unload run is cancelled with a return code of 8 when:

  • B|L|T does not begin with either uppercase B, uppercase L, or uppercase T.
  • Pad specified and length is not 1.

Notes

This #function is new in Fast/Unload version 4.0.

#SUBSTR: Substring

The #SUBSTR function returns a substring from within a source string. It expects a source string argument and a numeric byte position within the source string. It accepts an optional numeric maximum length of the output substring. #SUBSTR returns the string that begins at the indicated position of the source string and ends either at the end of the source string or when the supplied maximum length has been reached.

%out = #SUBSTR(str, pos, len)

Where:

strSource string. For Fast/Unload version 4.3 and later. str may be longer than 255 bytes.
posBeginning position within the source string for the desired substring. Must be numeric >= 1.
lenOptional maximum length of substring; default is 255. Must be numeric >= 0.
%outSubstring from str starting at position pos with length that is the minimum of len and #LEN(str) +1 - pos.

For example, you might want to get the "right hand half" of a string (it will be to the right of the middle character if the string length is odd):

%LEN = #LEN(%STR) %RIGHT = %LEN / 2 + 1 /* See note below %RIGHT = #SUBSTR(%STR, %RIGHT)

The Fast/Unload run is cancelled with a return code of 8 when:

  • Pos not numeric, or less than 1.
  • Len not numeric, or less than 0.

Notes

#TIME: Current time and/or date

The #TIME function returns the current date and time in a datetime string. It accepts an optional datetime format string, with a default that returns just time information. An optional output return code argument allows the FUEL program to intercept error conditions.

%tim = #TIME(fmt, %rc)

Where:

fmtOptional datetime format string for %tim. Defaults to HH:MI:SS.
%rcReturn code (optional, output).
%timSet to datetime string with current date and time, using fmt.

For example, the following fragment stores the current time in the last occurrence of the REORG_TIME field:

ADD REORG_TIME = #TIME()

Non-zero values of %rc, or terminating conditions, are shown in the following figure (see the discussion in Run-time errors during standard #function calls).

Errors:

if %rc present, set to corresponding number and set %tim to MISSING; if absent, cancel Fast/Unload with return code 8.

4fmt is not a valid datetime format.

Notes

  • The only difference between #TIME and #DATE is the default value for fmt.
  • Datetime formats explains valid datetime formats.

#TRANSLATE: Change characters of string using from/to pairings

The #TRANSLATE function returns a copy of the input string, with all characters which are contained in the input table translated to the corresponding characters in the output table. It expects a source string argument, and at least one of 3 optional string arguments. It accepts optional output table, input table, and pad character (used to extend the output table if it is shorter than the input table).

%out = #TRANSLATE(str, tbl_out, tbl_in, pad)

Where:

strSource string; required.
tbl_outString of "to" characters (optional). Default is null string. Trailing pad characters are added to this string, if needed, so that its length is equal to the length of tbl_in.
tbl_inString of "from" characters, optional. Defaults to 256 characters consisting of all byte values, in order, that is, X'00010203...FCFDFEFF'.
padPad character for tbl_out (optional, must be length 1). Default blank.
%outCopy of str, with all characters which are contained in the input table translated to the corresponding characters in the output table.

For example:

#TRANSLATE('ab', 'x', 'b') returns .ax. #TRANSLATE('ab', , '', 'z') returns .ab. #TRANSLATE('ab', , , 'z') returns .zz. #TRANSLATE('ab', 'AB', , 'z') returns .zz. #TRANSLATE('ab', '', , 'z') returns .zz.

The Fast/Unload run is cancelled with a return code of 8 when:

  • Only str argument supplied.
  • Pad supplied, and length not 1.

Notes

  • As a consequence of the default rules, if neither tbl_out nor tbl_in are supplied, %out is set to as many copies of pad as #LEN(str).
  • If a character occurs more than once in tbl_in, all instances of it after the first are ignored.
  • As noted, the default tbl_in is a 256 byte string; it is not possible to specify such a value in Fast/Unload. If you want to specify a translation for all 256 characters, you can do the following:

    %TBL_OUT = ... /* A 255 byte value %TBL_FF = ... /* Value that X'FF' translates to %OUT = #TRANSLATE(%STR, %TBL_OUT, , %TBL_FF)

This #function is new in Fast/Unload version 4.0.

#UPCASE: Change lowercase letters of string to uppercase

The #UPCASE function returns a copy of the input string, with all lowercase EBCDIC letters changed to the corresponding uppercase letters. It expects a source string argument.

%out = #UPCASE(str)

Where:

strSource string; required.
%outCopy of str, with all lowercase EBCDIC letters changed to their uppercase EBCDIC equivalents.

For example:

#UPCASE('?abc') returns '?ABC' #UPCASE('?ABC') returns '?ABC' #UPCASE('') returns ''

This #function has no cancelling conditions.

This #function is new in Fast/Unload version 4.0.

#VERPOS: Position in string of character not in or in list

The #VERPOS function scans a search string from an optional starting position and then finds either the first character that is Not in a list of target characters, or the first character that Matches a character in a list of target characters. It expects a string argument that is searched and a string comprising the target characters. It accepts an optional argument indicating the type of search to perform and an optional position at which to start the search. #VERPOS returns the starting position of the identified character, or 0 as follows:

  • For the Not matched (default) search, returns the position in the search string of the first character not in the target string, or 0 if all characters in the search string are in the target string.
  • For the Matched search, returns the position in the search string of the first character which is in the target string, or 0 if no characters in the search string are in the target string.

%opos = #VERPOS(search, target, NorM, pos)

Where:

searchString to be searched.
targetString containing set of target characters.
NorMOptional indicator of the type of search being formed:
  • 'N...' (any string beginning with uppercase N): to find position of first character of search not present in target.
  • 'M...' (any string beginning with uppercase M): to find position of first character of search present in target.

Defaults to N.

posOptional position within search to begin scanning. Must be a positive numeric value, default is 1.
%oposSet to position of first character in search that is not in ('N') or is in ('M') target, at or after the position identified by pos.

Examples:

#VERPOS('SIRIUS', 'ETANOISHRDLU') returns 0 #VERPOS('HOMER', 'MRH') returns 2 #VERPOS('HOMER', 'MRH', 'M') returns 1 #VERPOS('PLATO', 'AEIOU', , 3) returns 4 #VERPOS('FRED', '', 'N', 2) returns 2 #VERPOS('BETTY', '', , 'M', 3) returns 0 #VERPOS('WILMA', 'AEIOU', 'M', 3) returns 5

The Fast/Unload run is cancelled with a return code of 8 when:

  • NorM does not begin with either uppercase N or uppercase M.
  • Pos not numeric, or less than 1.

Notes

  • If search is null, #VERPOS returns 0, as long as the other arguments are not in error. If pos is greater than #LEN(search), #VERPOS returns 0.
  • If search is non-null and target is null, #VERPOS returns 0 if NorM starts with 'M', otherwise #VERPOS returns :DT.pos.
  • The function which performs this service is usually called "verify", but #VERPOS is used to distinguish it from the SOUL $Verify function:
    • $VERIFY has only a "Boolean" (0 or 1) return; #VERPOS returns a position or 0 to indicate search "failed".
    • $VERIFY only has a "nomatch" type of search.
    • $VERIFY does not have a pos argument.
    • $VERIFY returns 0 if there is a character in search which is not in target; #VERPOS (Nomatch) returns 0 if there is no such character.
    • $VERIFY returns "some character in search is not in target" (0) if search is null and target is not null; #VERPOS returns "all characters in search are in target" if search is null, whether or not target is null.

#WORD: Return nth blank-delimited word from string

The #WORD function returns the designated blank-delimited word within a string. It requires an input string and a word number within the string.

%out = #WORD(str, word)

Where:

strString containing blank-delimited words; required.
wordNumber of word within str to return; required. Must be numeric greater than or equal to 1.
%outSet to the wordth blank-delimited word within str. If word is greater than the number of words in str, the null string is returned.

Examples:

#WORD('A B C', 1) returns 'A' #WORD('A B C', 2) returns 'B' #WORD('A B C', 3) returns 'C' #WORD('A B C', 4) returns '' #WORD(' ', 1) returns ''

The Fast/Unload run is cancelled with a return code of 8 when:

  • word is not numeric, or less than 1.

Notes

  • The User Language $WORD function also has an optional delimiter character argument, and its "word" argument is argument number 3.

This #function is new in Fast/Unload version 4.0.

#WORDS: Count number of blank-delimited word in string

The #WORDS function returns the number of blank-delimited word in a string. It requires an input string.

%count = #WORDS(str)

Where:

strString containing blank-delimited words; required.
%countSet to number of word within str.

Examples:

#WORDS('A B C') returns 3 #WORDS('ABC') returns 1 #WORDS(' ') returns 0

This #function has no cancelling conditions.

Notes

  • The User Language $WORDS function also has an optional delimiter character argument.

This #function is new in Fast/Unload version 4.0.

#X2C: Convert hex representation to character string

The #X2C function converts a string of hexadecimal characters (the digits 0-9 and the letters A-F) to the corresponding byte string. Each two characters in the input string become one character in the result string, with a leading 0 added to input strings of odd length.

%str = #X2C(hex)

Where:

hexString to convert; contains only the characters 0-9 and A-F.
%strSet to the string of bytes represented by hex.

For example, in

%JUNK = #X2C('F1F2F3')

%JUNK would be set to the string 123 (EBCDIC X'F1F2F3'), and in

%JUNK = #X2C('102')

%JUNK would be set to EBCDIC X'0102' which is a non-displayable string.

The Fast/Unload run is cancelled with a return code of 8 when:

  • Non-hexadecimal digit character in hex.

Notes

See also

Fast/Unload topics