1 / 26

Revision on Foxpro Commands

Revision on Foxpro Commands. Print command ( ? ) e.g. ? 6/2 * 3 9 SET DECIMAL TO integer e.g. SET DECIMAL TO 4 ? 2 / 3 0.6667 SET( ) function e.g. ? SET (‘DECIMAL’) 4. SET FIXED ON|OFF e.g. SET DECIMAL TO 3 SET FIXED ON ? 3 * 2 6.000

taffy
Télécharger la présentation

Revision on Foxpro Commands

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. Revision on Foxpro Commands Print command (?) e.g. ? 6/2 * 3 9 SET DECIMAL TO integer e.g. SET DECIMAL TO 4 ? 2 / 3 0.6667 SET( ) function e.g. ? SET (‘DECIMAL’) 4

  2. SET FIXED ON|OFF e.g. SET DECIMAL TO 3 SET FIXED ON ? 3 * 2 6.000 + , - , * , / , ^ , % mathematical operators e.g. ? -7^2 49.00 ? -14%4 or ? MOD(-14,4) 2

  3. +concatenation, - concatenation e.g. ? ‘Chan ‘ + ‘Tai ’ - ‘Man’ Chan TaiMan SET CENTURY ON|OFF e.g. ? {12/20/1999} + 30 01/19/00 SET CENTURY ON ? {12/20/1999} + 30 01/19/2000

  4. SET CENTURY TO e.g. SET CENTURY TO 19 ROLLOVER 50 SET CENTURY ON ? {12/24/20} 12/24/2020 ? {12/24/65} 12/24/1965 SET (‘CENTURY’) e.g. ? SET (‘CENTURY’) ON

  5. SET DATE TO (DMY|MDY|YM) DATE ( ) system date function e.g. SET DATE TO DMY ? DATE( ) 25/12/99 =, !=or<>or #, <, >, <=, >=, = = relational operators SET EXACT ON|OFF e.g. ? ‘123’ = ‘12’ .T. ? ‘123’ = = ‘12’ .F.

  6. e.g. SET EXACT ON ? ‘123’ = ‘12’ .F. SET (‘EXACT’) ON SUBSTRING ($) operator e.g. ? ‘an’ $ ‘Chan’ .T. e.g. STORE ‘Hello’ TO x ? x Hello

  7. ?? Print Command e.g. ? ‘Hello!’ ?? ‘Hi!’ ? ‘How are you?’ Hello!Hi! How are you? LEN ( ) ~ returns the number of characters e.g. ? LEN(‘How are you?’) 12

  8. UPPER ( ), LOWER ( ) e.g. ? LOWER(‘Chan Tai Man’) chan tai man ? UPPER(‘Chan Tai Man’) CHAN TAI MAN SPACE ( ) e.g. ? ‘Hello!’+SPACE(3)+’Hi!’ Hello! Hi!

  9. LTRIM( ), RTRIM( ) / TRIM( ), ALLTRIM( ) e.g. X=‘ Hello! Hi! ’ ? LTRIM(X) Hello! Hi! (with trailing spaces) ? RTRIM(X) Hello! Hi! ? ALLTRIM(X) Hello! Hi! LEFT( ), RIGHT( ) e.g. ? LEFT(RIGHT(‘How are you?’, 8), 3) are

  10. SUBSTR( ) ~ returns specified numbers of characters e.g. ? SUBSTR(‘How are you?’, 2, 4) ow a STUFF( ) ~ returns a string with certain replaced char e.g. ? STUFF (‘How are you?’, 1, 3, ‘Who’) Who are you AT( ) e.g. ? AT(‘o’,’How are you?’) 2

  11. VAL( ) ~ converts string to numeric value e.g. ? VAL(‘2’)+VAL(‘3’) 5.00 ? VAL(‘-1234E-3’) -1.234 STR( ) ~ converts numeric value to string e.g. ? STR(1234.567,7,2) 1234.57 ? STR(1234.567,3,2) ***

  12. ASC( ), CHR( ) e.g. ? ASC(‘APPLE’) 65 ? CHR(66) ‘B’ ROUND( ), INT( ) e.g. ? ROUND(-123.456,2) 123.46 ? INT(-456.789) 456

  13. ABS( ) e.g. ? ABS(-12.34) 12.34 FLOOR( ), CEILING( ) e.g. ? FLOOR (123.4) 123 ? CEILING(123.4) 124 ? CEILING(-123.4) -123

  14. SQRT( ) e.g. ? SQRT(16.000000) 4.000000 DAY ( ), MONTH( ), YEAR( ) e.g. ? DAY ({12/25/2000}) 25 ? MONTH({12/25/2000}) 12 ? YEAR({12/25/02}) 2002

  15. DOW( ), CDOW( ), CMONTH( ) e.g. ? DOW({01/01/2000}) 7 ? CDOW({01/01/2000}) Saturday ? CDOW({02/30/2000}) *bad date* ? CMONTH ({12/25/2000}) December

  16. CTOD( ) ~ converts string to date expression e.g. ? CTOD(‘02/29/2000’) 02/29/2000 DTOC( ) ~ converts date expression to string e.g. ? DTOC ({12/25/2000}) 12/25/2000 IIF( ) function e.g. mark=65 ? IIF(mark>=50, ‘passed’, ‘failed’) passed

  17. CREATE <dbf file>~ create a table USE<dbf file>~ open a table USE~ close a table CLOSE DATABASES~close all opened tables CLOSE ALL~ close all tables and windows MODIFY STRUCTURE ~ design table structure SET DEFAULT TO<drive letter> SET PATH TO<path> e.g. SET DEFAULT TO a: SET PATH TO a:\trading

  18. LIST LIST FIELDS<fieldName,…> LIST FIELDS<fieldName,…>FOR<condition> LIST [FIELDS ……] [ FOR… …] [TO PRINT] BROWSE BROWSE FIELDS<fieldName,…> BROWSE FIELDS<fieldName:R,...> BROWSE FIELDS …… FOR<condition> BROWSE FIELDS…… FOR…… NOEDIT BROWSE [FIELDS [:R],…] [FOR…] [NOEDIT]

  19. EDIT EDIT FIELDS<fieldName,…> EDIT FIELDS<fieldName:R,...> EDIT FIELDS …… FOR<condition> EDIT [FIELDS [:R],…...] [FOR…...] DIR<drive letter>~ view the names of tables DISPLAY STATUS GO/GOTO<record number> GOTO TOP, GOTO BOTTOM

  20. BOF( ) & EOF( ) functions~ check whether the record pointer is at the beginning or at the end e.g. GOTO TOP ? BOF( ) .F. SKIP -1 ? BOF ( ) .T. GOTO BOTTOM SKIP 1 ? EOF( ) .T.

  21. RECNO( ) ~ returns the record number of the current record RECCOUNT( ) ~ returns the total number of records SET FIELDS TO <fieldName>, … | ALL ~ restricts access to specified fields only e.g. SET FIELDS TO name, class, class_no SET FILTER TO<condition> ~ restricts access to specified rows only e.g. SET FILTER TO class=‘3A’ AND mark>0

  22. REPLACE <fieldName> WITH <expression>,...~ replace the data of certain fields REPLACE … WITH … [ADDITIVE] ~ append text to memo field REPLACE … WITH … [FOR <condition>] REPLACE … WITH … [ALL] e.g.REPLACEtermWITH‘1’,; markWITH(test+exam)/2; FORclass=‘6S’

  23. BLANK~ clears all fields of the current record BLANK [FIELDS <fieldName>,...] [ALL] BLANK [FIELDS…] [ALL] [FOR <condition>] e.g. BLANK FIELDS mark,conduct FOR term=‘2’ APPEND APPEND BLANK APPEND FROM<table>FIELDS <fieldNames> APPEND FROM…FIELDS…[FOR<condition>] e.g. USE class6A APPENDFROM class6S FIELDS name; FOR sex=‘M’

  24. APPEND FROM… FIELDS TYPE DELIMITED APPEND FROM… FIELDS TYPE SDF e.g. of delimited file “Peter”, “M”, 14, 60 “Paul”, “M”, 13, 62 “Mary”, “F”, 15, 61 e.g. of SDF file Peter M 14 60 Paul M 13 62 Mary F 15 61 DELETE [ALL] DELETE FOR <condition> e.g. DELETEFOR leave=“Y” SET DELETE ON/OFF RECALL ALL

  25. DELETED( ) ~ returns boolean to indicate whether the current record is marked as deleted PACK ~ kills all records marked as deleted DELETE ALL + PACK = ZAP COPY FILE <table1> TO <table2> COPY TO <table> [FIELDS <fieldName>,…] COPY TO … [FIELDS …] [FOR <condition>] e.g. USE class6S COPY TO pass_6S FIELDS name, mark; FOR mark>=40 COPYTO … TYPEDELIMITED COPYTO … TYPESDF COPYSTRUCTURETO ... [FIELDS…] ~ copy the fields structure to a new table

  26. TOTALTO <table> ON <field> FIELDS <fieldList> e.g. MARK.DBF e.g. TOTAL TO stat ON subject FIELDS qty USE stat BROW

More Related