FUDLibrary


Absolute value, min, max
Trig and Numeric functions
Version functions
Trim and Pad functions
Other string functions
Date functions


Absolute value, min, max


absdbl(a), absflt(a), absint(a), abssml(a)

Declaration

function absdbl double precision returns double precision by value
function absflt float returns float by value
function absint integer returns integer by value
function abssml smallint returns smallint by value

Description

Returns the absolute value.

 

mindbl(a,b), minflt(a,b), minint(a,b), minsml(a,b)

Declaration

function mindbl double precision, double precision returns double precision by value
function minflt float, float returns float by value
function minint integer, integer returns integer by value
function minsml smallint, smallint returns smallint by value

Description

Returns the minimum value.

 

maxdbl(a,b), maxflt(a,b), maxint(a,b), maxsml(a,b)

Declaration

function maxdbl double precision, double precision returns double precision by value
function maxflt float, float returns float by value
function maxint integer, integer returns integer by value
function maxsml smallint, smallint returns smallint by value

Description

Returns the maximum value.

 

Trig and Numeric functions


fud_cos(a)

Declaration

function fud_cos double precision returns double precision by value

Description

Returns the cosine of a. a is in radians.

UDFLib compatibility

This function is the same as the UDFLib cos function.

 

fud_acos(a)

Declaration

function fud_acos double precision returns double precision by value

Description

Returns the arccosine of a in radians. a must be in the range -1 <= a <= 1.

Error condition

If a is not in the correct range then -999999 is returned.

UDFLib compatibility

This function is the same as the UDFLib acos function.

 

fud_sin(a)

Declaration

function fud_sin double precision returns double precision by value

Description

Returns the sine of a. a is in radians.

UDFLib compatibility

This function is the same as the UDFLib sin function.

 

fud_asin(a)

Declaration

declare external function fud_asin double precision returns double precision by value

Description

Returns the arcsine of a in radians. a must be in the range -1 <= a <= 1.

Error condition

If a is not in the correct range then -999999 is returned.

UDFLib compatibility

This function is the same as the UDFLib asin function.

 

fud_tan(a)

Declaration

function fud_tan double precision returns double precision by value

Description

Returns the tangent of a. a is in radians.

UDFLib compatibility

This function is the same as the UDFLib tan function.

 

fud_atan(a)

Declaration

function fud_atan double precision returns double precision by value

Description

Returns the arctangent of a in radians.

UDFLib compatibility

This function is the same as the UDFLib atan function.

 

fud_atan2(a, b)

Declaration

function fud_atan2 double precision, double precision returns double precision by value

Description

Returns the arctangent of a / b in radians. b must satisfy b <> 0.

Error condition

If b is zero then -999999 is returned.

UDFLib compatibility

This function is the same as the UDFLib atan2 function.

 

fud_ceiling(a)

Declaration

function ceiling double precision returns double precision by value

Description

Returns the smallest integer bigger than or equal to a.

UDFLib compatibility

This function is the same as the UDFLib ceiling function.

 

fud_floor(a)

Declaration

function fud_floor double precision returns double precision by value

Description

Returns the largest integer smaller than or equal to a.

UDFLib compatibility

This function is the same as the UDFLib floor function.

 

degrees(a)

Declaration

function degrees double precision returns double precision by value

Description

Converts a from radians into degrees.

 

radians(a)

Declaration

function radians double precision returns double precision by value

Description

Converts a from degrees into radians.

 

fud_PI

Declaration

function fud_PI returns double precision by value

Description

Returns PI.

UDFLib compatibility

This function is the same as the UDFLib PI function.

 

fact(a)

Declaration

function fact double precision returns double precision by value

Description

Converts a to an integer by truncation and then returns the factorial of a. a must be in the range 0<= a < 101.

Error condition

If a is not in range then -999999 is returned.

 

exp(a)

Declaration

function exp double precision returns double precision by value

Description

Returns e to the power of a. a must be in the range -700 <= a < 700.

Error condition

If a is not in range then -999999 is returned.

 

fud_log(a)

Declaration

function fud_log double precision returns double precision by value

Description

Returns the natural logarithm of a. a must be bigger than or equal to 1.0e-304.

Error condition

If a is not in range then -999999 is returned.

UDFLib compatibility

This function is the same as the UDFLib log function.

 

pow10(a)

Declaration

function pow10 double precision returns double precision by value

Description

Returns 10 to the power of a. a must be in the range -305 <= a < 305.

Error condition

If a is not in range then -999999 is returned.

 

fud_log10(a)

Declaration

declare external function fud_log10 double precision returns double precision by value

Description

Returns the logarithm to base 10 of a. a must be bigger than or equal to 1.0e-304.

Error condition

If a is not in range then -999999 is returned.

UDFLib compatibility

This function is the same as the UDFLib log10 function.

 

pow(a, b)

Declaration

function pow double precision, double precision returns double precision by value

Description

Returns a to the power of b. a must be greater than or equal to 0.

Error condition

If a is not in range then -999999 is returned.

 

round(a, b)

Declaration

function round double precision, integer returns double precision by value

Description

Rounds a to b decimal places. If b is negative then a is rounded to a value of the order 10^-b. For example round(723.123, -2) is 700. b must be in the range -304 < b < 304.

Error condition

If b is not in range then -999999 is returned.

 

truncate(a, b)

Declaration

function truncate double precision, integer returns double precision by value

Description

Truncates a to b decimal places. a is always truncated downwards even if a is negative. If b is negative then a is truncated to a value of the order 10^-b. For example truncate(-723.123, -2) is -800. b must be in the range -304 < b < 304.

Error condition

If b is not in range then -999999 is returned.

 

sqrt(a)

Declaration

function fud_sqrt double precision returns double precision by value

Description

Returns the square root of a. a must be equal to or greater than zero.

Error condition

If a is not in range then -999999 is returned.

UDFLib compatibility

This function is the same as the UDFLib sqrt function.

 

modquot(a, b)

Declaration

declare external function modquot integer, integer returns integer by value

Description

Returns the quotient when a is divided by b. b must not be equal to zero.

Error condition

If b is not in range then -999999 is returned.

 

modrem(a, b)

Declaration

function modrem integer, integer returns integer by value

Description

Returns the remainder when a is divided by b. b must not be equal to zero.

Error condition

If b is not in range then -999999 is returned.

 

Version functions

ver

Declaration

function ver returns double precision by value

Description

Returns the version number of UDFLib that FUDLibrary emulates. As I have no idea what this number should be the function returns 1.

 

fud_ver

Declaration

function fud_ver returns integer by value

Description

Returns the version number FUDLibrary multiplied by 100. For example if you have version 0.5 of FUDLibrary then this function returns 50.

 

Trim and Pad functions

 

alltrim(a), valltrim(a)

Declaration

function alltrim cstring(256) returns cstring(256) free_it
function valltrim cstring(256) returns cstring(256) free_it

Description

Trims any space characters (ascii value 32) from the start and the end of the string. Note other types of white space such as tabs are not stripped.

UDFLib compatibility

valltrim is identical to alltrim and is provided for UDFLib compatibility

 

alltrimc(a, b), valltrimc(a, b)

Declaration

function alltrimc cstring(256), char(1) returns cstring(256) free_it
function valltrimc cstring(256), cstring(1) returns cstring(256) free_it

Description

Trims any character b from the start and the end of the string.

UDFLib compatibility

valltrimc is identical to alltrimc and provided for UDFLib compatibility.

 

vltrim(a)

Declaration

function vltrim cstring(256) returns cstring(256) free_it

Description

Trims any space characters (ascii value 32) from the start of the string. Note other types of white space such as tabs are not stripped.

UDFLib compatibility

This function is the same as the UDFLib ltrim function.

 

ltrimc(a, b), vltrimc(a, b)

Declaration

function ltrimc cstring(256), char(1) returns cstring(256) free_it
function vltrimc cstring(256), cstring(1) returns cstring(256) free_it

Description

Trims any character b from the start of the string.

UDFLib compatibility

vltrimc is identical to ltrimc and is provided for UDFLib compatibility.

 

vrtrim(a)

Declaration

function vrtrim cstring(256) returns cstring(256) free_it

Description

Trims any space characters (ascii value 32) from the end of the string. Note other types of white space such as tabs are not stripped.

UDFLib compatibility

This function is the same as the UDFLib rtrim function.

 

rtrimc(a, b), vrtrimc(a, b)

Declaration

function rtrimc cstring(256), char(1) returns cstring(256) free_it
function vrtrimc cstring(256), cstring(1) returns cstring(256) free_it

Description

Trims any character b from the end of the string.

UDFLib compatibility

vrtrimc is identical to rtrimc and is provided for UDFLib compatibility

 

pad(str, c, n), vpad(str, c, n)

Declaration

function pad cstring(256), cstring(1), integer returns cstring(256) free_it
function vpad cstring(256), cstring(1), integer returns cstring(256) free_it

Description

Pads the end of the str with character c until it is n characters long.

Error condition

If c is empty, or n is less than the length of the string or n > 255 then the function returns "Bad parameters in rpad".

UDFLib compatibility

vpad is identical to pad and is provided for UDFLib compatibility

 

lpad(str, c, n), vlpad(str, c, n)

Declaration

function lpad cstring(256), cstring(1), integer returns cstring(256) free_it
function vlpad cstring(256), cstring(1), integer returns cstring(256) free_it

Description

Pads the start of the str with character c until it is n characters long.

Error condition

If c is empty, or n is less than the length of the string or n > 255 then the function returns "Bad parameters in lpad".

UDFLib compatibility

vlpad is identical to lpad and is provided for UDFLib compatibility.

 

centre(str, c, n), vcentre(str, c, n), center(str, c, n), vcenter(str, c, n)

Declaration

function centre cstring(256), cstring(1), integer returns cstring(256) free_it
function vcentre cstring(256), cstring(1), integer returns cstring(256) free_it
function center cstring(256), cstring(1), integer returns cstring(256) free_it
function vcenter cstring(256), cstring(1), integer returns cstring(256) free_it

Description

Pads the start and end of the str with character c until it is n characters long.

Error condition

If c is empty, or n is less than the length of the string or n > 255 then the function returns "Bad parameters in center".

UDFLib compatibility

vcentre, center, vcenter are identical to center and are provided for UDFLib compatibility.

 

Other string functions

 

soundex(str)

Declaration

function fud_soundex cstring(256) returns cstring(256) free_it

Description

Converts a string into its Soundex Code. This function uses the Soundex Algorothm described by Donald Knuth in The Art of Computer Programming Volume 3. The file examples/soundex.sql gives an example of how to use the fud_soundex function to do 'sounds like' searching.

 

len(str), vlen(str)

Declaration

function len cstring(256) returns integer by value

Description

Returns the length of str.

UDFLib compatibility

vlen is identical to len and is provided for UDFLib compatibility.

 

fud_lower(str), vlower(str)

Declaration

function fud_lower cstring(256) returns cstring(256)
function vlower cstring(256) returns cstring(256)

Description

Converts the string to lower case.

UDFLib compatibility

vlower is identical to fud_lower and is provided for UDFLib compatibility

 

cstradd(str1, str2), vcharadd(str1, str2)

Declaration

function cstradd cstring(256),cstring(256) returns cstring(512) free_it
function vcharadd cstring(256),cstring(256) returns cstring(512) free_it

Description

Concatenates str1 and str2.

UDFLib compatibility

vcharadd is identical to cstradd and is provided for UDFLib compatibility

 

cstrdel(str, pos, substr_len), vchardel(str, pos, substr_len)

Declaration

function cstrdel cstring(256), integer, integer returns cstring(256) free_it
function vchardel cstring(256), integer, integer returns cstring(256) free_it

Description

Deletes the substring of length substr_len characters which starts at character pos from string str. pos is zero based.

Error condition

If pos < 0 or substr_len < 0 or the substring extends beyond the end of the string then "Bad paramaters in chrdelete" is returned instead.

UDFLib compatibility

vchardel is identical to cstrdel and is provided for UDFLib compatibility.

 

cstr_plus_int(str, num)

Declaration

function cstr_plus_int cstring(256), integer returns cstring(256) free_it

Description

Appends num on to the end of str. The resulting string must be less than 255 characters long.

Error condition

If the resulting string would exceed 255 characters then "Bad parameters in cstr_plus_int" is returned instead.

 

int_plus_cstr(str, num)

Declaration

function int_plus_cstr cstring(256), integer returns cstring(256) free_it

Description

Adds num on to the start of str. The resulting string must be less than 255 characters long.

Error condition

If the resulting string would exceed 255 characters then "Bad parameters in cstr_int_plus_cstr" is returned instead.

 

cstr_to_double(str)

Declaration

function cstr_to_dbl cstring(256) returns double precision by value

Description

Converts the string to a double.

 

ascii(c)

Declaration

function ascii cstring(1) returns integer by value

Description

Returns the ascii value of c.

 

chr(n)

Declaration

function chr integer returns cstring(1) free_it

Description

Returns the character whose ascii value is n. n must be between 0 and 255.

Error condition

If n is out of range then "Value out of range" is returned instead.

 

parse(str, token, pos), vparse(str, token, pos)

Declaration

function parse cstring(256), cstring(1), integer returns cstring(256) free_it
function vparse cstring(256), cstring(1), integer returns cstring(256) free_it

Description

This function views str as a series of substrings separated by the token character. It then returns the substring specified by pos. If pos is 1 then it returns the first substring etc.

Error condition

If token is empty or pos < 1 then "Bad Paramaters in Parse" is returned. If pos is too large then it returns "Token to long in parse".

UDFLib compatibility

vparse is identical to parse and is provided for UDFLib compatibility.

 

pos(str, substr, start, occurrence), vpos(str, substr, start, occurrence)

Declaration

function pos cstring(256), cstring(256), integer, integer returns integer by value
function vpos cstring(256), cstring(256), integer, integer returns integer by value

Description

Searches str for a substring substr. start is the zero based index to start the search. occurrence specifies which substring to find. If occurrence is 1 then the first substring is required. The function returns the zero based index of the substring.

Error condition

If the substring is not found then -1 is returned. If there is an error in the parameters then -999999 is returned.

UDFLib compatibility

vpos is identical to pos and is provided for UDFLib compatibility.

 

proper(str), vproper(str)

Declaration

function pos cstring(256), cstring(256), integer, integer returns integer by value
function vpos cstring(256), cstring(256), integer, integer returns integer by value

Description

Converts the first letter of every word to upper case. For example proper("david bowyer") would return "David Bowyer".

UDFLib compatibility

vproper is identical to proper and is provided for UDFLib compatibility.

 

reverse(str), vreverse(str)

Declaration

function reverse cstring(256) returns cstring(256) free_it
function vreverse cstring(256) returns cstring(256) free_it

Description

Returns the inversion of str.

UDFLib compatibility

vreverse is identical to reverse and is provided for UDFLib compatibility.

 

lefts(str, num), vlefts(str, num)

Declaration

function lefts cstring(256), integer returns cstring(256) free_it
function vlefts cstring(256), integer returns cstring(256) free_it

Description

Returns the first num characters in str.

UDFLib compatibility

vlefts is identical to lefts and is provided for UDFLib compatibility.

 

rights(str, num), vrights(str, num)

Declaration

function rights cstring(256), integer returns cstring(256) free_it
function vrights cstring(256), integer returns cstring(256) free_it

Description

Returns the last num characters in str.

UDFLib compatibility

vrights is identical to rights and is provided for UDFLib compatibility.

 

substring(str, start, end), vsubstring(str, start, end)

Declaration

function substring cstring(256), integer, integer returns cstring(256) free_it
function vsubstring cstring(256), integer, integer returns cstring(256) free_it

Description

Returns the substring of str which starts at index start and finishes at index end. Both start and end are one based.

UDFLib compatibility

vsubstring is identical to substring and is provided for UDFLib compatibility.

 

replicate(c, n), vreplicate(c, n)

Declaration

function replicate cstring(1), integer returns cstring(256) free_it
function vreplicate cstring(1), integer returns cstring(256) free_it

Description

Returns a string of length n consisting of the character c. n must be in the range 0 <= n <= 255. c must not be empty.

Error condition

If c is empty or n is out of range then "Bad parameters" is returned.

UDFLib compatibility

vreplicate is identical to replicate and is provided for UDFLib compatibility.

 

Date functions

 

mer_year(ts)

Declaration

function mer_year timestamp returns integer by value

Description

Returns the year portion of the timestamp.

 

mer_month(ts)

Declaration

function mer_month timestamp returns integer by value

Description

Returns the month portion of the timestamp as a number. 1 is January, 2 is February etc.

 

month_of_year(ts)

Declaration

function month_of_year timestamp returns cstring(255) free_it

Description

Returns the month portion of the timestamp as a string.

 

mer_day(ts)

Declaration

function mer_day timestamp returns integer by value

Description

Returns the day in the month portion of the time stamp as an integer.

 

day_of_week(ts)

Declaration

function day_of_week timestamp returns cstring(255) free_it

Description

Returns the weekday name. e.g. Monday.

 

dow(ts)

Declaration

function dow timestamp returns integer by value

Description

Days since Sunday. (1 for Sunday, 2 for Monday, ...)

 

julian(ts)

Declaration

function julian timestamp returns integer by value

Description

Days since 1st January. (1 for 1st Jan, 2 for 2nd Jan, ...)

 

mer_hour(ts)

Declaration

function mer_hour timestamp returns integer by value

Description

Hour portion of the timestamp.

 

mer_minute(ts)

Declaration

function mer_minute timestamp returns integer by value

Description

Minute portion of the timestamp.

 

sec(ts)

Declaration

function sec timestamp returns integer by value

Description

Second portion of the timestamp.

 

msec(ts)

Declaration

function msec timestamp returns integer by value

Description

Millisecond portion of the timestamp. The implementation of this function relies on 'undocumented' information about the format of timestamps in Interbase.

 

maxtime(ts)

Declaration

function maxtime timestamp returns timestamp free_it

Description

Sets the time portion of the timestamp to 23:59:59.9999. The day portion is left intact. The implementation of this function relies on 'undocumented' information about the format of timestamps in Interbase.

 

zerotime(ts)

Declaration

function zerotime timestamp returns timestamp free_it

Description

Sets the time portion of the timestamp to 00:00:00.0000. The day portion is left intact. The implementation of this function relies on 'undocumented' information about the format of timestamps in Interbase.

 

firstday(ts)

Declaration

function firstday timestamp returns timestamp free_it

Description

Sets the day portion of the timestamp to the first day of the month. Sets the time portion of the timestamp to 00:00:00.0000. The implementation of this function relies on 'undocumented' information about the format of timestamps in Interbase.

 

lastday(ts)

Declaration

function lastday timestamp returns timestamp free_it

Description

Sets the day portion of the timestamp to the last day of the month. Sets the time portion of the timestamp to 23:59:59.9999. The implementation of this function relies on 'undocumented' information about the format of timestamps in Interbase.

 

week(ts)

Declaration

function week timestamp returns int by value

Description

Returns the week in the year as a number. (1 , 52)

 

quarter(ts, fiscalyear)

Declaration

function quarter timestamp, integer returns cstring(255) free_it

Description

Returns the financial quarter the timestamp lies in. The format is YYQN where YY is the two digit year and N is from 1 to 4. fiscalyear gives the start of the financial year. (1 for January, 2 for February, ...).

For example
select quarter(CAST('1996-12-1' AS DATE), 1) from RDB$DATABASE

returns "96Q4".

 

addtime(ts, day, hour, min, sec, msec)

Declaration

function add_time timestamp, integer, integer, integer, integer, integer returns timestamp free_it

Description

Adds the time period specified by day, hour, min, sec, msec to the timestamp. Note none of the parameters is constrained. For example hour could be 30.
The implementation of this function relies on 'undocumented' information about the format of timestamps in Interbase.

 

subtime(ts, day, hour, min, sec, msec)

Declaration

function sub_time timestamp, integer, integer, integer, integer, integer returns timestamp free_it

Description

Subtracts the time period specified by day, hour, min, sec, msec from the timestamp. Note none of the parameters is constrained. For example hour could be 30. The implementation of this function relies on 'undocumented' information about the format of timestamps in Interbase.

 

makedate(year, month, day, hour, min, sec)

Declaration

function makedate integer, integer, integer, integer, integer, integer returns timestamp free_it

Description

Creates a timestamp from year, month, day, hour, min, sec. Note none of the parameters is constrained. For example hour could be 30. The implementation of this function relies on 'undocumented' information about the format of timestamps in Interbase.

 

diffdate(ts1, ts2, control)

Declaration

function makedate integer, integer, integer, integer, integer, integer returns timestamp free_it

Description

Returns the difference in time between the two timestamps. control specifies the units:
4 days
3 hours
2 minutes
1 seconds
0 milliseconds

The implementation of this function relies on 'undocumented' information about the format of timestamps in Interbase.

Error condition

If control is not in the range (0, 4) then -999999 is returned. Also if the return value of this function would cause the integer to overflow then -999999 is returned instead.

UDFLib compatibility

UDFLib will happily let the return value of this function overflow. I view this as a defect in UDFLib and hence this function will not let the return value overflow. Any code which relies on this 'feature' will need to be changed.

 


Copyright © Deebee Solutions Ltd 2000.
Verbatim copying and distribution of this entire document is permitted in any medium, provided this notice is preserved.