Visual FoxPro 6.0
Sponsored Links
This presentation is the property of its rightful owner.
1 / 404

Visual FoxPro 6.0 程序设计教程 PowerPoint PPT Presentation


  • 333 Views
  • Uploaded on
  • Presentation posted in: General

Visual FoxPro 6.0 程序设计教程. 第 1 章至第 6 章. 高等教育出版社. 编辑:朱梦环 郝德全 王洪 吴震林 达县职业高级中学. 第 1 章 Visual FoxPro 基础知识. 目 录. 第 2 章 基本数据元素. 第 3 章 数据库的基本操作. 第 4 章 数据处理与 SQL. 第 5 章 程序设计基础. 第 6 章 查询与视图. 第 1 章 Visual FoxPro 6.0 概述. 学习要点 1 、数据库的基本术语和概念。 2 、 常用文件类型和数据类型 3 、 Visual FoxPro 的命令格式。

Download Presentation

Visual FoxPro 6.0 程序设计教程

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Visual FoxPro 6.0

16


1 Visual FoxPro

2

3

4 SQL

5

6


1 Visual FoxPro 6.0

1

2

3Visual FoxPro

4 Visual FoxPro

5


1 Visual FoxPro 6.0

1.1 Visual FoxPro 6.0

1.2

1.3

1.4


1.1 Visual FoxPro 6.0

119866FoxBASE+ 1.0

219877FoxBASE+ 2.0

319887FoxBASE+ 2.1

41992FoxPro 2.5

51994FoxPro 2.6

619956Visual FoxPro 3.0

719968Visual FoxPro5.0

819989Visual FoxPro6.0


1.2

1.2.1

1.2.2

1.2.3

1.2.4


1(DatabaseDB)

2(Database Management SystemDBMS)(OS)

3

4Database SystemDBS

DBSDBMSDB


33VFP6


A1B1C1A2B2C2D234



1-2

1-3


1-5

1-61-41-5


1.2.3

1

-(E-R)

2

3-(Entity-Relationship Model)

P.PS.Chen1976E-R


1

N

N

N

1

N

M

1

N

N

E-R

E-R

1MN


4Relational Model

()

5Object Relational Model

1

2


1.2.4

1

1

StudentStudent_IDNameSexBirthdayClassesDormitoryPhonenumber Student (Student_IDNameSexBirthdayClassesDormitoryPhonenumber)

k(k1)k

1-8Student


Sex{}Student_IDPhonenumber

()


2

3

4

5

6


7

KR1R2R2KR1

8

9

3

()

3


2

1Projection

RR

PROJECT 12n

ARRA

1-1 1-9S1

PROJECT S1,

()

1-10


2

RRFSelect

SELECT WHERE

F(R)

1-2 1-9S1

SELECT S1 WHERE =

1-11


R

S

3

RSFRSJoin

JOIN 1 AND 2 WHERE

F=ABF><=ABRASB

RS3.113.12

JOIN R AND S WHERE B<D


1.3 VFP6

1 .PJT .PJX

2 .DBC .DCT

1.3.1

3 .DBF .FPT

4 .PRG .FXP

5.IDX .CDX

6.MEM

7.FMT

8.FRX .FRT

9 .LBX .LBT

10 .TXT

11 .MNT .MNX .MPR .MPX

12 .SCX .SCT


1.3.2 VFP6

1Character,C

2Numeric,N

3Logic,L

4DateD

5MemoM

6GeneralG


1.4

1.4.1

1.4.2

1.4.3 VFP6


1.4.1

USE Grade

COUNT ALL FOR <60

LIST ALL , FOR ; <60 TO PRINTER

USE

1GRADE

2GRADE60

360

4GRADE


Visual FoxPro

<>

[<>]

[<>]

[FOR<>]

[WHILE<>]

[TO FILE <>/TO PRINTER/TO ARRAY <>/TO <>]

[ALL [LIKE/EXCEPT <>]]

[IN <>]


VFP

ALL

NEXT <n> N

RECORD <n> N

REST

FOR <>

WHILE <>

TO

ALL [LIKE/EXCEPT <>]

IN </>


1.4.2

1

2VFP44

32048;

4


1.4.3 VFP6

10*/128.3

ABC_DE-f1

.DBF


[]

<>

/


VFP6VFP6VFP6


2

1

2

3

4

5

2.1

2.2

2.3

2.4


2.1

1VFP6

2Visual FoxPro 6.0



3VFP6

VFP6VFP6VFP6VFP6

VFP6|

VFP6QuitEnter

VFP6

4

1

Visual FoxPro

2

VFP6Wizard.app


2.2

2.2.1

Visual FoxPro:

2.2.2


2.2.3

1

Visual FoxPro

S1

S(1)

Visual FoxPro


2

DIMENSION <1><>[<>][<2> <>[,<>]]

DECLARE <1><>[<>][<2> <>[,<>]]

DIMENSIONDECLARE

<1>

<>[<>]

1

2

3


4

5

6DIMENSIONDECLAREDIMENSION

DIMENSION <1><>[<>][<2> <>[,<>]]

DIMENSION A 2 , 3 , BB ( 4 , 8 )

DIMENSION A(2,3),BB(4,8)

DIMENSION A(2,3)

DIMENSION A(6)


3

STORE <> TO </>

STORE 0 TO A 0A

STORE "" TO A(2,1) A21

</>=<>

A=.T. A


2.1 VFP

1

STORE <> TO <>

STORE 0 TO AA,BB,CC 0AA,BB,CC

STORE "" TO NAME NAME

<>=<>

A=.T. A


2

LIST MEMORY [LIKE<>] [TO PRINTER[PROMPT]/TO FILE<>] [NOCONSOLE]

LIST

MEMORYLIST

LIKE<>

TO PRINTER[PROMPT]

TO FILE<>

NOCONSOLE


DISPLAY MEMORY [LIKE <>] [TO PRINTER[PROMPT]/TO FILE<>] [NOCONSOLE]

DISPLAY

LIST

LIST MEMORYDISPLAY MEMORY

LIST MEMORY

DISPLAY MEMORY


LIST MEMORYDISPLAY MEMORY

LIST MEMORY

LIST MEMORY


LIST MEMORYDISPLAY MEMORY

DISPLAY MEMORY

DISPLAY MEMORY


3

SAVE TO <>/ <MEMO >[ALL LIKE/ EXCEPT <>]

<> .MEM

SAVE

<>

<MEMO>

ALL LIKE<>]<>

ALL EXCEPT <>]<>


SAVE

SAVE TO VAR1 VAR1.MEMAABBCCNAMEA

SAVE TO VAR2 ALL LIKE ?A* AVAR2.MEMAANAME

SAVE TO VAR3 ALL EXCEPT ?A*AVAR2.MEMBBCCA


4

RELEASE <>

<>,

RELEASE ALL [LIKE/EXCEPT <>]

CLEAR MEMORY

RELEASE ALL


RELEASE BB,CC

LIST MEMORY LIKE *

RELEASE ALL LIKE ?A*

LIST MEMORY LIKE *

RELEASE ALL

LIST MEMORY LIKE *


5

RESTORE FROM <> [ADDITIVE]

<>

RESTORE

FROM <>

[ADDITIVE] ADDITIVE


RESTORE FROM VAR1

LIST MEMORY LIKE *

RESTORE FROM VAR2

LIST MEMORY LIKE *

RESTORE FROM VAR3 ADDITIVE

LIST MEMORY LIKE *


2.3

2.3.1

2.3.2

2.3.3


2.3.1

C N

L D

<>

??<>

??


2.3.2

()

1

1 +NNN 2 -NNN

3 * NNN 4 /NNN

5 ** NNN 6 ^ NNN

7 %NNN

1

2


1 < NNLCCLDDL

2 > NNLCCLDDL

3 = NNLCCLDDL

4 <= NNLCCLDDL

5 >= NNLCCLDDL

6 <> NNLCCLDDL

7 # NNLCCLDDL

8 != NNLCCLDDL

9 $ CCL

10 == CCL


(1) .NOT. LL

(2) LL

(3) .AND. LLL

(4) .OR. LLL

(1) + CCC

(2) - CCC

(1) +DNDNDD

(2) -DDNDND


2.3.3

+-

+-

**^

*/%

+-

+-

.NOT.

<>=<=>=<>#!=$==

.AND.

.OR.


2.4

2.4.1

2.4.2

2.4.3

2.4.4

2.4.5

2.4.6


2.4.1

1.

ABS(<nExpression>)

<nExpression>

<nExpression>ABS( )

2.

SIGN(<nExpression>)

101

<nExpression>SIGN( )SIGN( )1100


3.

INT(<nExpression>)

<nExpression>INT( )

4.

SQRT(<nExpression>)

<nExpression>SQRT( )

5.

EXP(<nExpression>)

e

<nExpression>exx


6.

LOG(<nExpression>)

EXP

<nExpression>LOG( )ex=<nExpression>x<nExpression>0

7.

LOG10(<nExpression>)

10

<nExpression>LOG10( )10x=<nExpression>x<nExpression>0

8.

CEILING(<nExpression>)

<nExpression>CEILING( )


9.

FLOOR(<nExpression>)

<nExpression>FLOOR( )

10.

MAX(<eExpression1><eExpression2>[<eExpression3>])

<eExpression1><eExpression2>[<eExpression3>]MAX( )

11.

MIN(<eExpression1><eExpression2>[<eExpression3>])


12.

ROUND(<nExpression1><nExpression2>)

<nExpression1><nExpression2><nExpression2>ROUND( )<nExpression2>2()0

13.

RAND([<nExpression>])

(0,1)

<nExpression>RAND( )

14.

PI()


15.

MOD(<nExpression1><nExpression2>)

<nExpression1><nExpression2>

<nExpression1><nExpression2>

<nExpression2>

<nExpression2>

MOD()%

<nExpression1><nExpression2><nExpression1><nExpression2><nExpression1><nExpression2>

? MOD(132,11) 0

? MOD(132.45,11.56) 5.29

? MOD(-132.45,11.56) 6.27

? MOD(132.45,-11.56) -6.27

? MOD(-132.45,-11.56) -5.29


2.4.2

1.

1&<VarName>[.< cExpression>]

&&<VarName>

&.&<VarName>.

abcd=[Visual]

VisualFoxpro=[]

Visual=123456789

"&abcd.FoxPro" VisualFoxPro (C)

? &abcd.Foxpro (C)

? Abcd 123456789 (N)


2(<VarName>)

( )&

<VarName>

tableName=[Student]

use (tablename) &&Student

3EVALUATE(<cExpression>)

<cExpression>

<cExpression>VFP6<cExpression>255EVALUATE( )&EVALUATE( )


2.

1AT(<cSearchExpression>,<cExpressionSearched> [,<nOccurrence>])

n

<cSearchExpression>AT( )<cExpressionSearched><nOccurrence><cSearchExpression><cExpressionSearched><nExpression>

<nOccurrence><cSearchExpression>

<cExpressionSearched><cSearchExpression><nOccurrence>0

AT( )2

2ATC(<cSearchExpression>,<cExpressionSearched> [,<nOccurrence>])


3.

RAT(<cSearchExpression>,<cExpressionSearched> [,<nOccurrence>])

AT( )<cSearchExpression><cExpressionSearched><nOccurrence>

<nOccurrence>RAT( )<cExpressionSearched>< cSearchExpression ><nOccurrence><nExpression>=1<cExpressionSearched><cSearchExpression>RAT( )0

4.

RATC(<cSearchExpression>,<cExpressionSearched> [,<nOccurrence>])

<cSearchExpression><cExpressionSearched><nOccurrence>

<cExpressionSearched><cSearchExpression><nOccurrence>0


5.

SUBSTR(<cExpression>,<nStartPosition> [, <nCharactersReturned>])

<cExpression><nStartPosition><nCharactersReturned>

<nCharactersReturned><nCharactersReturned>

6.

LEFT(<cExpression>,<nExpression>)

<cExpression><nExpression>

<cExpression>LEFT( )<nExpression><cExpression><nExpression><cExpression><nExpression>LEFT()1SUBSTR( )


7.

RIGHT(<cExpression>,<nExpression>)

<cExpression><nExpression>

<cExpression>LEFT( )<nExpression><cExpression><nExpression><cExpression><nExpression>

8.

TRIM(<cExpression>)

<cExpression>

TRIM( )RTRIM( )

9.

RTRIM(<cExpression>)

RTRIM( )TRIM( )


10.

ALLTRIM(<cExpression>)

<cExpression>LTRIM (RTIMR(< cExpression>))

ALLTRIM( )

11.

LEN(<cExpression>)

<cExpression>,

12.

SPACE(<nExpression>)

<nExpression>

13.

REPLICATE(<cExpression>,<nExpression>)

<cExpression><nExpression>


14.

STUFF(<cExpression>,<nStartReplacement>,<nCharacters-Replaced>, <cReplacement>)

<cExpression><nStartReplacement><cExpression><nCharactersReplaced>0<cReplacement><cExpression><cReplacement><cExpression><nCharactersReplaced>


2.4.3

1.

TIME([<nExpression>])

248()

<nExpression>1/100 s<nExpression>1/18sSECONDS( )

2.

DATE( )

3.

DMY(<dExpression | tExpression>)

..22

<dExpression>

<tExpression>


4.

MDY(<dExpression | tExpression>)

..October 05 2000

5.

YEAR(<dExpression>)

<dExpression>

CENTURY

6.

MONTH(<dExpression>)

<dExpression>

7.

DAY(<dExpression>)

<dExpression>

DAY( )131


2.4.4

1.

UPPER(<cExpression>)

<cExpression>

2.

LOWER(<cExpression>)

<cExpression>

3.

PROPER(<cExpression>)

<cExpression>

4.

CTOD(<cExpression>)

<cExpression>


5.

DTOC(<dExpression | tExpression> [,1])

<dExpression | tExpression>[,1]

6.

STR(<nExpression>[,<nLength>[,<nDecimalPlaces>]])

<nExpression>

<nLength><nDecimalPlaces>(*)*<nDecimalPlaces><nLength><nExpression>


7.

VAL(<cExpression>)

<cExpression>

8. ASCII

ASC(<cExpression>)

<cExpression>ASC

9. ASCII

CHR(<nExpression>)

<nExpression>ASC1~255

7

? CHR(7)+""&&


2.4.5

1.

DBC( )

2.

DBF([<cTableAlias | nWorkArea>])

<cTableAlias><nWorkArea>

3.

LUPDATE([<cTableAlias> | <nWorkArea>])

4.

FDATE(<cFileName> [, <nType>])

<cFileName><nType>010


5.

FCOUNT([<nWorkArea>|<cTableAlias>])

0VFP6

6.

FIELD(<nExpression>[,<nWorkArea>|<cTableAlias>])

<nExpression>

<nWorkArea>|<cTableAlias>

VFP6


7.

FSIZE(<cFieldName>[,<nWorkArea>|<cTableAlias>])

<cFieldName><nWorkArea>|<cTableAlias>

8.

RECCOUNT([<nWorkArea>|<cTableAlias>])

<nWorkArea>|<cTableAlias>0VFP6

9.

RECSIZE([<nWorkArea>|<cTableAlias>])

<nWorkArea>|<cTableAlias>


10.

RECNO([<nWorkArea>|<cTableAlias>])

<nWorkArea>|<cTableAlias>

11.

BOF([<nWorkArea>|<cTableAlias>])

()

<nWorkArea>|<cTableAlias>

12.

EOF([<nWorkArea>|<cTableAlias>])

()

<nWorkArea>|<cTableAlias>


13.

DELETED([<nWorkArea>|<cTableAlias>])

.T..F.

<nWorkArea>|<cTableAlias>DELETED( ).F.

14.

FOUND([<nWorkArea>|<cTableAlias>])

LOCATECONTINUEFINDSEEK.T..F.

<nWorkArea>|<cTableAlias>

15.

ALIAS([<nWorkArea>|<cTableAlias>])

<nWorkArea>|<cTableAlias>


16.

SELECT([0/1])

01

17.

1TYPE(<cExpression>)

CNLDMYTOGSU

2VARTYPE(eExpression [, lNullDataType])

CNLDYTOGXNullU

TYPE()VARTYPE()TYPE()VARTYPE()TYPE()VARTYPE()


18.

EMPTY(<eExpression>)

<eExpression>.T..F.

19.

ISNULL(<eExpression>)

Null.T..F.

<eExpression>

20.

ISBLANK(<eExpression>)

<eExpression>


21.

OCCURS(<cSearchExpression>,<cExpressionSearched >)

<cSearchExpression><cExpressionSearched >

<cExpressionSearched><cSearchExpression>0

22.

FILE(<cFileName>)

.T..F.

<cFileName>

23.

ISALPHA(<cExpression>)

<cExpression>.T..F.


24.

ISLOWER(<cExpression>)

<cExpression>.T..F.

25.

ISUPPER(<cExpression>)

<cExpression>.T..F.

26.

ISDIGIT(<cExpression>)

<cExpression>(09).T..F.

27.

IIF(<lExpression>,<eExpression1>,<eExpression2>)

<lExpression>

<lExpression>.T.<eExpression1><eExpression2>


28.

BETWEEN(<eTestValue>,<eLowValue>,<eHighValue>)

<eTestValue><eLowValue><eHighValue>.T..F.<eLowValue><eHighValue>NullNull

2.4.6

1.

USED(<nWorkArea>|<cTableAlias>)

<nWorkArea>/<cTableAlias>.T.


2.

CREATEOBJECT(<ClassName>[,<eParameter1>,<ePara-meter2>])

OLE

<ClassName>OLE

3.

DODEFAULT(<eParameter1>[,<eParameter2>])

<eParameter1>[,<eParameter2>]

4.

MESSAGE([1])


5.

MESSAGEBOX(<cMessageText>[,<nDialogBoxType> [,<cTitle-BarText > ]])

mm=messagebox(MESSAGEBOX()+CHR(13)+",3+64+256,"MessageBox()")

-1-2-3-4-5-6-7


1VFP6

2VFP6

2VFP6


3

1

2

3

4


3

3.1

3.2

3.3

3.4

3.5

3.6


3.1

3.1.1

3.1.2

3.1.3

3.1.4


3.1.1

VFPControl Center

1VFP

2VFP

Gxglxt

CREATE PROJECT <|?>

<>VFP.PJX

<?>


.APP.EXE



3.1.2

1

Event loop

3-1:

DO Setup &&

DO MainMenu.mpr &&

READ EVENTS &&

DO cleanup &&

MainMenu.mprCLEAR EVENTS


2

External libraryprocedure

3

DODO FORM

4

READ EVENTSCLEAR EVENTS

5

SETSET TALKCtalkVal

CtalkVal=SET (Talk)

TALK

SET TALK &CtalkVal


3.1.3


3.1.4

1

2

3

4

1

2

3

4


3.2

3.2.1

3.2.2

3.2.3

3.2.4

3.2.5

3.2.6


3.2.1

1VFP

2

StudentGrade

3

Student

4

5


3.2.2

Gxglxt


3.2.3

Gxglxt

StudentGradeStudentGrade

Specialty


3.2.4

VFPnull


3.2.5

VFP

VFP


3.2.6


3.3

3.3.1

3.3.2


3.3.1


3.3.2

1

2

.DBF

OPEN DATABASEEXCLUSIVE


3.4

3.4.1

3.4.2

3.4.3


3.4.1

GxglxtStudent


3.4.2

CREATE <>

Enter

<>

Enter

CREATE.FPT

.DBF


A-J

Student.dbf

VFP|Alt+FCtrl+ NCtrl+N VFP


|


3.4.3

1

LIST STRUCTURE [TO PRINTER[PROMPT] /TO FILE<>]

DISPLAY STRUCTURE [TO PRINTER[PROMPT] /TO FILE<>]

[TO PRINTER][PROMPT][PROMPT]TO PRINTER

[TO FILE]


LIST STRUCTUREDISPLAY STRUCTURE

DISPLAY STRUCTURE

LIST STRUCTURE

Student

USE Student

LIST STRUCTURE


2

MODIFY STRUCTURE

NULL

(1)

Ctrl+D

Ctrl+W


(2)

Ctrl+I

Ctrl+W

(3)

MODIFY STRUCTURECREATE


3

COPY STRUCTURE TO <> [FIELDS <>]

<>

<>

FIELDS <>

FIELDS <>

4

1

COPY STRUCTURE TO <> EXTENDED


Studentstudstr

USE Student

COPY STRUCTURE TO studstr EXTENDED

USE studstr

LIST STRUCTURE


2

CREATE <> FROM <>

studstrStudent1

CREATE Student1 FROM studstr

USE Student1

LIST STRUCTURE


3.5

3.5.1

3.5.2

3.5.3

3.5.4

3.5.5

3.5.6

3.5.7


3.5.1

USE [<>] [EXCLUSIVE] [SHARED]

<>

[EXCLUSIVE]

[SHARED]

FPT

ALIAS<>


3.5.2

APPEND [BLANK]

[BLANK]


CREATE

APPENDAPPEND BLANKAPPENDVFP

|


3.5.3

VFP

1

GOTO [RECORD <> ] /TOP/BOTTOM

GO [RECORD <> ] /TOP/BOTTOM

<>

<>

TOP

[BOTTOM]

RECORD<>0


2

SKIP [<>]

<>

1<><>

2<>SKIP SKIP 1


3.5.4

1INSRET

INSERT [BLANK] [BEFORE]

[BEFORE]

[BLANK]

1

2VFPINSERTINSERT


2INSERTSQL

INSERT INTO <>[(<1> [<2>])] VALUES (<1>[,<2>])

INSERT INTO <> FROM ARRAY <>/ FROM MEMVAR

<><>

[(<1> [<2>])]

[VALUES (<1>[,<2>])]

[FROM ARRAY <>]

FROM MEMVAR


1<>VFP

2VALUES

3FROM ARRAY <><>

4FROM MEMVAR

INSERTSQLStudent


INSERT INTO Student(,,,,,,;

) VALUES("99045002","","",{^1980/03/22},;

"99","3-311","2356306")

3

APPEND FROM <>/ [FIELDS <>] [FOR <>]

<>

[<>]

[FIELDS <> ]

[FOR <>]<>FOR


3.5.5

LIST [OFF] [FIELDS <>] [<>] [FOR <>] [WHILE <>] [TO PRINTER [PROMPT] / TO FILE <>]

DISPLAY [OFF] [FIELDS <>] [<>] [FOR <>] [WHILE <>] [TO PRINTER [PROMPT] / TO FILE <>]

[OFF]OFF

[<>]ALLRECORDN [ NEXTNREST

FIELDS <><><>50


[FOR<>/WHILE<>]<>

[TO PRINTER [PROMPT] / TO FILE <>]TO PRINTER [PROMPT][PROMPT]TO FILE <>

LISTDISPLAY

(1)DISPLAYLIST

(2)DISPLAYNEXT 1LISTALL


3.5.6

1

(1)


VFP


2

BROWSE [FIELDS <>] [LOCK <>] [LAST] [FOR <>]

[Fields<>]

LOCK <>

LAST

FOR <>

1BROWSEBROWSE


2<>

VFP

10

<>=<>

BROWSE FIELDS NAME_BIRTH=+":"++":"+DTOC()+""


:H

BROWSE FIELDS NAME_BIRTH=+":"++":"+ ; DTOC()+"":H="" ,


2

REPLACE <1> [ADDITIVE] [,<2> WITH <2> [ADDITIVE]] [<>] [FOR <>] [WHILE <>]

<1>

WITH <1>

<>

FOR <>

WHILE <>

WITHWITH


3.5.7

VFP

1

DELETE [<>] [FOR <>] [WHILE <>]

GO 7

DELETE

GO 4

DELETE NEXT 3

LIST


2

PACK [DBF] [MEMO]

DBFMEMOPACK

PACKPACK

PACK

LIST


3

RECALL [<>] [FOR <>] [WHILE <>]

*

(Student)

RECALL ALL

BROW

4

ZAP

ZAPDELETE ALL PACKZAP


3.6

1

SCATTER [FIELDS <>/FIELDS LIKE <>/FIELDS EXCEPT <>] [MEMO] TO <>/ TO <> BLANK/MEMVAR/NAME <>

scatter fields student_id,name,sex,classes to abc

list memory like *


2

GATHER FROM [<>/<MEMVAR>]/[<NAME >] [FIELDS <>/ FIELDS LIKE <>/FIELDS EXCEPT <>]

dime aa(7)

aa(1)="1999045003"

aa(2)=""

aa(3)=99

append blank

Gather from aa fields Student_id,name,classes


3

COPY TO ARRAY <> [FIELDS <>] [<>] [FOR <>] [WHILE <>][NOOPTIMIZE]

SCATTER


4

APPEND FROM ARRAY <> [FOR <>] FIELDS <>

M

FIELDS <><><>

EMPTY().T.


1CREATE PROJECT

2

3

4

5

6CREATECOPY STRUCTURECREATEFROM

7MODIFY STRUCTURE

8APPENDINSERT INTODELETEBROWSEREPLACE

9


4SQL

1

2

3

4

5SQL


4 SQL

4.1

4.2

4.3

4.4

4.5

4.6 SQL


4.1

SORT TO <> ON <1> [/A | /D] [/C] [,<2> [/A | /D] [/C] ...] [ASCENDING|DESCENDING] [<>] [FOR <>] [WHILE <>] [FIELDS <>| FIELDS LIKE <> | FIELDS EXCEPT <>]

<>

ON <1>

[/A | /D] [/C]/A/D/C/C/A/D


[ASCENDING]/D

[DESCENDING]/AASCENDING DESCENDING

[<>]ALL

[FOR <>]

[WHILE <>]<>

[FIELDS <>]SORTFIELDS

[FIELDS LIKE <>]

[FIELDS EXCEPT <>]


4.2

VFP

Null


1

2

3

4.2.1

1

INDEX ON <> TO <> [UNIQUE] FOR <>[ADDITIVE]

<>.IDX

<>


<>

[UNIQUE]UNIPUE<>

[ADDITIVE]ADDITIVE

FOR <><>


1

2

3

4

USE STUDENT

INDEX ON TO XHSY

LIST


2

INDEX ON <> TAG <> [OF <>][FOR <>] [ASCENDING | DESCENDING] [UNIQUE][ADDITIVE]

.CDX

<>[FOR <>][ADDITIVE]

TAG <> [OF <>]TAG <>[OF <>]


TAG <>[OF <>]

[ASCENDING | DESCENDING]ASCENDING DESCENDING

[UNIQUE].IDX.CDXUNIQUE

DESCENDINGASCENDING


3

1



2


4.2.2

1

1

USE <> INDEX <> [ORDER <>/ <>/[TAG] <> [OF <>]] [ASCENDING/ DESCENDING]

<>

<>ORDERORDER


2ORDERORDER <>

3ORDER [TAG] <> [OF <>]ORDER

4ORDER <><>


(2)

SET INDEX TO [<>/] [ORDER <>/<>/[TAG] <> [OF <>]] [ASCENDING/DESCENDING] [ADDITIVE]

<>

[ORDER <>]


0

[ORDER <>]

[ORDER [TAG] <> [OF <>]][OF <>]

[ASCENDING/ DESCENDING][ASCENDING/ DESCENDING]ORDER

[ADDITIVE]SET INDEX


SET INDEX

SET INDEX TO

2

SET ORDER TO [<>/<>/[TAG] <> [OF <>] [ASCENDING/DESCEN-DING]


<>USESET INDEX

<>

[TAG] <> [OF <>][OF <>]

[ASCENDING/DESCENDING]

SET ORDER TO

VFPSET ORDERASCENDINGDESCENDINGSORT ON ASCENDINGDESCENDING


0

3

()

REINDEX

REINDEXUNIQUEINDEXSET UNIQUE ONUNIQUE


4.3

4.3.1

4.3.2

4.3.3


4.3.1

1LOCATE

LOCATE [<>] [FOR <>] [WHILE <>]

[<>]LOCATEALL

[FOR <>]LOCATERushmoreLOCATE FOR FOR


[WHILE <>]

(1)

(2)LOCATERECNO()FOUND()EOF()FOUND()

(3)SET EXACT OFFLOCATE

(4)

CONTINUE


2CONTINUE

CONTINUE

LOCATE

CONTINUELOCATE,LOCATECONTINUE<>CONTINUE

CONTINUERECNO() FOUND()EOF()

CONTINUERECNO()table plus one, FOUND()EOF()


4.3.2

LOCATEVFPFINDSEEK

1FIND

FIND <>/<>

FOUND()FOUND()EOF()

FIND


FIND

FIND

SET EXACTFINDSET EXACT ONFIND


+FINDSET EXACT-FIND

FINDCONTINUEFINDFINDSKIPDISP


2SEEK

SEEK <> [ORDER <>/<>/ [TAG] <> [OF <>] [ASCENDING/ DESCENDING]]

<>1

<>SEEK<>

ORDER <>/<>/[TAG] <> [OF <>] [ASCENDING/DESCENDING]<>

SEEKFIND


SEEKSEEKSEEK

SEEK

3


4.3.3

GETEXPR [<1>] TO <> [TYPE <2>[;<>]] [DEFAULT <3>]

GETEXPRLOCATE

[<1>]

TO <>VFPEscDEFAULTEsc


[TYPE <2>[;<>]]<2>C-N-D-L-T-F-I-B-Y-Currency

<><2><><2><><2><>

[DEFAULT <3>]GETEXPR<3>GETEXPR


GETEXPRLOCATE

GETEXPR "" TO CXTJ TYPE "L" DEFAULT "= "


4.4

4.4.1

4.4.2

4.4.3


4.4.1

COUNT [<>] [FOR <>] [WHILE <>] [TO <>]

<>

<><><><><><>COUNTALL

TO <>(SET TALK ON)

USE STUDENT

SET EXACT OFF

COUNT FOR ="".OR.="" TO RS


4.4.2

SUM [<>] [<>] [FOR <>] [WHILE <>] TO <>/TO ARRAY <>

<>

<><>

TO <><>


4.4.3

AVERAGE [<>] [<>] [FOR <1>] [WHILE <2>] [TO <>| TO ARRAY <>]

<><>

AVERAGESUM

<>ALL<><><>SET TALK ON


4.5

4.5.1

4.5.2

4.5.3


4.5.1

1

VFP632767132767110AJ1-32767A-J10A-J

USE <>USEALIAS

USE <> [ALIAS <>] [IN <//>] [AGAIN]


[IN <>/<>/<>]<><>

[ALIAS <>]

[AGAIN]

1AGAINUSE

2AGAINUSEIN


2

SELECT

SELECT <>/<>/0

0

SELECT 3

USE STUDENT ALIAS XS

SELECT 1

USE SCORE

USE SCORE ALIAS CJ IN XS AGAIN


CLOSE

1CLOSE DATABASE

1

2CLOSE TABLE

3CLOSE ALL

1CLOSE ALL FCREATE()()FOPEN()CLOSE ALLSET PRINT


USE

USE IN <>/<>

<>-><>.

<> -><> <>.<>

SELECT 2

USE SCORE ALIAS CJ

SELECT 1

USE STUDENT

DISPLAY ,,,CJ.,CJ.


4.5.2

1

SET RELATION TO [<1>] INTO <>/<> [,<2> INTO <>/<>]] [IN <>/<>][ADDITIVE]

<1>


<>

1<>RECNO()EOF().T.

SELECT 2

USE SCORE ALIAS CJ

SELECT 1

USE STUDENT

SET RELATION TO RECNO() INTO CJ

2<>RECNO()<><>


EOF().T.

SELECT 2

USE SCORE ALIAS CJ

SELECT 1

USE STUDENT

SET RELATION TO 3*RECNO()-2 INTO CJ

3<>

SELECT 2

USE SCORE ALIAS CJ

INDEX ON TO XHSY

SELECT 1

USE STUDENT

SET RELATION TO INTO CJ


INTO <>/<>

ADDITIVEADDITIVEADDITIVE

<><><>


SET SKIP TO

SET SKIP TO <>/<> [,<>/<>]

SET SKIP TO<><>

2

SET RELATION/


1SET RELATION TO

2SET RELSTION OFF INTO <>/<>

<>/<>C

SET RELATION OFF INTO C

USE


4.5.3

COPY

JOIN WITH <>/<> TO <> FOR <> [FIELDS <>]

<>/<><>

<>/<>

FOR <><>

[FIELDS <>]<>

JOINJOIN


4.6 SQL

4.6.1 SQL

4.6.2 SQL

4.6.3 SQL


4.6.1 SQL

1

CREATE TABLE|DBF TableName1 [NAME LongTableName] [FREE] (FieldName1FieldType [(nFieldWidth [,nPrecision])] [NULL | NOT NULL]

[CHECK lExpression1 [ERROR cMessageText1]]

[DEFAULT eExpression1][PRIMARY KEY|UNIQUE]

[REFERENCES TableName2 [TAG TagName1]] [NOCPTRANS]

[,FieldName2 ...][,PRIMARY KEY eExpression2 TAG TagName2

|,UNIQUE eExpression3 TAG TagName3]

[,FOREIGN KEY eExpression4 TAG TagName4 [NODUP]

REFERENCES TableName3 [TAG TagName5]]

[,CHECK lExpression2 [ERROR cMessageText2]])

|FROM ARRAY ArrayName


TableNamelTABLEDBF

NAMELongTableName128

FREE

FieldNamel255Null254

FieldType[(nFieldWidth[nPrecision])]()FieldTypenFieldWidthnPrecision


FiledTypenFiledWidthnPression

FiledType

nFiledWidth

nPrecision

nd

d

-VFP

DTIYLMGPnFieldWidthnPrecisionNFBnPrecision0

n

-

-

n

n

-

-

-

-

-

-

-

-

-

-

d

d

-

d

-

-

-

-

C

D

T

N

F

I

B

Y

L

M

G

P


NULLnullnull255254

NOT NULLnullNULLNOT NULLSET NULLnullNULLNOT NULLPRIMARY KEYUNIQUESET NULLNOT NULL

CHECK lExpression1lExpression1

ERROR cMessageText1VFP6

DEFAULT eExpression1eExpression1

PRIMARY KEY

UNIQUE

INDEXUNIQUEnull


REFERENCES TableName2 [TAG TagName1]TAG TagNamelTAG TagNamel

NOCPTRANS

PRIMARY KEY eExpression2 TAG TagName2eExpression2TAG TagName2

UNIQUE eExpression3 TAG TagName3eExpression3PRIMARY KEYTAG TagName3

FOREIGN KEY eExpression4 TAG TagName4 [NODUP]eExpression4TagName4NODUP


FROM ARRAY ArrayName

SET EXCLUSIVEFREECREATE TABLECREATE TABLE NULLNOT NULLCHECKDEFAULTPRIMARY KEYUNIQUE

4-15CREATE TABLEGradexsglxt4-2


xsglxt

CREATE TABLE Grade(Student_ID C(10) NOT Null,;

Course_ID C(4) NOT Null,;

TestType C(4) NOT Null CHECK TestType=[] OR TestType; =[] OR TestType=[] ;

ERROR [];

DEFAULT ,;

PRIMARY KEY Student_ID + Course_ID + TestType TAG SCT,;

TestDate D NOT Null,;

TestGrade N(5,1) NOT Null)

Grade5GradeCREATE TABLE


2

CREATE CURSOR alias_name(fieldname1type

[(precision [,scale])[NULL|NOT NULL]

[CHECK lExpression [ERROR cMessageText]]

[DEFAULT eExpression][UNIQUE][NOCPTRANS]][, fname2 ...])

| FROM ARRAY ArrayName

CREATE TABLECREATE TABLE

4-16StudentCREATE CURSORCUR_StudentStudent_IDNameSex

CREATE CURSOR CUR_Student(Student_ID C(10) NOT NULL UNIQUE,;

Name C(8) NOT NULL UNIQUE,;

Sex C(2) CHECK Sex=[] OR Sex=[] ERROR [] DEFAULT [],;

Birthday D,;

Classes C(10),;

Dormitory C(5),;

PhoneNumber C(8))


3

3

ALTER TABLE TableName1 ADD | ALTER [COLUMN] FieldName1

FieldType [(nFieldWidth [,nPrecision])][NULL | NOT NULL]

[CHECK lExpression1 [ERROR cMessageText1]]

[DEFAULT eExpression1][PRIMARY KEY | UNIQUE]

[REFERENCES TableName2 [TAG TagName1]][NOCPTRANS]

[NOVALIDATE]

TableName1

ADD [COLUMN] FieldName1

ALTER [COLUMN] FieldName1

FieldType[(nFieldWidth[,nPrecision])]


NULL | NOT NULL()null

CHECK lExpression11Expressionl

ERROR cMessageText1

DEFAULT eExpression1

PRIMARY KEY

UNIQUE

REFERENCES TableName2 TAG TagNamelTAG TagNamel

NOCPTRANSNOCPTRANSNOCPTRANS

4-17GradeIsTest.T.

xsglxt

ALTER TABLE Grade ADD IsTest L DEFAULT .T.


ALTER TABLE TableName1 ALTER [COLUMN] FieldName2 [NULL | NOT NULL] [SET DEFAULT eExpression2]

[SET CHECK lExpression2 [ERROR cMessageText2]]

[DROP DEFAULT][DROP CHECK][NOVALIDATE]

ALTER [COLUMN] FieldName2ALTER TABLEALTER [COLUMN] FieldName2

SET DEFAULT eExpresslon2

SET CHECK lExpression2

DROP DEFAULT

DROP CHECK

4-18GradeTestGrade3

xsglxt

ALTER TABLE Grade ALTER TestGrade N(3)


ALTER TABLETableName1 [DROP [COLUMN] FieldName3]

[SET CHECK lExpression3 [ERROR cMessageText3]]

[DROP CHECK]

[ADD PRIMARY KEY eExpression3 TAG TagName2 [FOR lExpression4]]

[DROP PRIMARY KEY]

[ADD UNIQUE eExpression4 [TAG TagName3 [FOR lExpression5]]]

[DROP UNIQUE TAG TagName4]

[ADD FOREIGN KEY [eExpression5] TAG TagName4 [FOR lExpression6]

REFERENCES TableName2 [TAG TagName5]]

[DROP FOREIGN KEY TAG TagName6 [SAVE]]

[RENAME COLUMN FieldName4 TO FieldName5]

DROP [COLUMN] FieldName3FieldName3


ADD PRIMARY KEY eExpression3 TAG TagName2 [FOR lExpression4]eExpression3TagName2TAG TagName2eExpression3eExpression3FOR lExpression4lExpression4FOR

DROP PRIMARY KEY

ADD UNIQUE eExpression4 [TAG TagName3 [FOR 1Expression5]]ADD PRIMARY KEY eExpression3 TAG TagName2 [FOR lExpression4]

DROP UNIQUE TAG TagName4

RENAME COLUMN FieldName4 TO FieldName5FieldName4FieldName5


4-19GradeTestTypeIsTest

xsglxt

ALTER TABLE Grade ALTER TestType SET DEFAULT [];

ALTER TestType SET CHECK testtype="".OR.testtype=

"".OR.testtype="".OR.testtype="";

ERROR [];

ALTER IsTest DROP DEFAULT

4-20GradeIsTestNoTest.F.

xsglxt

ALTER TABLE Grade RENAME COLUMN IsTest TO NoTest ALTER NoTest SET DEFAULT .F.

ALTER TABLE Grade ALTER IsTest SET DEFAULT .F. RENAME COLUMN IsTest TO NoTest

4-21Grade

DRPO TABLE Grade


[TOP nExpr [PERCENT]]TOPORDER BYORDER BYTOPnExpnExp %1~32767

[Alias.Select_Item]Select_ItemSelect_Item

FROM

[AS Column_Name]Select_Item

FROMVFP6


[FORCE]VFP6FROM

[DatabaseName!]

Table [[AS] Local_Alias]Select

INNER JOIN

LEFT [OUTER] JOINJOIN

RIGHT [OUTER] JOINJOIN

FULL [OUTER] JOINJOIN

[DatabaseName!]Table [[AS] Local_Alias]


ON JoinCondition

[INTO Destination]INTOTOTOINTO

Destination

ARRAY ArrayName

CURSOR CursorNameVFP6SELECT

DBF TableName|TABLE TableNameSET SAFETYOFFVFP6SELECT

[TO FILE FileName [ADDITIVE] | TO PRINTER [PROMPT] | TO SCREEN]TOINTOFileNameASCIIADDITIVE


[PREFERENCE PreferenceName]

[NOCONSOLE]VFP6

[PLAIN]

[NOWAIT]

WHERE JoinConditionFROM.AND.FieldName1ComparisonFieldName2

FieldName1FieldName2Comparison

===LIKE<>!=#>>=<<=

FilterCondition


[GROUP BY GroupColumn]GroupColumnSQL

[HAVING FilterCondition]GROUP BY GroupColumn

[UNION [ALL] SELECTCommand]SELECTSELECTALLUNION

[ORDER BY Order_Item ]Order_Item

1

4-22Student1981

SELECT Student_ID AS ,Name AS ,Sex AS ;

FROM xsglxt!Student;

WHERE Year(Birthday)>=1981


2

4-23StudentScore

SELECT Student.Name AS ,Sex AS ,;

Score.,Score.;

FROM xsglxt!Student INNER JOIN xsglxt!Score;

ON Student.Student_ID=Score.Student_ID

3

4-240001

SELECT Student_ID ,Name,Classes FROM Student ;

WHERE Student_ID IN (SELECT Student_ID FROM Grade ;

WHERE Course_ID ='0001')


4COUNT()SUM()AVG()MAX()MIN()

4-25Score

SELECT SUM() AS ,AVG() AS ,;

MAX() AS ,MIN() AS ,;

COUNT(RECNO()) AS FROM Score

5GROUP BY

4-26

SELECT Score., Student.student_id, Student.classes;

FROM xsglxt!score INNER JOIN xsglxt!student ;

ON Score.student_id = Student.student_id;

INTO CURSOR CursorTab

SELECT MAX(),MIN(),SUM(),;

AVG(),Classes AS ;

FROM CursorTab ;

GROUP BY CLASSES


6

4-2790

SELECT Student_id AS ,Name AS ;

FROM Student ;

WHERE Sex=[] ;

UNION ;

SELECT Student_id AS ,Name AS ;

FROM Score ;

WHERE >90

SELECTSELECTunionintersectminus

90union


4.6.3 SQL

1

INSERT INTO Tablename [(Fieldname1 [,Fieldname2, ...])]

VALUES (eExpression1 [, eExpression2, ...])

INSERT INTO Tablename FROM ARRAY ArrayName | FROM MEMVAR

INSERT INTO TablenameTablenameVFP6

[(Fieldname1 [,Fieldname2, ...])]INSERT-SQL


VALUES (eExpression1 [, eExpression2, ...])Fieldname1 [,Fieldname2, ...]SET NULLONINSERT-SQLnullVALUES

FROM ARRAY ArrayNameFROM ARRAY

FROM MEMVAR

4-28INSERTSQLStudent


INSERT INTO Student (Student_ID, Name, Sex, Birthday, Classes,;

Dormitory, Phonenumber,Age);

VALUES(1999041002,,,{^1980/03/22},;

"99","3-311","2356306",20)

INSERT INTO Student VALUES(1999041002,,;

"",{^1980/03/22},"99","3-311","2356306",20)

2

UPDATE [DatabaseName1!]TableName1

SET Column_Name1 = eExpression1[, Column_Name2 = eExpression2 ...]

WHERE FilterCondition1 [AND | OR FilterCondition2 ...]

WHERESETeExpression1Column_Name1WHERE


4-29990

UPDATE Score SET =0 ;

WHERE Student_ID IN (SELECT Student_ID FROM Student ;

WHERE Student.Classes=[99])

3

DELETE FROM [<cDatabaseName !>] <cTablename>

WHERE FilterCondition1 [AND | OR FilterCondition2 ...]

wherewhere

4-30goods(gid,num,)order_form(gid,num,)

DELETE FROM Order_form ;

WHERE Order_form.num>(SELECT Goods.num FROM Goods ;

WHERE Order_form.gid=Goods.gid)


1SORT

2

3INDEX

4LOCATEFINDSEEKGETEXPR

5COUNTSUMAVERAGE

6USEINALIAS

7SELECT

8SET RELATIONSET SKIP

9JOIN

10SQL4

11CREATE TABLE CREATE CURSOR ALTER TABLE

12SQLSELECTSELECT-SQL

13SQLINSERT INTOUPDATEDELETE FROM


5 VFP6

1

2

3


5 VFP6

5.1 VFP6

5.2 VFP6

5.3 VFP6

5.4


5.1.1 VFP6

VFP6

VFP

*

*L501.PRG

CLEAR

CTALK=SET("TALK")

SET TALK OFF

INPUT "=" TO R

S=PI()*R*R

? ""+ALLTRIM(STR(R))+"=",S

SET TALK &CTALK

RETURN


1VFP

12048

2;

3

2


37

VFP6


5.1.2 VFP6

1

VFP6EnterEnter

1

2Enter


VFP6

VFP6

2

1VFP6ASCIIVFP6

MODIFY COMMAND <>

MODIFY COMMAND [<>/]


5-2VFP6

VFP6

MODIFY COMMAND L501

Ctrl+WL501.prg


2

DO <>

.PRG

DO L501

3

Ctrl+WCtrl+Q


4

MODIFY COMMAND <>

MODIFY COMMAND


3

VFP6VFP6

VFP6

VFP6

(1) 5-1VFP6

(2)

VFP


5-1 VFP6


Tab

5-2ClickClickClickClickClick

5-3MouseMove

5-2


5-3 MouseMove

MouseMoveMouseUpMouseUp


3VFP6

VFPVFPVFP5-4

5-4 VFP


4VFP6

VFP6


5.2 VFP6

5.2.1 VFP

5.2.2

5.2.3

5.2.4


5.2.1 VFP

1

1

ACCEPT [<>] TO <>

VFP

[<>]

[<>]ACCEPTEnter


VFP6ACCEPT

<>ASCII

5-3

MODIFY COMMAND L503

(.PRG)


Ctrl+ W

CLEAR

SET TALK OFF

ACCEPT "" TO FileName

USE (FileName)

LIST

USE

RETURN

FileName

2

ACCEPT

INPUT[<>] TO <>


VFP

[<>]

[<>]VFP

INPUTACCEPT

<>

INPUTACCEPTACCEPTINPUTVFPACCEPTINPUT


5-4

*L504.PRG

CLEAR

CTALK=SET("TALK")

SET TALK OFF

INPUT "=" TO R

S=PI()*R*R

V=4/3*PI()*R**3

? "=",S

? "=",V

SET TALK &CTALK

RETURN

DO L504

10Enter

=

10

= 314.16

= 4188.790205


3

WAIT<>[TO <>]

ACCEPTTO <><>

WAIT

YNYN


2

???

@ <, > SAY <>

<>

3

1

Esc

Resume


Esc

SET ESCAPE OFF

EscEsc

CANCEL

SUSPEND

|RESUME


2

NOTE/ * <>

&& <>

NOTE*&&

USE STUDENT &&STUDENT

3

<>

TEXT

<>

ENDTEXT


5.2.2 VFP6

VFP

5-510005%100010%

*L505

CTALK=SET("TALK")

SET TALK OFF

SCAN

IF >=1000

REPLACE WITH *1.05

ELSE

REPLACE WITH *1.1

ENDIF

ENDSCAN

SET TALK &CTALK

RETURN


1

2

5-6VFP6

1

VFP

IF <>

<1>

[ELSE

<2>]

ENDIF

1

2

5-6


<><>IF<1><>ELSE<2><2><>ELSE<2>IFENDIFENDIF

IFENDIFIFENDIF

5-51000>=1000<1>REPLACE WITH *1.0510005%1000


>=1000<2>REPLACE WITH *1.1100010%

2

CASE <1> <1> VFP<><>CASEOTHER-WISEENDCASE

DO CASE

CASE <1>

<1>

[CASE <2>

<2>

CASE <N>

<N>]

[OTHERWISE

<N+1>]

ENDCASE


ENDCASE

CASE <><>

5-6

CLEAR

AA=INT(RAND()*10) &&10

DO CASE

CASE AA=0

? 0

CASE AA=1

? 1

CASE AA=2

? 2

CASE AA=3

? 3

OTHERWISE

? 3

ENDCASE


2

VFP

1DO WHILE

DO WHILE <>

[<>]

[EXIT]

[LOOP]

ENDDO

<>DO WHILEENDDO<>

[<>]<>


VFP

[LOOP]DO WHILELOOPDO WHILEENDDO

[EXIT]DO WHILEENDDOENDDOEXITDO WHILEENDDO

ENDDODO WHILE

5-71000

STORE 0 TO AA,BB

DO WHILE AA<=1000

BB=BB+1

AA=AA+BB

ENDDO

? BB

45


5-8N7101

STORE 0 TO AA,BB &&

DO WHILE .T.

BB=BB+1

IF MOD(BB,7)=0 &&BB7

LOOP &&BB7BB1

ENDIF

AA=AA+BB &&BB7

IF MOD(AA,101)=0 &&AA101

EXIT &&AA101

ENDIF

ENDDO

? BB,AA

20718483


2FOR

FOR <>=<> TO <> [STEP <>]

<>

[EXIT]

[LOOP]

ENDFOR/NEXT

<>FORENDFOR

<> TO <><><>

[STEP <>]<>STEP1

<>VFP


[EXIT]ENDFORFORENDFOREXIT

[LOOP]FORLOOPENDFORENDFORFORENDFORLOOP

FORENDFORVFPENDFORNEXTFORVFP<><>

5-91100

AA=0

FOR II=2 TO 100 STEP 2

AA=AA+II

ENDFOR

? AA

2550


3

SCAN [<>] [FOR <>] [WHILE <>]

[<>]

[LOOP]

[EXIT]

ENDSCAN

[<>]SCANALL

[FOR <>]FOR

[WHILE <>]

[<>]VFP


[LOOP]SCANLOOPSCANENDSCAN

[EXIT]SCANENDSCANENDSCANEXITSCANENDSCAN

ENDSCANSCAN

SCAN

5-10STUDENT

USE STUDENT

SCAN FOR =

DISP

WAIT

ENDSCAN

USE

USE STUDENT

SCAN

IF #

LOOP

ENDIF

DISP

WAIT

ENDSCAN

USE


5.2.3

1

RETURN

DO

DO <> [IN <>][WITH <>]

WITH

<> VFPVFPSET PROCEDURE


.FXP.PRG.FXP

DOVFP

IN <> <>

[WITH <>]<>27


*MYSUB.PRG

PROCEDURE MYSUB

PARAMETERS R,S

S=PI()*R^2

RETURN

5-11MYMAIN.PRGMYSUB.PRG

*MYMAIN.PRG

CTALK=SET("TALK")

SET TALK OFF

CLEAR

STORE 0 TO RR, AREA

DO WHILE .T.

INPUT " " TO RR

DO MYSUB WITH RR, AREA

? ""+ALLTRIM(STR(RR))+"", AREA

WAIT "Y/N" TO ANSWER

IF UPPER(ANSWER)="Y"

LOOP

ELSE

EXIT

ENDIF

ENDDO

SET TALK &CTALK


2

1

MODIFY COMMAND <>

PROCEDURE <>

<>


PROCEDURE <1>

<1>

RETURN

PROCEDURE <2>

<2>

RETURN

PROCEDURE <N>

<N>

RETURN

128

2

1

SET PROCEDURE TO <>


VFP6VFP6SET PROCEDURE.FXP.PRG.FXP

2

CLOSE PROCEDURE

3

RETURN [<>/TO MASTER/TO <>]


[<>]RETURN

[TO MASTER]

[TO <>]

RETURN5-7


MYPROCED

5-12MYPROCED.PRGMYMAIN.PRG

*MYMAIN

CLEAR

TEXT

1--2--3--4

21015

ENDTEXT

CTALK=SET("TALK")

SET TALK OFF

SET PROCEDURE TO MYPROCED

DO WHILE .T.

ACCEPT "" TO SELECT

PROGNAME="PROGRAM"+SUBSTR(SELECT,1,1)

IF (SUBSTR(SELECT,1,1)="1".OR. SUBSTR(SELECT,1,1)="3").AND.

OCCURS(",",SELECT)#1.OR.SUBSTR(SELECT,1,1)="2".AND.

OCCURS(",",SELECT)#2.OR.SUBSTR(SELECT,1,1)>"4";

.OR.SUBSTR(SELECT,1,1)<"1"


WAIT WINDOW AT 15,20 " " NOWAIT

LOOP

ELSE

IF SUBSTR(SELECT,1,1)="4"

EXIT

ENDIF

ENDIF

IF OCCURS(",",SELECT)=1

POSITION=ATC(",",SELECT,1)

AA=VAL(SUBSTR(SELECT,POSITION+1,LEN(SELECT)-POSITION))

DO (PROGNAME) WITH AA

ELSE

POSITION1=ATC(",",SELECT,1)

POSITION2=ATC(",",SELECT,2)

AA=VAL(SUBS(SELECT,POSITION1+1, LEN(SELECT)-POSITION1))

BB= VAL(SUBS(SELECT,POSITION2+1,LEN(SELECT)-POSITION2))

DO (PROGNAME) WITH AA,BB

ENDIF

ENDDO

CLOSE PROCEDURE

SET TALK &CTALK

RETURN


MYPROCED

*MYPROCED

PROCEDURE PROGRAM1

PARAMETERS R

S=PI()*R^2

? ""+ALLTRIM(STR(R))+"",S

RETURN

PROCEDURE PROGRAM2

PARAMETERS LONG,WIDTH

S=LONG*WIDTH

? ""+ALLTRIM(STR(LONG))+""+ALLTRIM(STR(WIDTH))+;

"",S

RETURN

PROCEDURE PROGRAM3

PARAMETERS R

N=1

T=1

DO WHILE N<=R

T=T*N

N=N+1

ENDDO

? ""+ALLTRIM(STR(R))+"",T

RETURN


3

5-1330

*MYMAIN.PRG

CTALK=SET("TALK")

SET TALK OFF

SET PROCEDURE TO MYSUB

INPUT 30 TO NUMBER

II=1

DO MYSUB WITH NUMBER,II

CLOSE PROCEDURE

SET TALK &CTALK

RETURN

*MYSUB.PRG

PROCEDURE MYSUB

PARAMETERS MM,NN

IF MM>1

DO MYSUB WITH MM-1,NN &&

NN=NN*MM &&

ENDIF

? STR(MM,2)+=+STR(NN,10)

RETURN


5.2.4

1

FUNCTION <>

PARAMETERS <>

<>

RETURN <>

<><>RETURN <><>


5-14PRODUCT()

*PRODUCT.PRG

FUNCTION PRODUCT

PARAMETERS MM,NN

IF TYPE("MM")="L".OR.TYPE("NN")="L"

=MESSAGEBOX("",64,"PRODUCT()")

RETURN .F.

ELSE

IF MM>NN

=MESSAGEBOX(1+

CHR(13)+"2",64,"PRODUCT()")

RETURN .F.

ENDIF

ENDIF

TT=1

DO WHILE NN>=MM

TT=TT*MM

MM=MM+1

ENDDO

RETURN TT


2

<>(<>)

PARAMETERS <><>


5.3 VFP6

5.3.1

5.3.2

5.3.3

5.3.4

5.3.5

5.3.6

5.3.7

5.3.8


5.3.1

5.3.2

VFP6



5.3.3

VFP6

cTest=123_456_7 8 9_0

1

SUBSTR()

? Substr(cTest,1,1)

? Substr(cTest,4,1)

? Substr(cTest,10,1)

? Substr(cTest,11,1)

1

-

8


15FORFOR1SUBSTR()

FOR II=1 TO 15

?? SUBSTR(cTest,II,1)

ENDFOR

L508.PRG

123_456_7 8 9_0

2

? ISDIGIT(2)

.T.

? ISDIGIT(_)

.F.

? ISDIGIT(SUBSTR(cTest,10,1))

.F.


3

cNumbVar=

FOR

cCharacter=SUBSTR(cTest,II,1)

cNumbVar=cNumbVar+ cCharacter

cNumbVar=

FOR II=1 TO 15

cCharacter=SUBSTR(cTest,II,1)

IF ISDIGIT(cCharacter)

cNumbVar=cNumbVar+ ccharacter

ENDIF

ENDFOR


5.3.4

cNumbVar=

FOR II=1 TO 15

cCharacter=SUBSTR(cTest,II,1)

IF ISDIGIT(cCharacter)

cNumbVar=cNumbVar+ ccharacter

ENDIF

ENDFOR

? cTest

? cNumbVar

123_456_7 8 9_0

1234567890

cTest=123_456_7 8 9ab0

123_456_7 8 9ab0

123456789

FOR1516


FORVFPLEN()FOR

cNumbVar=

FOR II=1 TO LEN(cTest)

cCharacter=SUBSTR(cTest,II,1)

IF ISDIGIT(cCharacter)

cNumbVar=cNumbVar+ ccharacter

ENDIF

ENDFOR

? cTest

? cNumbVar

123_456_7 8 9ab0

1234567890

cTest="123_456_7 8 9ab0cd1e2 3"

123_456_7 8 9ab0cd1e2 3

1234567890123


5-9

5.3.5

STUDENTSTUDENT5-9

REPLACE


REPLACE WITH cNumbVar

SCANENDSCANcTest

SCAN

cNumbVar=

FOR II=1 TO LEN()

cCharacter=SUBSTR(,II,1)

IF ISDIGIT(cCharacter)

cNumbVar=cNumbVar+ ccharacter

ENDIF

ENDFOR

REPLACE WITH cNumbVar

ENDSCAN


5-10 STUDENT

5.3.6

STUDENT

5-9


5.3.7

STUDENTSTUDENT

ACCEPT TO TABNAMESR

LtableOK=.F. &&

&&.F.

LfieldOK=.F. &&

TABNAME= &&

IF AT(.,TABNAMESR)=0

TABNAME=TABNAMESR+.DBF &&


ENDIF

DO WHILE .T.

IF FILE(TABNAME) &&

USE (TABNAME) &&

LtableOK=.T. &&.T.

EXIT &&

ELSE

=MESSAGEBOX(,64,)

USE ? &&

IF USED() &&

EXIT &&

ENDIF

ENDIF

ENDDO

*

*LfieldOK.T.EXIT

*LfieldOK.F.

FOR II=1 TO FCOUNT()

IF FIELD(II)=.AND.TYPE()=C

LfieldOK=.T.

EXIT


ENDIF

ENDFOR

IF LtableOK.AND. LfieldOK

SCAN

cNumbVar=

FOR II=1 TO LEN()

cCharacter=SUBSTR(,II,1)

IF ISDIGIT(cCharacter)

cNumbVar=cNumbVar+ ccharacter

ENDIF

ENDFOR

REPLACE WITH cNumbVar

ENDSCAN

ENDIF


5.3.8

5-15

FUNCTION NUMBERONLY(CMIXEDVAL)

cNumbVar=

FOR II=1 TO LEN(CMIXEDVAL)

cCharacter=SUBSTR(CMIXEDVAL,II,1)

IF ISDIGIT(cCharacter)

cNumbVar=cNumbVar+ ccharacter

ENDIF

ENDFOR

RETURN cNumbVar

ENDFUNC

SCAN

REPLACE FIELDNAME WITH NUMBERONLY(FIELDNAME)

ENDSCAN

REPLACE ALL FIELDNAME WITH NUMBERONLY(FIELDNAME)


5.4

VFP6

5.4.1

5.4.2

5.4.3


5.4.1

VFP6VFP6

1VFP6

VFP6VFP6


5-2

5-2VFP

VFP5-3

5-3VFP

ParentClass


2

VFPVFPVFP6

1VFP6


2

3

26


5.4.2

VFP6


WindowsVFP6

VFP65-4VFP6

VFP6VFP6

Release

Object.Release


5-4VFP6


5.4.3

1

1|

2


NewToolBarToolBarc:\gxglxt\libs\gxglxt_app.vcx

3




5-15

4NewToolBar5-15

5-15NewToolBarCaption


Command1CaptionBFontBold.T.Command2CaptionIFontBold.T.FontItalic.T.Command3CaptionUFontBold.T.FontUnderLine.T.

Combo1|RowSourceType1RowSource


12ValueControlSourceValue

5

1Combo2Click Event


THISFORMSET.ActiveForm.ActiveControl.FontName=THIS.VALUE

2Combo3Click Event

THISFORMSET.ActiveForm.ActiveControl.FontSize=;

VAL(ALLTRIM(THIS.VALUE))

3Command1Click Event

THISFORMSET.ActiveForm.ActiveControl.FontBold=;

!THISFORMSET.ActiveForm.ActiveControl.FontBold

THIS.FontBold=THISFORMSET.ActiveForm.ActiveControl.FontBold

4Command2Click Event

THISFORMSET.ActiveForm.ActiveControl.FontItalic=;

!THISFORMSET.ActiveForm.ActiveControl.FontItalic

THIS.FontItalic=THISFORMSET.ActiveForm.ActiveControl.FontItalic

5Command3Click Event

THISFORMSET.ActiveForm.ActiveControl.FontUnderline=;

!THISFORMSET.ActiveForm.ActiveControl.FontUnderline

THIS.FontUnderline=THISFORMSET.ActiveForm.ActiveControl.FontUnderline

6Combo1Click EventVFP


2

|



1VFP6

2Modify Command

3Do

4IfEndifDocaseEndcaseDo WhileEnddoScan EndscanForEndfor

578

6

7


6

1

2

3

4

5

6


6

6.1

6.2

6.3

6.4

6.5


6.1

6.1.1

6.1.2


6.1.1

GXGLXTStudent0499


GXGLXTStudent


Student.

0

4

9

8



1

2

3

4


.QPR


Stud_query


6.1.2

Grade Grade



1

2254

3


1

2

3

4

5


.QPR

.NULL.

NULL


Grad_Query

.NULL.,


6.2

6.2.1

6.2.2

6.2.3

6.2.4

6.2.5

6.2.6

6.2.7

6.2.8


6.2

VFP6

Grad_Query

1

2


|

CREATE QUERY


1

2

3

4SET FILTER TO

5

1

2

3

4

5

6


6.2.1

GXGLXTStudentGradeCourses99049804

GXGLXTStudentGrade

Courses


VFP6


1Inner Join:

2Right Outer Join

3Left Outer Join:

4Full Join

1=


2LIKEStudent. LIKE 99049904

3==

4>

5>=

6<

7<=

8Is NullNull

9Between


10IN

.NOT..AND..OR.

1

2.T.

3

4


6.2.2

Student.Student.Courses.Grade.

Student.Courses.Grade.


6.2.3

99049804

Grade.=1


ANDStudent.In9904,9804,En

6.2.4


Student.


6.2.5

SUM()COUNT()AVG()


1

2AVGexpNGradeAVG(Grade.)Grade

3

4Grade.


6.2.6

SQLDistinct


XY

Student.Student.Courses.Grade.Grade.


6.2.7


.DBF

Microsoft GraphVFP6

VFP6

.FRX

.LBX

1


6.2.8

DO .qpr

1|1


6.3

6.3.1

6.3.2


6.3.1

1

1

2

1


1

2

3

1

2

3

4

1

2

3


1

1


2

3

4

5

6

7

GradeCourses1

Grade

Courses

2


2

1

2

3

2a


2a

Grade

Courses

3


3

4


4

4a


4a

5

5

1


2

1


|

||

|


SQL

/SQLSQL

/


2

ClasszcDepartment


GXGLXT

Classzc



Classzc.Classzc. Classzc.Classzc.Classzc.



3

3


DepartmentClasszcStudentCoursesGrade3


4



SQL

3


SQL WHERE

WHERE

WHERE

WHERE

WHERE

SQL DELETEINSERT

SQL UPDATE

6.5


6.3.2

1

ODBC

|


1

2

3

4

5

6

7

ODBCODBCVFP TablesVFP


DatabasesPathBrowse


2



Visual FoxPro DatabaseConfigure Connection

BrowseSelect Database


Configure ConnectionPath\\092\FOXPRO\Visualfp.dbcOK

1



3

VFP

SQL WHERE VFP

SQL WHERE

UPDATEDELETEWHEREVFPWHERE


4

1


SQL

SQL DELETEINSERTSQL UPDATE

2

VFP


5

ODBC

ODBC

VFPVFPODBC

1


VFP

ODBC

VFP


Data Sources

2ODBC

VFPODBC

VFP ODBCID

VFP

3

DBSETPROP( )

Asynchronous

Disp


warning

BatchMode

Transactions

4

DBSETPROP( )

ConnectTimeout

QueryTimeout

IdleTimeout

VFPSQLWaitTime


6.4

6.4.1

6.4.2

6.4.3

6.4.4

6.4.5

6.4.6

6.4.7


6.4.1

USE

USE

c:\gxglxtgxglxt1

open database c:\gxglxt\gxglxt

use 1


browse

VFP6Close All112|


6.4.2

NODATAUSE

open database c:\gxglxt\gxglxt

use 1 nodata in 0

Select 1

browse

1NODATAVFP61.F. WHEREWHERE


6.4.3

RENAME VIEW

RENAME VIEW

21

rename view 1to 2

6.4.4

DELETE VIEW


DELETE VIEW

xsglxt2

delete view2

6.4.5

INDEX ON


6.4.6

VFP

1


2

3

4

1ClasszcStudentCourseGrade. Classzc.Classzc.Student.Student.Course.Grade.Grade.7

2 Classzc.=?Grade.=?

3|


4|

05"1"


6.4.7

3


Grade

Grade++

||041


3

6299


Grade

99

99

Grade


6.5

1MIS990520

2

Visual FoxPro


6.6.1

.DBF

CREATE SQL VIEWCREATEOFFLINE()studentgrade

CREATE SQL VIEW test1

CONNECTION 1

AS SELECT * FROM student INNER JOIN grade;

ON student.=grade.;

CREATEOFFLINE(test1)


6.6.2

1

test1

USE test1

2

ADMINUSEtest1

USE test2 ADMIN


1VFP6

2.QPRDO

3

4

5

6

7

8

9

10SQL-SELECTSQLSQL


  • Login