Você está na página 1de 10

FOXPRO 2.

6 COMMANDS
COMMON CAMMANDS USED FOR DATABASE

1) CREATE This command is used to create the database using FoxPro. Syntaxt create NCIT When you give create command it immediate a dialog box to create a database fields (headings of the columns). It has following options Name to specify the name of the field Type to specify the type of the field like Character/Numeric/Date/Float Width the length of the field data. Dec - if you want to use the number with decimal points. It has two command buttons Insert to insert a new field. Delete to delete the existing field.

After specifying the field names then press OK button When you press the OK button (It will show a message box INPUT DATA RECORDS NOW? If you want to insert the records according to the database fields) Insert the records of the database.

2) LIST This command is used to see the data of the database table created SyntaxList

3) GOTO This command is used to navigate (to go to any record) in the database. A DISPLAY command follows the GOTO command

GOTO TOP It is used to go to the first record of the database. SyntaxGoto top display

GOTO BOTTOM It is used to go to the last record of the database. SyntaxGoto bottom

display

GOTO 3 It is used to go to the 3rd record of the database. SyntaxGoto 3 display

Using NEXT with GOTO. The NEXT command with the GOTO command is used to see the next number of records of the database. SyntaxGoto 3 Display next 2

4) BLANK This command will empty the record. SyntaxGoto 3 Blank This will empty the 3rd record. SyntaxGoto 3 Blank next 4 This will empty the next 4 records.

5) SKIP This command will leave the record. SyntaxGoto 3 Skip 3 Display This will show the seventh record of the file.

6) BLANK This command will insert a blank record. SyntaxGoto 3 Insert blank Display This will insert an extra blank record.

7)DELETE This command is used to delete the records from the database. The deleted records will be shown with the * sign. The deleted records will be undeleted. Syntax Goto 3 Delete Or SyntaxGoto 3

Delete next 3

8) RECALL This command is used to undelete the deleted records. Syntax Goto 3 Recall Or SyntaxGoto 3 Recall next 3

9) PACK This command is used to delete permanently any record. This command is used after the delete command. Syntax Goto 4 Delete Pack Or Syntax Goto 4 Delete next 3 Pack 10) ZAP This command is used to delete the records permanently from the database. Syntax Zap

11) EDIT This command is used to edit the records of the database this command will only edit the records. We cannot insert new records with it. SyntaxEdit Or Syntax Goto 4 Edit

12) APPEND This command is used to insert new records in the database. SyntaxAppend

13) MODI STRU This command is used to change the fields or enter new fields for the records in the database. Syntax Modi stru This command will open the early option of the fields. This will open an dialog box asInsert to insert the new field. Delete to delete the field.

You can also move the field from their positions.

14) BROWSE This command shows the database in the tabular form you can also edit the records from the database.

SyntaxBrowse

BROWSE NOEDIT This command stop to edit the records. But we can delete the records by Ctrl+t.

BROWSE NODELETE This command stop to delete the records.

DIRECT USE OF THE COMMANDS Syntax Edit for name=Aman Or Edit for rollno=3 This will edit the specified record. Syntax delete for name=Aman Or delete for rollno=3 This will delete the specified record. Syntax recall for name=Aman Or recall for rollno=3 This will recall the specified record.

Inbuilt Functions

Date and time functions We use the ? sign before the functions? date() This command shows the system date. ? time() This command shows the system time ? cdow(date()) This will show the current Day name. ? month(date())

This will show the months number. ? year(date()) This will show the current year. ? DBF() This will show the current opened database file name. ? version() This will show the version of the FoxPro database system.

String functions a=NCIT Technology ? len(a) This will show the length of the string. ? left(a,3) This shows the 3 letters of the string from the left side. eg- NCI ? right(a,3) This shows the 3 letters of the string from the right side. eg-ogy ? substr(a,6,12) This will show the string from the middle by given location. It will start from the 6 letter to the 12th letter. eg- Techno ?upper(a) NCIT TECHNOLOGY This will convert the string to the uppercase letters. ?lower(a) This will convert the string to the lower letters. eg- ncit echnology? proper(a) This will convert the string to the suitable case. ?at(Tech,a) Ans 6 ? stuff(a,6,15,Devigarh) This command replace the text on the given location and enter the new text. NCIT Devigarh ? OS() This will show the DOS Operating System version.

Arithmetic Functions

a=20 b=35 c=a+b ?c This will return the value of c 66 after adding two variables. ? pi() This will return the pi value.

a=8343.999 ?int(a) This will return the integer part of the value.

eg- 8343

?round(a,2) This will reduce the decimal places of the value to the 2 digits. Eg -8343.99

?sin(a) This will return the sin value of a.

?cos(a) This will return the cos value of a.

?tan(a) This will return the tan value of a.

Here is brief overview and example usage of the basic FoxPro commands like Append, Set, Record, Go to, Skip, Edit, List, Display, Browse and Replace.

1.

2.

Append command is used to add new record in the table. Set status on displays status bar at the bottom of the screen. It shows the screen active database file, the current record pointer position, number of records in the database file. And the command used to close the status bar is Set status off Set default to A is used to change the default root directory from C: drive to A: drive. Set carry on specifies static enter or duplicate for the present record into a new record when the append command is entered. Set carry off command is used to delete or to stop duplication. Dir command displays the database file.

3. Record Pointer:FoxPro marks its position with a table by means of a internal maker called the record pointer. A table first opens the Record Pointer normally pointing the first record in the table.

4. Go to:Go 2 command is used to show the positioning of the record pointer on the 2nd record. Go Top command moves the record pointer on first record. Go Bottom moves the record pointer on last record.

5. Skip
command moves the record pointer from the current location to next location. Skip 2 command jumps 2 record. Skip -2 goes back to 2 records, that is current record - 2. 6. ? RECNO() command displays the current record number.

7. Modify the Record:To modify data in the existing records the following commands can be used: --> EDIT displays the required record to be edited on the screen. EDIT fields stuno, stuname, fee: displays the above fields on the screen. EDIT For Fee >300 and Fee < 300 EDIT For DOJ = {06/11/09} displays data relating to that date of joining. EDIT for DOJ < {06/11/09} EDIT for DOJ > {06/11/09}

8. Viewing the Record:After adding the record to the table, the next logical step is to view the data. Data can be viewed with the list and display command with the command window.

Read more: http://tech-wonders.blogspot.com/2010/02/foxpro-commands-overview-appendset.html#ixzz1zegaDG60 Under Creative Commons License: Attribution

The default scope of the List command is to display all the record on the screen. The scope can be changed by using various options of the list command.

For example, --> LIST record 4 displays the record no. 4 --> LIST stuno, stuname, fee (field name) displays the said field names only. --> LIST stuname, Fee +50 displays the figures of student name adding 50 to the previous amount. LIST stuname, Fee -50 displays the figures deducting 50 from previous amount. Note: Val is used for the conversion of characters into numeric. LIST for Val (marks) > 50 LIST stuname, Fees x 2 multiplies LIST stuname, Fees / 2 divides LIST for Fees > 2450 displays the fees greater than the amount 2450. LIST for Fees > 2450 and < 4000 displays fee amounts that fall between 2450 and 4000. For 'and' condition all conditions should be satisfied. For 'or' condition any condition if satisfied it displays the data. LIST for stuname = "rao" displays rao's data only. Here strings used for characters only and for numbers there is no usage of any strings. LIST for stuname != "rao" or LIST for stuname <> "rao" displays data except rao's. LIST for stuname = "Raghu" and Fees >200 displays the data for Raghu if the fee is greater than 200. Here note that the character names are unique as in data. LIST for doj>{06/11/99} displays data of students joined after the specified date of joining (doj).

Display Command
Display command is somewhat similar to LIST command. Display All and List command are interchangeable. Both commands display the list of the records in the table. The default scope of the Display command is current record position. For example, using the command, go 6 Display we can display the 6th record. Disp all stuno, stuname, fees displays all the field names. Disp all stuno for course = "FoxPro" displays the number of students in foxpro course.

Set Headings:Set Headings off command displays the record without the field headings.Set Headings on command displays the records with field headings.

Set Print:The Set Print command sends output to the printer in addition to the screen. Set Printer on Set Printer to LPT1 ?Date() command displays the current date (mm / dd /yy) Set Date Japan ?Date() 00/07/25 Set Date Germany ?Date() 25/07/00 Set Date America ?Date() 07/25/00 Set Century on ?Date() 07/25/2000 Set Century off ?Date() 07/25/00 Set Century off LIST

Browse Command:It usually difficult to view a number of records on the screen at the same time. FoxPro browse mode displays the large amount of information at the same time. Browse displays the records shows in a spreadsheet format.

Browse fields stuno, stuname, fee Displays those fields only. New record is not acceptable but modifications only acceptable. Browse fields stuno, stuname, fee Freeze fee command restricts the edition of the specified field.

Replace Command:The replace command overwrites the contents of the specified fields in a table with new contents. It replaces the contents of only current record. For example, Replace all fees with fees + 50 command replaces all the fees adding amount 50 to all.
Read more: http://tech-wonders.blogspot.com/2010/02/foxpro-commands-overview-appendset.html#ixzz1zegMwC3z Under Creative Commons License: Attribution

Você também pode gostar