Download presentation
Presentation is loading. Please wait.
Published byΚύνθια Κουταλιανός Modified over 6 years ago
1
Chapter 2 Functions in Foxpro April 2003 cylau
Foxpro Chap. 2 Functions
2
Functions Used to evaluate data and return a result
can be assigned to a variable x = LEN(‘I LOVE U’) // x =8 can be used directly in a print command ? LEN(‘I LOVE U’) // 8 input: parameter and argument //’I LOVE U’ output: return as a single value //8 April 2003 cylau Foxpro Chap. 2 Functions
3
Commonly used functions
Character processing Numeric processing Date processing Logical processing April 2003 cylau Foxpro Chap. 2 Functions
4
Functions for Character Processing(1)
LEN(‘ABC’) // 3 UPPER(‘Au’) // ‘AU’ LOWER(‘Au’) // ‘au’ PROPER(‘AU wan’) // ‘Au Wan’) SPACE(3) // ‘ ’ LTRIM(‘ abc’) // ‘abc’ RTRIM(‘abc ’ ) // ‘abc’ ALLTRIM(‘ abc ’ ) // ‘abc’ April 2003 cylau Foxpro Chap. 2 Functions
5
Functions for Character Processing(2)
LEFT(‘ABCDE’, 2) // ‘AB’ RIGHT(‘ABCDE’, 2) // ‘DE’ SUBSTR(‘ABCDE’, 2, 3) // ‘BCD’ STUFF(‘ABCDE’, 2, 3, ‘X’) // ‘AXE’ STUFF(‘ABCDE’, 2, 0, ‘X’) // ‘AXBCDE’) STUFF(‘ABCDE’, 2, 3, ‘’) // ‘AE’ STUFF(‘ABCDE’, 7, 3, ‘X’) // ‘ABCDEX’ April 2003 cylau Foxpro Chap. 2 Functions
6
Functions for Character Processing(3)
AT(‘CD’, ‘ABCDE’) // 3 AT(‘CE’, ‘ABCDE’) // 0 VAL(‘123’) // 123 ‘123’ + ‘45’ // ‘12345’ VAL(‘123’) + VAL(‘45’) // STR(123) // ‘123’ STR(123, 6, 2) // ‘123.00’ ASC(‘ABC’) // 65 CHR(65) // ‘A’ April 2003 cylau Foxpro Chap. 2 Functions
7
Functions for Numeric Processing
ABS(-123) // 123 ROUND(123.45, 1) // 123.5 P.63 ROUND(numExp, numExp) INT(456.78) // 456 CEILING(456.78) // 457 FLOOR(456.78) // 456 MOD(20, 7) // 6 SQRT(10) // 3.16 April 2003 cylau Foxpro Chap. 2 Functions
8
Functions for Date Processing(1)
DATE() // today DAY({04/23/2003}) // 23 DOW({04/23/2003}) // 4 note: 1st day of week is Sunday CDOW({04/23/2003}) // Wednesday April 2003 cylau Foxpro Chap. 2 Functions
9
Functions for Date Processing(2)
MONTH({04/23/2003}) // 4 CMONTH({04/23/2003}) // April YEAR({04/23/2003}) // 2003 YEAR({04/23/03}) // 1903 CTOD(‘01/23/00’) //{01/23/1900} CTOD(‘01#23#00’) // { / / } DTOC({01/23/00}) // ‘01/23/1900’ April 2003 cylau Foxpro Chap. 2 Functions
10
Functions for Logical Processing
IIF(condition, exp1, exp2) IIF(1=2, ‘abc’, ‘xyz’) // ‘xyz’ IIF(1=1, ‘abc’, ‘xyz’) // ‘abc’ April 2003 cylau Foxpro Chap. 2 Functions
11
More on Functions What are the arguments in the function
STUFF(‘ABCDE’, 2, 3, ‘FG’) What is the output? What is the output of SUBSTR(‘Amoy Garden’, address) April 2003 cylau Foxpro Chap. 2 Functions
12
Exercise Do Ex. 1 to 15 on P and get a feel of the pitfalls that comes with some of the questions. April 2003 cylau Foxpro Chap. 2 Functions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.