Thursday, December 5, 2013 9:50AM EST
Tip of the Day: Understanding New (IFF((condition), arg1, arg2))
Logical Function
Product.: R:BASE eXtreme 9.5 (32/64)
Build...: 9.5.3.21205 or higher www.rupdates.com
Keywords: Functions
Section.: Logical Functions
Did you know that a new "IFF" logical function has been added to
handle working
with conditions to return a value.
Syntax: (IFF((condition), arg1, arg2))
If the condition is met, then the value of arg1 is returned. If
condition is not
met, then the value of arg2 is returned.
The condition must follow the syntax specifications as set with
IF...ENDIF command
structure.
The condition must list a set of conditions that combine to form a
statement that
is either true or false.
Conditions can be combined with the connecting operators AND, OR, AND
NOT, and OR
NOT.
Conditions using CURRENCY, the value MUST match database CURRENCY
SYMBOL settings.
It is important to note that the condition needs to be a single item,
which is why
quotes are used in the examples below.
The data types of arg1 and arg2 must match.
-- Example 01: (Comparison of Variables)
SET VAR v1 INTEGER = 1
SET VAR v2 INTEGER = 2
SET VAR v3 TEXT = NULL
SET VAR v3 = (IFF('.v1<.v2','First','Second'))
SHOW VAR v3
First
-- Example 02: (Comparing Logic)
SET VAR v1 TEXT = NULL
SET VAR v1 = (IFF('1 < 2','Yes','No'))
SHOW VAR v1
Yes
-- Example 03: (Using IF Command)
SET VAR v1 INTEGER = 1
SET VAR v2 INTEGER = 2
IF v1 < .v2 THEN
PAUSE 2 USING 'Smaller' +
CAPTION 'New IFF Function' ICON INFO +
BUTTON 'Press any key to continue ..' +
OPTION MESSAGE_FONT_NAME Tahoma +
|MESSAGE_FONT_COLOR GREEN +
|MESSAGE_FONT_SIZE 11 +
|THEMENAME Longhorn
ELSE
PAUSE 2 USING 'Bigger' +
CAPTION 'New IFF Function' ICON INFO +
BUTTON 'Press any key to continue ..' +
OPTION MESSAGE_FONT_NAME Tahoma +
|MESSAGE_FONT_COLOR GREEN +
|MESSAGE_FONT_SIZE 11 +
|THEMENAME Longhorn
ENDIF
CLEAR VARIABLES v1,v2
RETURN
-- Example 04: (Using WHILE Command)
SET VAR v1 INTEGER = 1
SET VAR v2 INTEGER = 2
SET VAR vPause2Message TEXT = NULL
WHILE v1 < v2 THEN
SET VAR v1 = (.v1 + 1)
SET VAR vPause2Message = (CTXT(.v1))
PAUSE 2 USING .vPause2Message +
CAPTION 'New IFF Function' ICON INFO +
BUTTON 'Press any key to continue ..' +
OPTION MESSAGE_FONT_NAME Tahoma +
|MESSAGE_FONT_COLOR GREEN +
|MESSAGE_FONT_SIZE 11 +
|THEMENAME Longhorn
ENDWHILE
CLEAR VARIABLES v1,v2,vPause2Message
RETURN
-- Example 05: (SELECT and Display Feedback on Data)
CONNECT RRBYW18
SELECT NetAmount,(IFF('NetAmount>$100000','Good','Needs Improvement'))=30 +
AS Status FROM SalesBonus
NetAmount Status
------------ ------------------------------
$176,000.00 Good
$87,500.00 Needs Improvement
$22,500.00 Needs Improvement
$40,500.00 Needs Improvement
$76,800.00 Needs Improvement
$36,625.00 Needs Improvement
$56,250.00 Needs Improvement
$152,250.00 Good
$108,750.00 Good
$78,750.00 Needs Improvement
$27,000.00 Needs Improvement
$9,500.00 Needs Improvement
$210,625.00 Good
Stay productive, my friends!
Very Best R:egards,
Razzak.
www.rbase.com
www.facebook.com/rbase
www.RazzakMemon.com
--
30+ years of continuous innovation!
15 Years of R:BASE Technologies, Inc. making R:BASE what it is today!
--