Download presentation
Presentation is loading. Please wait.
Published byMatilda Fields Modified over 9 years ago
2
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
3
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
4
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
5
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
6
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.
7
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
8
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
9
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!
10
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
11
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
12
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) ***
13
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
14
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
15
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
16
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
17
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
18
17 CREATE ~ create a table USE ~ 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 SET PATH TO e.g.SET DEFAULT TO a: SET PATH TO a:\trading
19
18 LIST LIST FIELDS LIST FIELDS FOR LIST [FIELDS ……] [ FOR… …] [TO PRINT] BROWSE BROWSE FIELDS BROWSE FIELDS …… FOR BROWSE FIELDS…… FOR…… NOEDIT BROWSE [FIELDS [:R],…] [FOR…] [NOEDIT]
20
19 EDIT EDIT FIELDS EDIT FIELDS …… FOR EDIT [FIELDS [:R],…...] [FOR…...] DIR ~ view the names of tables DISPLAY STATUS GO/GOTO GOTO TOP, GOTO BOTTOM
21
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.
22
21 RECNO( ) ~ returns the record number of the current record RECCOUNT( ) ~ returns the total number of records SET FIELDS TO, … | ALL ~ restricts access to specified fields only e.g.SET FIELDS TO name, class, class_no SET FILTER TO ~ restricts access to specified rows only e.g.SET FILTER TO class=‘3A’ AND mark>0
23
22 REPLACE WITH,... ~ replace the data of certain fields REPLACE … WITH … [ADDITIVE] ~ append text to memo field REPLACE … WITH … [FOR ] REPLACE … WITH … [ALL] e.g.REPLACE term WITH ‘1’,; mark WITH (test+exam)/2 ; FOR class=‘6S’
24
23 BLANK ~ clears all fields of the current record BLANK [FIELDS,...] [ALL] BLANK [FIELDS…] [ALL] [FOR ] e.g.BLANK FIELDS mark,conduct FOR term=‘2’ APPEND APPEND BLANK APPEND FROM FIELDS APPEND FROM…FIELDS…[FOR ] e.g.USE class6A APPEND FROM class6S FIELDS name; FOR sex=‘M’
25
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 PeterM1460 PaulM1362 MaryF1561 DELETE [ALL] DELETE FOR e.g.DELETE FOR leave=“Y” SET DELETE ON/OFF RECALL ALL
26
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 TO COPY TO [FIELDS,…] COPY TO … [FIELDS …] [FOR ] e.g.USE class6S COPY TO pass_6S FIELDS name, mark; FOR mark>=40 COPY TO … TYPE DELIMITED COPY TO … TYPE SDF COPY STRUCTURE TO... [FIELDS…] ~ copy the fields structure to a new table
27
26 TOTAL TO ON FIELDS e.g.MARK.DBF e.g. TOTAL TO stat ON subject FIELDS qty USE stat BROW
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.