1 / 12

Chapter 2

Chapter 2. Functions in Foxpro. 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’

wilma
Download Presentation

Chapter 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 2 Functions in Foxpro 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 Foxpro Chap. 2 Functions

  3. Commonly used functions • Character processing • Numeric processing • Date processing • Logical processing Foxpro Chap. 2 Functions

  4. Functions forCharacter 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’ Foxpro Chap. 2 Functions

  5. Functions forCharacter 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’ Foxpro Chap. 2 Functions

  6. Functions forCharacter Processing(3) • AT(‘CD’, ‘ABCDE’) // 3 • AT(‘CE’, ‘ABCDE’) // 0 • VAL(‘123’) // 123 • ‘123’ + ‘45’ // ‘12345’ • VAL(‘123’) + VAL(‘45’) // 168.00 • STR(123) // ‘123’ • STR(123, 6, 2) // ‘123.00’ • ASC(‘ABC’) // 65 • CHR(65) // ‘A’ Foxpro Chap. 2 Functions

  7. Functions forNumeric 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 Foxpro Chap. 2 Functions

  8. Functions forDate 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 Foxpro Chap. 2 Functions

  9. Functions forDate 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’ Foxpro Chap. 2 Functions

  10. Functions forLogical Processing • IIF(condition, exp1, exp2) • IIF(1=2, ‘abc’, ‘xyz’) // ‘xyz’ • IIF(1=1, ‘abc’, ‘xyz’) // ‘abc’ 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) Foxpro Chap. 2 Functions

  12. Exercise • Do Ex. 1 to 15 on P.64 - 68 and get a feel of the pitfalls that comes with some of the questions. Foxpro Chap. 2 Functions

More Related