Você está na página 1de 11

Alpha, AlNum

Alpha(%string%)
AlNum(%string%)
This set of functions is used to check the contents of a string.

Alpha(%string%)
Checks if %string% contains only alpha characters (A-Z,a-z)
Returns: 1 if true, 0 otherwise.

Examples:
Alpha("this is a test!") = 0
Alpha("this is a test") = 0
Alpha("thisisatest") = 1

AlNum(%string%>
Checks if %string% contains only alph-numeric characters (A-Z,a-z,0-9)
Returns: 1 if true, 0 otherwise.

Examples:
AlNum("1 2 3") = 0
AlNum("thisisatest123") = 1

Alpha, AlNum
Alpha(%string%)
AlNum(%string%)
This set of functions is used to check the contents of a string.

Alpha(%string%)
Checks if %string% contains only alpha characters (A-Z,a-z)
Returns: 1 if true, 0 otherwise.

Examples:
Alpha("this is a test!") = 0
Alpha("this is a test") = 0
Alpha("thisisatest") = 1

AlNum(%string%>
Checks if %string% contains only alph-numeric characters (A-Z,a-z,0-9)
Returns: 1 if true, 0 otherwise.

Examples:
AlNum("1 2 3") = 0
AlNum("thisisatest123") = 1
Compare, CompareNoCase, CompareNum,
CompareNumNoCase
Compare(%string1%, %string2% [,"%justification%"])
CompareNoCase(%string1%, %string2%)
CompareNum(%string1%, %string2%, %length%)
CompareNumNoCase(%string1%, %string2%, %length%)
This set of functions is used to compare strings.

Compares %string1% and %string2%


Return:
-1 if %string1% is less than %string2%
0 if both strings are the same
1 if %string1% is greater than %string2%
Allowed values for %justification% are shown below:

The Compare function has an extra argument (%justification%).


Allowed values for %justification% :
L - left-justified comparison (used for string comparison)
R - right-justified comparison (used for numeric comparison)

Default value for %justification% is L

Note: Here's a quote from the manual:


"For mixed strings, take care. For example, a right-justified
comparison of the strings
AB100 and AB99 indicates that AB100 is greater than AB99 since 100 is
greater than 99.
But a left-justified comparison of the strings AC99 and AB100
indicates that AC99 is
greater since C is greater than B."

A right-justified comparison is simply left-padding the strings with


blanks so that they
have the same length and then comparing the strings.
Compare("AB100,"AB99","R") = Compare("AB100"," AB99","L") = 1
Compare("AC99","AB100","L") = 1
Compare("100","20","R") = Compare("100"," 20","L") = 1

The remainder of this set of functions are fairly straightforward.


CompareNoCase - compares strings with no regard for case
CompareNum - compares the first n characters of a string
CompareNumNoCase - compares the first n characters of a string with no
regard for case

Examples:
Compare("horse","horse","L") = 0
Compare("horse","horse","R") = 0

Compare("zebra","ardvark","L") = 1
Compare("zebra","ardvark","R") = 1

Compare("100","20","L") = -1
Compare("100","20","R") = 1

Compare("100B","99A","L") = -1
Compare("100B","99A","R") = 1

Compare("A99","B100","L") = -1
Compare("A99","B100","R") = 1

CompareNoCase("Zebra","zebra") = 0

CompareNum("ant","antler",3) = 0
CompareNum("ant","antler",4) = -1

CompareNumNoCase("Ant","antler",3) = 0

Convert
Convert(%from%,%to%,%string%)
This function is used to translate from one set of characters to
another set.

Return:
a string with with translated characters.

Examples:
Convert("-.","/:","23-01-2009 18.09.33") = "23/01/2009 18:09:33"

Hint
Use convert to remove unwanted characters
Convert("0123456789_","","FILENAME_01") = "FILENAME"

Use convert to detect characters within a string


let str = "FILENAME_01"
let has_no_digits = (Len(str) = Len(Convert("0123456789","",str)))

Count, DCount, Len


Count(%string%,%substring%)
DCount(%string%,%delimiter%)
Len(%string%)
Count(%string%,%substring%)
This function returns the number of times %substring% occurs in
%string%.

Return:
integer

Examples:
Count("this is an island","is") = 3

DCount(%string%,%delimiter%)
This function returns the number of fields in a delimited string.

Return:
integer

Examples:
Count("this is an island"," ") = 4

Len(%string%)
This function returns the number of characters in %string%

Return:
integer

Examples:
Len("this is an island") = 17

DateFromDaysSince, DateFromJulianDay,
DaysSinceFromDate, JulianDayFromDate,
MonthFromDate, MonthDayFromDate,
NextWeekdayFromDate,
PreviousWeekDayFromDate,
WeekdayFromDate, YearFromDate,
YeardayFromDate, YearWeekFromDate
DateFromDaysSince(%days%,%date1%)
DateFromJulianDay(%jdate%)
DaysSinceFromDate(%date1%,%date2%)
JulianDayFromDate(%date%)
MonthFromDate(%date%)
MonthDayFromDate(%date%)
NextWeekdayFromDate(%date%,%dayofweek%)
PreviousWeekdayFromDate(%date%,%dayofweek%)
WeekdayFromDate(%date%)
YearFromDate(%date%)
YeardayFromDate(%date%)
YearweekFromDate(%date%)
DateFromDaysSince(%days%,%date1%)
Returns a date %days% from %date1%

Example:
let days = 10
let date1 = 2001-01-01
DateFromDaysSince(days,date1) = 2001-01-11

DaysSinceFromDate(%date1%,%date2%)
Returns the number of days between two dates

Example:
let date1 = 2001-01-01
let date2 = 2001-01-07
DaysSinceFromDate(date1,date2) = -6

DateFromJulianDay(%jdate%)
Converts a Julian date to a date

Example:
let jdate = 2451911
DateFromJulianDay(jdate) = 2001-01-01

JulianDayFromDate(%date%)
Converts a date to a Julian date

Example:
let date = 2001-01-01
JulianDayFromDate(date) = 2451911

Hint:
Use Julian days whenever you need to do date arithmetic

MonthFromDate(%date%)
returns the month portion of a date

Example:
let date = 2001-01-07
MonthFromDate(date) = 1

MonthDayFromDate(%date%)
returns the day of month

Example:
let date = 2001-01-07
MonthDayFromDate(date) = 7

NextWeekdayFromDate(%date%,%dayofweek%)
returns the date on which the next %dayofweek% falls.

Example:
let date = 2001-01-01
NextWeekdayFromDate(date,"wed") = 2001-01-03
PreviousWeekdayFromDate(%date%,%dayofweek%)
returns the date on which the previous %dayofweek% falls.

Example:
let date = 2001-01-01
PreviousWeekdayFromDate(date,"friday") = 2000-12-29

WeekdayFromDate(%date%)
returns a zero-based interger indicating the day of week (0=Sunday)
An optional argument can be used to indicate a different start of
week.

Example:
let date = 2001-01-01
WeekdayFromDate(date) = 6
WeekdayFromDate(date,"Mon") = 0
let date = 2001-01-07
WeekdayFromDate(date) = 0
WeekdayFromDate(date,"Mon") = 6

YearFromDate(%date%)
returns the year portion of a date

Example:
let date = 2001-01-07
YearFromDate(date) = 2001

YeardayFromDate(%date%)
returns the day of year

Example:
let date = 2001-01-07
YeardayFromDate(date) = 7

YearweekFromDate(%date%)
returns the week of year

Example:
let date = 2001-01-07
YearweekFromDate(date) = 1

DecimalToDecimal, DecimalToString,
StringToDecimal
DecimalToDecimal(%decimal% [,"%rtype%"])
DecimalToString(%decimal% [,"suppress_zero" | "fix_zero"])
StringToDecimal(%string% [,"%rtype%"])
This set of functions is used to manipulate decimal values.
DecimalToDecimal
Return:
a decimal value

DecimalToString
Return:
a string representation of the decimal value.

StringToDecimal
Return:
a decimal value

Note that the lvalue data type defines rounding operations. In the
examples below,
the lvalue is specified for each example.

Examples:
Round down
DecimalToDecimal(0000000001234.567890,"floor") = 00000000000001234.56
(lvalue=19,2)

Round up
DecimalToDecimal(0000000001234.567890,"ceil") = 00000000000001234.57
(lvalue=19,2)

Round nearest
DecimalToDecimal(0000000001234.567890,"round_inf") =
00000000000001234.57 (lvalue=19,2)
DecimalToDecimal(0000000001234.565890,"round_inf") =
00000000000001234.57 (lvalue=19,2)
DecimalToDecimal(-0000000001234.565890,"round_inf") = -
00000000000001234.56 (lvalue=19,2)

Discard non-significant fractional component


DecimalToDecimal(0000000001234.567890,"trunc_zero") =
00000000000001234.56 (lvalue=19,2)

Default is "trunc-zero"
DecimalToDecimal(0000000001234.567890) = 00000000000001234.57
(lvalue=19,2)

DecimalToString(0000000001234.567890) = " 0000000001234.567890"


DecimalToString(0000000001234.567890,"suppress_zero") = " 1234.56789"
DecimalToString(0000000001234.567890,"fix_zero") = "
0000000001234.567890"

StringToDecimal("0001234.56789") = 0000000001234.567890 (lvalue=19,6)

Notes:
1. There is a leading character in the string representation of
decimal values. The character
can be either a space or a negative sign.
2. As far as I can tell, "fix_zero" does not have any effect.
3. Using "suppress_zero" suppresses leading and trailing zeros as well
as the decimal point if the value
has no fractional component.
Hint: To create a string such as "-1234.50", use the following:
Let str = "-00000000000001234.50"
s1 = Trim(str[1,1]) = "-"
s2 = Right(str,Len(str)-1) = "00000000000001234.50"
s3 = Trim(s2,"0","L") = "1234.50"
result = s1:s3
= Trim(str[1,1]):Trim(Right(str,Len(str)-1),"0","L")
= "-1234.50"

UpCase, DownCase
UpCase(%str%)
DownCase(%str%)
This functions are used to convert from uppert to lower case or vice-
versa.

Return:
a string with case conversion

Examples:
UpCase("jack robinson") = "JACK ROBINSON"
DownCase("PETER RABBIT") = "peter rabbit"

Left, Right, Substring


Field(%string%,%delimiter%,%occurrence%,[%number%])
string[%start%,%length%]
Left(%string%,%length%)
Right(%string%,%length%)
This function returns fields in a delimited string.
Field(%string%,%delimiter%,%occurrence%,[%number%])
Return:
string

Examples:
let string = "one for the road"
Field(string," ",2) = "for"
Field(string," ",3,2) = "the road"

These functions are used to extract a portion of a string.

%string%[%start%,%length%]
Return:
%length% characters of string starting at %start%

Examples:
let string = "one for the road"
string[1,3] = "one"
string[5,3] = "for"

Right(%string%,%length%)
Return:
%length% rightmost characters

Examples:
let string = "one for the road"
Right[1,4] = "road"

Left(%string%,%length%)
Return:
%length% leftmost characters

Examples:
let string = "one for the road"
Left[1,7] = "one for"

Index
Index(%string%,%substring%,[%n%])
This function finds the nth occurance of substring within string

Return:
a one-based integer pointing to the start of the substring within
string

Examples:
let string = "these are the results"
Index(string,"re",1) = 8
Index(string,"re",2) = 15

IsNotNull, IsNull, NullToEmpty, NullToZero,


NullToValue, SetNull
IsNotNull(%var%)
IsNull(%var%)
NullToEmpty(%var%)
NullToZero(%var%)
NullToValue(%var%,%value%)
SetNull()
These functions are used to manipulate NULL values.

Examples:
s = @NULL
IsNotNull(s) = @FALSE
IsNull(s) = @TRUE
NullToValue(s,"some_string") = "some_string"
NullToEmpty(s) = ""

i = @NULL
NullToZero(i) = 0
i = @NULL
NullToValue(i,42) = 42

The SetNull function is used to set a column in an OUTLINK to NULL.


SetNull()

PadString, Space, Str


PadString(%string%,%char%,%length%)
Space(%length%)
Str(%string%,%repeats%)
PadString(%string%,%char%,%repeats%)
This function returns %string% right-padded with %repeat% number of
%char%

Return:
string

Examples:
PadStr("Title","*",3) = "Title***"

Space(%length%)
This function returns a string made up of %length% spaces

Return:
string

Examples:
Space(3) = " "

Str(%string%,%repeats%)
This function returns a string made up of %string% repeated %repeat%
times
Return:
string

Examples:
Str("happy ",3) = "happy happy happy "