Working from the Command Window

Using the Command Window: When we made selection from the menu system, we saw that Visual FoxPro generated the relevant commands in the Command window. It may be easier to enter commands than to make selections from the menu system. Creating a New Table: To create a table file from command window, type the word CREATE followed by the name of the table file, and press Enter key. 1. Type CREATE and give file name and press Enter key in the command window. 2. Fill the structure in appeared table and click on OK button. 3. Visual FoxPro displays a dialog box and asks if you want to input data records now. 4. Give the answer. If answer is Yes then enter the records in table. 5. Press ^ + w keys to save the record. Modify the structure of a Table: From the command window we can modify the structure by typing the MODIFY STUCTURE command. 1. Type MODIFY STRUCTURE in the command window. 2. Move the pointer on the field, where we want to insert the new field. 3. Click Insert button. Now type the field name and enter the width. 4. Now we click Ok button to save the changes. 5. Click Yes to make changes permanent. Displaying and Editing Data: Working from the command window, we can USE a table and then type one of the following: • APPEND to display the table in Append mode. • EDIT or CHANGE to display the table in edit mode. • BROWSE to display the table in browse mode. • REPLACE to change the contents in more than one record. Append command: Syntax: APPEND [BLANK] [FROM <Filename> [FOR <expression>]] This command is used to add records to the active database file. If any file will not open then using this command will asked filename first. APPEND will gives us Data Entry Screen for continues entry (may be terminated by CTRL W). APPEND BLANK will add a blank record at the bottom of the screen. APPEND FROM <Filename> add records of a closed database file to the active database file. The structure of both of the files should be same, otherwise record nos. will increases but all or partially data will not include. If expression will add with Append From <Filename> then only those records will added who fulfill the given expression. Example: Use Kanak Append

Append From Kumar Append From Kumar For State="Bihar" Edit/Change command: Syntax: EDIT [FIELDS <Field List>] [condition] or CHANGE [FIELDS <Field List>] [condition] If we know the record number in advance, we can edit using EDIT command. For example: EDIT 5 We may also specify the field list, conditions and scope while giving EDIT command. For example: Use kanak EDIT FIELDS NAME, BRANCH, ROLL_NO FOR BRANCH = “computer science” Browse command: Syntax: - [BROWSE] [FIELDS <Field List>] [FREEZE] [WIDTH n] [Lock] This is a powerful editing command provide us facility to edit records horizontally with showing us multiple records at a time. Example: - Browse Browse Fields Name, Salary Browse Width 10 Browse Freeze Salary Replace command: Syntax: [REPLACE <field1> WITH <expr1> [, <field2> WITH <expr2> [<Scope>] [FOR <expL1>] This is a powerful editing command. This is used to replace a new value in a field with or without a condition. We can replace a new value in more than one record in same command line. Example: - Replace All Name with “Kanak” For Name=“Raja” Replace All Salary with Salary*1.1 for Salary < 5000 Delete and Recall commands: Delete command: - [DELETE] <SCOPE> [FOR <Expression>] [<Logical Operator> <Expression>] This command is used to mark the specified records for deletion. Delete does not remove records physically. It adds an astrick (*) sign along with those records you want to delete. Example: Delete All Delete Next 5 Delete Rest Delete Record 10 Delete All For State = "Bihar" Delete All For State = "Bihar" .And. City = "Patna" Delete All For Salary <=5000 Delete All For Male Delete All For Dob={10/10/80} Pack command: Syntax: [PACK]

Example: Zap Erase command: Syntax: [DELETE FILE <Filespec>] or [ERASE <Filename>] This command is used to delete a file physically with all that’s records and structure.Pack Zap command: Syntax: [ZAP] This command is used to erases all records of active database except its structure. The result of a DOS command appears in a separate Visual FoxPro RUN command window.Syntax: [LIST] [FIELD <Field List>] [FOR <Expression>] [<Logical Operator> <Expression>] [OFF] [TO PRINT] . For example: SET DEFAULT TO C: We can specify the full path name of a directory.This command is used to physically remove all those records which was marked for deletion. Example: Recall All Recall Next 7 Recall Rest Recall Record 7 Recall All For State = "Bengal" Recall All For State = "Bihar" .Dbf Erase Akshay. City = "Patna" Recall All For Salary <=5000 Recall All For Male Recall All For Dob={10/10/80} Run command: We can execute any DOS command or non Visual FoxPro program without quitting from Visual FoxPro. by using: SET DEFAULT TO C:\LEARNFOX\DATA Display and List command: List: . This is very dangerous command. Example: . A DOS command is by placing executed with RUN or exclamation mark (!) before writing the actual DOS commands. Remaining records will be copied to original file.And. so use it carefully because lost data can't be recovered. Example: .Delete File Akshay. Set Default: Visual FoxPro uses its default drive and directory for creating files.Dbf Recall command: Syntax: [Recall] <SCOPE> [FOR <Expression>] [<Logical Operator> <Expression>] This command is used to unmark the specified record which was marked for deletion. unless we specify the path separately.

) .And.) Display Structure (Display structure of active database. City = "Patna" List Off List Off Field Name. Example: Display All Display Next 5 Display Rest Display Record 10 Display All Field Name.Syntax: [DISPLAY] <SCOPE> [FIELD <Field List>] [FOR <Expression>] [<Logical Operator> <Expression>] [OFF] [TO PRINT] [FILES] [STRUCTURE] [MEMORY] [STATUS] [DELETED ()] This command is used to display the records and some other information. Salary List For State = "Bihar" List For State = "Bihar" .And. "TO PRINT" suffix is used for print information through printer if it is ON.Salary To Print List For Salary <=5000 List For Male List For Dob={10/10/80} List For Dob=CTOD("10/10/80") List For "Kumar"$ Name DISPLAY: .Salary Display All For State = "Bihar" Display All For State = "Bihar" . "OFF" suffix is used here for not print record no. "TO PRINT” suffix is used for print information through printer if it is ON.This command is used to see or print the contents of a database file.State To Print Display All Off Field Name.City.F_Name. "OFF" suffix is used here for not print record no.) Display Status (Display current status of FOXPRO.City.) Display Memory (Display Memory Variables.) Display For Deleted () (Display only those records which are marked for deletion. Example: List List Field Name. City = "Patna" Display All Off Display All Name.DBF files of current Path/Directory.Salary To Print Display All For Salary <=5000 Display All For Male Display All For Dob={10/10/80} Display All For Dob=CTOD("10/10/80") Display All For "Kumar"$ Name Display Files (Displays .F_Name.

They are generally used to find an individual record or to isolate records that meet certain criteria.Select only those records who fulfill both the conditions. .Sorting means grouping records in a particular order say ascending or descending based on a key field of the records.?IIF (Result = “P”. i. false.Select all those records who do not fulfill specified condition. :.Syntax : [SORT ON] <Field Name [/A] [/C] [/D]> [TO <New Filename>] This command is used to arrange the records of the active database file according to a field to another database file into ascending or descending order.Select all those records who fulfill either first or second condition. We can perform Sorting or Indexing tasks at the command level from Command window. The Syntax for this function: IIF (condition.Using Logical Expression: Logical expressions are either true or false. Mathematical Operators:Unary minus Exponentiation ^ or ** Division / Multiplication * Subtraction Addition + Relational Operators: > Less Than > Greater Than = Equal To <> Not Equal To # Not Equal To <= Less Than Or Equal To => Greater Than Or Equal To Logical Operators: 1. expression2) The IIF() function can save space in our programs. true or . “Pass”. Sorting a table: .e.e. . Example: In IF command: .T. :. .F. i. because in one line it can take the place of the IF…ELSE…ENDIF commands. . Logical Functions: Some functions also return . and third is the one returned if it false. 2.AND. “Fail”) Sorting and Indexing: We can arrange records in our table in a way that best suits our needs. although they are generally used in programming. expression1. Sort: . The first defines the logical condition.IF Result = “P” ? “Pass” ELSE ? “Fail” ENDIF In IIF() function: . the second is the expression returned if condition is true. The IIF() Function: IIF is the function from an IF…ELSE…ENDIF structure. Visual FoxPro has two commands for organizing records in a table namely SORT and INDEX. which has three parameters.NOT. 3. :.OR.

If any changes have been made to the table while the index file was closed. but has an ampersand (&) in front of it namely. .INDEX ON NAME TO NAMES Set Index: An index that has just been created is active. The parent table controls the child so that when we move the record pointer in the parent table. We will note that the indexed file on the right side of figure retains the original record number. Use of Macro: Macro substitution is a programming technique used in command files. &FLD etc. But by using the SET INDEX command.Dbf Index: . Table in a relational database is similar to the traditional file system with its records. The macro is just like an ordinary memory variable. It also defines relationships between two or more table.Syntax: INDEX ON <field expr> TO <.IDX file> | TAG <tag name> [OF <CDX file>] [FOR <condition>] [COMPACT] [ASCENDING/DESCENDING] [UNIQUE] [ADDITIVE] Example: . The number 2 here indicates the order in which the index file was originally opened. we can update with the REINDEX command. contain records and columns. it replaces that macro with the contents of the memory variable. we can activate any of the indexes. It rebuilds all open index files in the current work area.dbf Sort On Name/C To Nameasc. then records pointer moves to the end of the last record in child file. SET ORDER TO 2. original record no do not change.Indexing is a process of arranging records in a particular order. Example :- Working with Relational Databases in Visual FoxPro Working with Relational Databases in Visual FoxPro: A Relational database is defined as a database that allows us to group its data items into one or more independent tables that can be related to one another by using fields common to each related table. &NAME. fields and files. we use numbers such as. Use of Multiple Tables: Visual FoxPro is a relational database manager. If a matching record cannot be traced in the child table. When Visual FoxPro encounters a macro in command file. contain fields. called tuples.Using Visual FoxPro relational power. With SET ORDER. Visual FoxPro automatically moves the record pointer to the first corresponding record in the child table. Indexing a table: . Relating Files: . In a relation.Sort On Name To Rajiv. In indexing.Dbf Sort On Salary/D To Msal. Reindex: This command recreates all the open index files. The table’s rows. and hence gives us the choice to use one or more than one table at a time. called attributes. one table is called the parent table and the other is called as child table. we can create a relation to connect or join records from different tables and thus we can access their information at the same time. Set Order: To activate an index file use the SET ORDER command.Dbf Sort On Name/A To Rajiv.

highlight Wizards and choose Form. To select all the fields click the button. In Visual FoxPro. If we want a table other than this.A keyfield establishes relationship among two or more tables. . we will probably find it easier to store them all in one place. One table is considered as the parent table and another as the child table. the click button. which improves the performance.If we create an application that requires several tables. 3. Click Tools menu. the databases and Tables: area will show the current database. click on the small button to the right of Databases and Tables: area. In the dialog box that appears. (f) Relational model is very useful for representing most of the real world objects and the relationships among them. From the Available Fields: area. Creating a New Database in Visual FoxPro: . The fields of child table appear in a grid below the fields of parent table. views and relationships between the tables stored as a file with . 4. there are many corresponding records in the previous table. After this Wizard selection dialog box will appear. • Many to many – in this relationship . (e) In Relational database record relationship is implemented using primary key or composite key field. Now we choose One-to-Many Form Wizard and then click OK. • One to many – one to much relation ship is a relationship in which a record in one table has one or more related records in another table. Hence it is very simple and represents the logical relationship among the data items rather than physical relationship. select the field which we want in our form. a record n one table has many corresponding records in a second table and for every record in he second table.dbc extension. a database is a collection of tables. (d) Relational database is only concerned with data and not with the structures. There are three types of relationships that can be established among tables. The open dialog box will get opened and we can open the required table using the dialog box. 2. Entering and viewing data using the Form Wizard: The One-to-many wizard creates a form from related tables. (c) Relational database is much easier to use. (b) Relational database is very effective for small databases. These are: • One to one – It means that for every record in one table there a single corresponding record in another table. To run the One-to-many Form wizard 1. Relationships among Tables: .Advantage of Relational Database:(a) The relational database structure can be efficiently used even with a PC that has limited main memory and processing capability.

click the button. In the next dialog box that appears. In the Query Wizard dialog box that appears. Select a field from the Available fields: list and click the Add> button to move it to selected fields. Now we click on Next>. In the dialog box that appears. we click the Preview button to view the form before we exit the One-To-Many Form Wizard. 8. In the next dialog box. Click Tools menu. Now we select ●Ascending to sort the results in ascending order or ●Descending to sort them in descending order. The next step is to determine the order in which our Query results will be stored. In the screen that appears. Move the required fields from the Available Fields: area to the selected fields: area. highlights Wizards and choose Query. 9. . 3. we have to choose whether we want to include only related rows from both tables or all rows from either table. 6. select the fields based on which we want to sort the records in the parent table. Now we click on Next> button. Now we click on Next>. mention whether we want all the records or only a portion of the records. we can specify our criteria. Select an option to our choice from the dialog box that appears and click Finish button. We have chosen to view all the records. To remove a field from the selected fields. In the dialog box that appears. first select fields from one table. From the dialog box that appears. select fields from the other table and move these also to the selected fields: area. Now we click on Next>. In the Wizard selection dialog box that appears. 7. 9. select Query Wizard and Click OK. click the button. The button type: area specifies the form’s navigation buttons. Now we click on Next>. 2. 6. 10. The Wizard displays a picture in the magnifying glass as an example of the style which we highlight. we can select the fields that determine the relationship between the tables from the field lists. Now we click on Next> button. Otherwise select any of the listed options and click Finish. In the dialog box that appears. Query Wizard to work with Relational Database: 1. 7. Similarly. We can select up to three fields. 5.5. only related records are included. select the fields from the “child” table in the dialog box that appears. Similarly. Criteria are restrictions we place on a query or an advanced filter to identify the specific records we want to work with. 11. By default. After this we click on Next> button. Now we click on Next>. To remove all the fields. Now we select related fields from the field’s lists to determine the relationship between the two tables. select a style for the3 form. 8. from the style box. Now we click on Next> button. Then click Next>. 4.

Click Tools menu. Choose One-to-Many Report Wizard. Click the Browse button to display the table or view. 4. In the Wizard selection dialog box. to establish temporary relationships and to set work area properties. Click the open button. edit and/ or append data. the Expression builder will appear in which we can set relationship between the tables. 2. 5. currently selected. Click the One-To-many button to display the Create One-To-Many Relationships dialog box. in a Browse window where we can examine. Wrapping occurs when the number of selected cannot fit on a single line within the width of our report. Click Close button to Remove the selected table or view from the Aliases list. where we can establish a one-to-many temporary relationship between child and parent tables. an open dialog box will appear from where we have to open a table or view. To work with One-To-Many Report Wizard 1. This button gets enabled only when we establish relation between tables by selecting them in the View dialog box and then clicking Relations. 2. 3. A set Index Order dialog box will appear if no index order has already been set between the two tables. 3. Using Queries and SQL: . and define data filters. The Data Session window that appears is known as View window. To Work with the View Window 1. The Aliases area displays the view name or table name without the file extension.Using One-To-Many Report Wizard: The One-to-Many Report Wizard creates a Report that groups records from a parent table with records from a child table. The Current session: drop down list displays the name of the current data session. Click properties button to see the Work Area Properties dialog box. 8. 7. The rest of the steps are same as that of the form Wizard. The relations area indicates any temporary relationship established between the tables or views listed in the Aliases box. 6. If we do not want the fields to warp. In this dialog box we can modify the structure of a table. Click the Relations button to define the relations between tables or views. to add a table or view to the Aliases list. When we click OK. uncheck the checkbox. highlight Wizards and choose Report. Click Window menu and chose Data session. select index files and fields. In the last step Check the “Wrap fields that do not fit” checkbox if we do not want the fields to wrap. Using the View Window: The view window can be used to open and display tables. If no tables or views are listed.

English-like statement and performs very complex jobs to access information from very large size database. Views are less safe than Queries. deleting. A Query. Differences between Queries and Views are as follows: Queries Queries are simpler to create. f. the modifications made in a view get automatically reflected in the base tables. c. Defining the relationship between two or more tables. e. . modifiable. This includes maintaining database and manipulating the stored values to keep the information current. The syntax for the Visual FoxPro SQL SELECT statement is following: SELECT <field list> FROM <table list> TO <output option> WHERE <join criteria> GROUP BY <group column> HAVING <filter criteria> ORDER BY <order item> Clause Function SELECT Select the fields to be output FROM Specify the tables from which to retrieve information TO Determine where should output go WHERE Specify the primary section criteria GROUP BY Specify any groups HAVING Specify any secondary selection criteria ORDER BY Specify a sort order for the final output Queries versus View: Views are tables whose contents are taken or derived from other tables. Views Views are somewhat more than difficult to create than Queries. Both are created using the same method and both are used to retrieve data. can only work with native Visual FoxPro databases. This includes system security and authorization which must be controlled and maintained. Hence. Creating. Queries and Views are similar to each other in many ways. b. and modifying table structure. Purpose of using SQL:a. It is a very simple and powerful language because it uses compact. Inserting data into tables. d. Extracting data in meaningful ways based on the tables defined relationships that is accessing or retrieving data. Views themselves window through which certain contents of a table can be viewed. on the other hand.SQL (Structure Query Language) is a simple high level language that enables us to utilize a database completely and easily. Also. Outputs of Queries are read-only Views are not read-only which which ensures that data in a query means that data in a view is are not accidentally altered.

click OK. Working with Multiple Tables: Through Query Designer we work with multiple pages. These relational operators can be used with NOT operator to negate the logic. click the Insert button and to remove a selected join condition click the Remove button. The report button will direct the output into a visual FoxPro report or will create a quick report immediately. For specifying the criteria. Directing output: The default output for the query designer is the browse window. After selecting the output destination. The Query Designer refers to the way that Visual FoxPro allows us to get information from table.Queries perform slightly better than Views perform less better than Views. We can drag a field from one table to matching field in the other table to create further join conditions. 3. The table button will direct the output to a dbf file. To insert a join condition click the Insert button and to remove a selected join condition clicks the Remove button. The screen button will connect the output to an input/edit screen. Queries can be selected as input to graph. field name and criteria. cross-tab. > (more than) and < (less than). == (exactly like). The label button will direct the output to a label form. Select the matching fields from the two tables and specify whether we want Inner. select Add Table… In the Add Table or View dialog box that appears select the table which we want to use and click Add button. The graph button will connect the output with Microsoft graph wizard. Cursor is a temporary file which can hold the results of a query temporarily and the contents of which can be passed to another SQL statement. A join condition dialog box will appear. Query Designer: In Visual FoxPro. we create queries in special window called the Query Designer. . report and label Outputs of views are limited to creation. Queries. The browse button will direct the output to the browse window. We can specify other output destinations using the query destination button in the query designer toolbar. From the menu that appears. Browse windows and Screen Forms. It will guide us through the process of creating a rudiment graph. Join: In this tab we have to specify join type. The designer shows join condition by displaying lines that connect the matching fields between the two tables. The Query Designer is a versatile and powerful tool for retrieving information. To add a table to the Query Designer:1. we can use relational operators = (like). To insert a join condition. Left. Right click the top pane of the designer. Now the top pane of Query Designer displays two tables. Right or Full join. The cursor button will direct the output to a cursor. 2.

choose run query from the query menu. Syntax: SELECT COUNT <Distinct/*> FROM < Table name> ORDER BY: This command is used to sort in ascending or descending order in a particular field. Alternatively. select the field to be grouped from the available fields list and click add button. AVG. Similarly. Syntax: SELECT <Column name> FROM <Table name> WHERE <Condition> ORDER BY<Column to order> [<ASC/DESC>] . MIN and COUNT. one can also view the SQL code by selecting View SQL from the query menu. Running the query: To run our query. This will execute the SQL query we have built and send the results to the output destination which we have specified. A grouped query: Suppose we need to group the records on the basis of department. SUM: This function calculates the arithmetic sum of all selected values of a given column. click the maximize the table view button in the query designer toolbar. This is done by adding ORDER BY to the SELECT command. This can be done by clicking the having button. using the SQL button in the query designer toolbar. Syntax: SELECT MIN <Column name> FROM<Table name> Count: This function counts the number of rows in the output table. Syntax: SELECT <Column name> FROM <Table name> Where: Suppose we want to see only a certain number of rows that contain specific values. Syntax: SELECT <Column name> FROM <Table name> WHERE <Column name> <Operator> <Value> Aggregate functions: SQL Aggregate functions produce a single value for the entire group of table entries. These functions are SUM. we would need to place WHERE clause along with the SELECT statement. We can also specify the selection criteria for groupings. which must be present in every SELECT query. Maximizing the Table view: To maximize the top pane of the query designer window.Viewing SQL code: We can view the actual SQL code. Syntax: SELECT MAX <Column name> FROM<Table name> Min: This function calculates the smallest of all selected values of a given column. SQL select command: SQL SELECT command retrieves data from a table. Alternatively press ctrl + q keys to run the query. MAX. Syntax: SELECT SUM <Column name> FROM<Table name> AVG: This function calculates the average of all selected values of a given field. Syntax: SELECT AVG <Field name> FROM<Table name> MAX: This function calculates the largest of all selected values of a given column. For this. fields can be removing from the grouped fields list by clicking the remove button. Syntax: SELECT * FROM <Table name> From: From is the keyword in SQL.

This command removes specific rows meeting the condition and not the individual field values. Revoke etc. .dbc)” (iii) Now we select the location in “Look in: drop down list”. Visual FoxPro is such a database tool for managing relational databases. removing unwanted or outdated information. function (<Column>). arranging information in a desired order. Update. Updating data refers to inserting and deleting rows in tables and changing values in columns. just as the WHERE clause does for individual rows. <value> …) UPDATE Command: UPDATE is the SQL verb that changes or modifies data values in a table. SQL provides commands to update the data in a table. Syntax: SELECT <Column>. Also. we must be:(i) Go to File menu and choose open (ii) After appearing the open dialog box. (iv) Now double click the database. modifying existing information. functions (<Column>) FROM <Table> GROUP BY <Column> HAVING: The HAVING clause defines criteria used to eliminate certain groups from the output. listed in the blank rectangular area. Syntax: DELETE FROM <table name> WHERE <condition> GRANT command: This command is used to permit users access to the database. drop down list of “files of type” select “database (*. To open a database. Syntax: GRANT <privilege name> | ALL ON <object> TO <user | PUBLIC> [WITH GRANT OPTION] REVOKE command: This command is used to cancel database privileges from user. by entering open database <database name> in the command window. Opening a Database: Opening and existing Visual FoxPro database is as same as opening other files. This invokes command such as Insert. such as adding new information. INSERT INTO Command: INSERT INTO command adds new rows to a table. SQL can be used to define security mechanism or scheme for protecting data in a system from unauthorized access.GROUP BY: The GROUP BY clause allows us to form groups based on the specified condition. Delete etc. Syntax: UPDATE <table name> SET <column name = new column value> [WHERE <condition>] DELETE command: We can remove rows from a table with the command DELETE. This involves commands such as Grant. Syntax: REVOKE<privilege name> | ALL ON <object> TO <user | PUBLIC> Using Visual FoxPro Database: In a typical database. (v) Alternatively. Syntax: INSERT INTO <Table name> VALUES (<value>. we can also open a database. Syntax: SELECT <Column>. function (<Column>) FROM <Table> HAVING <Column> OTHER SQL Commands: Other than retrieving data. one needs to perform several operations.

use the import command in the command window. In the To: textbox.Closing a Database: To close all open databases we give following command in command window: Close databases: For close all open databases and tables. 2. specify the character using which we want to delimit strings of text in the output file. In the Form: drop down list. Click File menu and chose Export. type the path and name of the destination file. Syntax: import from <filename> [Database <database-name> [Name <LongTableName>]] [Type <file type>] Steps of exporting file:1. Close all: For close all open databases. Either type the full path and filename or click the button with three dots () to locate the file. This starts the Import Wizard which will guide us through a brief series of steps to import ASCII text files. The default text delimiter is the double quote (” “) character. Deleting a Database: We can easily delete a database by giving the following command. After Importing dialog box appearing. 6. 3. If we wish to import the text file click on the import Wizard button. Either type the full path and filename or click the button with three dots () to locate the file. tables. 3. If we have selected Microsoft EXCEL 5. into a Visual FoxPro. report designer. such as MSEXCEL or any other program such as Paradox it is in a table format. The default field separator is the comma (. Alternatively. 2. in the type: drop down list. 5. 4. another drop-down list called Sheet: appears. form designer. . query designer and label designer. Click File menu and chose Import. 4. 5. In the text delimiter: textbox. specify the path and name of the file to import. select the character which we want to separate data fields in the output file. from the Type: drop down list. Steps of Importing data:1.) character. After Export dialog box appearing. Click OK to import the file. specify the type of file to export.0 in the Type: drop-down list. Syntax: delete database <database_name> [delete tables] Visual FoxPro Utility Importing and Exporting Data using Wizard We can import data from a spreadsheet program. In this specify the excel worksheet to import. From the field separator: drop down list. specify the type of file to Import. To: textbox shows the path and filename of the table to which the file will import.

Through this option we can search for a particular text from here. use the export command in the command window. f. Memo editing window: In the memo edit window. d. we should be able to use all of Visual FoxPro’s text edit capability. Paste Special:-Through this option we can link or embedded on OLE object from the clipboard. e.Through this option we can copy of selected text from a field or file into the clipboard without removing it from the current location. Select All: .Through this option we can reverse using the Undo command can be redone. Cut: . In the Form: textbox. Edit Menu The options in Edit menu can be divided onto two sections-one for text editing(Cut. Undo: . Program files: Programs are edited in the program files. paste etc.Through this option we can remove selected text or data without placing on the clipboard. Alternatively. . Either type the full path and filename or click the button with three dots to locate the source file. c. Clear: . copy. from which it can be quickly recall. Edit window fields: Edit window is also an ideal place for text manipulation. Clicking Options… button will display the export Options dialog box where we specify which records and fields are to export. 7. The later portion of the edit menu involves OLE (Object Linking and Embedding) which allows us to connect data in software. Find: . Copy: . Insert Object and Links). Copy.6. Paste: .Through this option we can select all lines of text in the current editing window.Through this option we can reverse our last editing command.Through this option we remove selected text from the field or file into a section of memory called the clipboard.Through this option we paste while a piece of text is selected. Syntax: export to <filename> [Type <file type>] Editing Text We can enter and edit text in any of the following places: a. Click OK to export the file. b. Browse window fields: Browse window can also be used for editing text. the contents of the clipboard replace the selected text otherwise without selecting paste into current file at the cursor location. Form’s and menu’s code properties: Program codes can also be edited here. Redo: . Command window: Commands can be tried out in the command window and pasted into the program file. Paste. namely cut. Find and Replace) and the other for linking Visual FoxPro with another software(Paste special. specify the path and file name of the source file.

This dialog box will appear when we click the Browse. set color and font option including proposed automatic indentation of lines for all our future editing sessions. 10. alignment. 7.Through this option we can replace the specified string in the Look for: box with the string in the Replace With textbox. Replace: .Through this option we can locates the next occurrence of the string found previously with the Find option. 2. When we return the new object. Alternatively. If the object which we want to insert has not been created yet.Through this option we can specify whether we want a centre. Now we click on Ok. We will note that the toolbars and working environment of the application we choose appears within the Visual FoxPro window. Check the Link checkbox. if we want to link the Object and uncheck it if we want to embed the object. 3. The search continues forward from the cursor position. Additional commands are available on the Format menu that would vary according to what window we can work with. Font: . containing a general type field. double click it. Object: .This option provides us to editing a selected OLE object. A new window for the field will open. 6. spacing.Through this option we can set the font type. Enlarge Font: .. select the create from File ratio button. we can open the concerned application. From the list of applications in the Object Type: list box. In the Paste Special dialog box. Double-click the field. Choose the required file and click OK. Properties: . Open a table. If the object which we want to insert is already available. then select the Create new ratio button. select the application to use. we can select the type of link we want. Reduce Font: . button. in the Browse window.Find Again: . indentation and object positioning. If we want to edit in object. 8.Through this option we can list the Object Linking and Embedding objects that we link or embed in an application from Forms or general fields in Visual FoxPro. The object will get inserted in the general field. Copy the required object and use Paste or Paste Special…. left or right alignment for his text. To insert the object in the general field. Click Edit menu and choose Insert object.This option reduces the font size to the next-smaller size available in the current window.. 5. To create an OLE link: 1.This command is used to enlarge the font size. style and size in the current window. it will be incorporated into the general field. 4. 9. Insert Object: . Format Menu The Format menu contains that controls fonts. Create the object here. . Either writes the full pathname of the file we need in the File: textbox or use the File open dialog box.

Comment: .This option displays the size submenu. Bring to Front: . which lets we change the horizontal spacing of selected objects.This option removes previously inserted indents one a time in the current window. which contains commands that let we set point size and style for different shapes.This option brings selected object to the back of the objects in a form. which lets we define whether the selected control is opaque or transparent. which contains commands that let we adjust alignment and spacing of text within a field or label control. between lines of text in the current window.This option displays text with no blank lines between text lines in current window. Fill: .This option displays the pen submenu. Vertical Spacing: .This option displays the Mode submenu. Set Grid Scale: . Ungroup: . 1 1 /2 Space: . Snap to grid: . Double Space: .This option joins selected objects and they can be manipulated as the group.This option sets line spacing of text at 2 in the current window. Horizontal Spacing: .This option displays the horizontal spacing submenu.This option brings selected object to the top of the objects in a form. where we can define horizontal and vertical increments of the grid in pixels. Mode: .This option moves controls in grid increments when we select object and drag them.This option sets line spacing at 1.This option defines a fill pattern for shapes such as rectangle.This option displays the Set Grid Scale dialog box.This option removes previous comment formatting (*!*) from the selected text. Size: .This option indents the selected line or lines by one tab in the current window. Text Alignment: .This option displays the horizontal spacing submenu.5. Pen: .Single Space: .This option separates previously grouped objects into individual objects again and they can manipulate individually. Group: .This option marks selected lines of text as comment by placing an *!* at the beginning of the line. Unindent: . . Send to Back: . Indent Space: . Spelling Tool The Spelling Tool is very flexible and powerful tool that allows us to check spelling in a program file or in the memo field. Align: . Fill provides eight fill pattern options. rounded rectangle etc. Uncomment: . which lets we change he size of selected object.This option displays the Align submenu. which lets we change the vertical spacing of selected objects. which lets we change the size of selected object.This option displays the text Alignment submenu.

When the information changes in the source document. Various option available in this dialog box are as follows: Option Function Always suggest Display a list of suggested correction for each unmatched word when we check spelling. Linking: . 2.Linking is the term used to describe the establishment of a connection between the source document and the destination document. • Click Ignore All to ignore all occurrences of the word in the document.Steps to spell check our program file or memo field:1. . automatically. and selects words that it does not recognize. • Click Change All to change all occurrences of the misspelled word in document. 8. Spelling tool will continue searching. 4. the changes are reflected in the destination document. The spell tool will search through our document. Complete. 7. Concise. A linked object maintains connection between the two documents. the toolbars and menus from the original program will appear. 6. Then choose anyone from the following list: • Click the change button to change the word. Click the Undo Last button to undo the spelling change made. specify the language of dictionary we want and in the Type: list box. Click Tools menu and choose spelling…. Changes that we make to the linked information will also appear in the original document. • Click Ignore to leave the word as it is. 3. • Click the Add button to add this word to the Visual FoxPro dictionary. such as an Excel spreadsheet or a Word document. 5. Click Close to stop the spell checking if so desired. Ignore Extra Spaces Skip extra spaces between words. Object Linking and Embedding Object Linking and Embedding is a method by which an object created in another application. Either type the current words in the change To: textbox or select the correct word from the suggestions: list. double click it. Now we click on OK button. Ignore words in Skip words in which each character is in UPPERCASE uppercase letter. T edit the linked information. Medical or Legal dictionary. The misspelled words are highlighted in the text and displayed in the not in Dictionary: box. Click the Options… button in the Spelling & Grammar dialog box to open the Options dialog box. can be linked to or embedded in a Visual FoxPro table or form. in the language: list box. Clicking the Suggest button will display a list of suggestions after we type a word in the change To: textbox. specify whether we want Normal. In the Directory area.

2. Logical Variables: . Programming and Developing Applications using Visual FoxPro An Overview of Programming: A computer programming is a series of instructions given to a computer to execute them. 5.Embedding is the term used to describe the insertion of a copy of an object from one application into another. 1. storing the results of calculations for future use d. preserving data from a table record c. Variables: Variable is a memory location within the computer that is used to store data temporarily. collecting and storing inputs b. which can be letters. numeric. Alternatively. After we have entered the commands.This is used to store numeric values such as whole or decimal numbers. Character Variables: . From the appeared dialog box. Numeric Variables: . Click Save button. 4. These are character. invoke File menu and select Save As. 3. storing individual items of information that must be globally available throughout an application Creating and using Variables: . type Do <file name> in the command window. types modify command <file name> in the command window.This store strings of characters. 4. If a document is embedded. Running the program from a file: We can execute a program by selecting DO from the program menu and selecting a program from the Do dialog box. 3. 2. The embedded copy does not change even if the original object changes. hen we can edit the information by opening the document in the original program and make changes to it.There are mainly four types of variables used in Visual FoxPro. Variables play very important role in programming by: a. one after the other. Date Variables: . we choose Program radio button and click on the New file button. numbers or a combination of both. The command file is saved with an extension . Click File menu and choose New. These instructions are commands that cause the computer to perform specific tasks.prg in Visual FoxPro. type the file name to save the current document.This store date values written in MM/DD/YY format. Once the copy is inserted it has no further association with the original object. Variables can be created in one of the following two way:- . date and logical variables. A command file created by the programmer in Visual FoxPro contains a group of commands. Type our program in this editor.Embedding: . Creating Files: 1.This contain a logical value of T(true) or F(false). in general. Alternatively. A program editor will appear.

. say.a. The @ command allows us o perform many things such as displaying information.. CHOICE. Enter the following command to display active memory variable DISPLAY MEMORY . With assignment (=) statement Syntax: variable = expression Simple Output using ‘?’ Command: Till now we have created many memory variables with STORE or = (assignment) methods. Using the Store command Syntax: STORE <expression> To <variable name> b. Getting Input from the User: There are two commands. We also need to provide a variable to store the answer to the question.. so the subsequent value is displayed on the current line. The ?? Command does not include a linefeed and carriage return before the display. Clearing Screen with @ Commands: . When we use either Accept or Input commands. Drawing and Clearing Box Using @ Command: .@. clearing selecting screen and designing custom screens. inputting data in fields/variables. Boxes can be drawn with a single or double-line border..Say…Get Command: We also use a combination of @. Get and Read commands to prompt the user to enter the values from the keyboard. It restricts entry to specific characters and it validates formats but not values. we can use DISPLAY MEMORY or LIST MEMORY commands to show existing memory variable values. so I is positioned one line below the previous item displayed. we enclose the prompt to be asked in apostrophes (‘) or double quotes (“).CLEAR statement blanks rectangular area on the screen. For example: ? “Visual FoxPro” ?? “Visual FoxPro” Picture Clauses: It applies a specific format o a specific character position. Symbol Meaning A Accepts only alphabetic characters . Syntax: Accept “<Message>” To <Variable name> Or Input “<Message>” To <Variable name> @.@ Command I used to draw lines and boxes on the screen. Displaying and Manipulation Information with ?/?? Commands: The ? and ?? Commands are used to ask Visual FoxPro to display particular data on the screen. We can view the contents of memory variables by entering statements in the following manner: ? MNAME. The ? command issues a carriage return before printing the expression list. However. For drawing we need to specify the top-left and bottom-right coordinates of the box. namely ACCEPT and INPUT commands that allow we to get data from the keyboard. AMT The “?” displays the specific values that had been stored in the memory variable.

A SCAN loop acts like a DO…WHILE loop. Control Flow: Control statement allows us to change the sequence of instruction for execution. Visual FoxPro has two basic methods of selection. Visual FoxPro provides three loop commands. When it gets to ENDDO. Syntax: SCAN [scope] [FOR condition] [WHILE condition] [commands] ENDSCAN FOR…ENDFOR: FOR…ENDFOR executes a set of statements within a loop for specified number fo times. Control statements are of the following two types: • Looping Statement • Selection Statement Looping: Repeating a step or a number of a program for a specified number of times or until a condition is met. DO WHILE…ENDDO b. the program executes that commands that follow. It is used for selecting the proper path out of the two or more alternative paths in the program logic. We can use a memory variable as a counter to determine how many times Visual Foxpro executes the statement inside the loop. it loops-break.L Accepts only Y(yes) or N(no) N Accepts letters and digits X Accepts any character 9 Accepts only digits or sign # Accepts digits. is known as looping or iteration.If we want to get emp_code that must begin with an alphabet and has three digits then we can write Picture”A999”. Iteration is used when one or more instructions may be executed several times depending on a condition. it checks to confirm if the logical expression is true. SCAN…ENDSCAN c. these are:a. FOR…ENDFOR DO WHILE…ENDDO: The most important command used for Iteration in Visual FoxPro language is DO WHILE loop. ENDDO Each time the program reaches this DO WHILE command. Specifies decimal point precision ‘ Left of the decimal Example: . which has the following form: Do WHILE <logical exp> …. Syntax: FOR <memvar> = <exp1> to <exp2> [STEP<exp3>] ENDFOR/NEXT SELECTION: Selection is used for making decisions. When there are one or two choices. blanks and sign ! Converts lowercase letters to uppercase $ Displays currency symbol . SCAN…ENDSCAN: This is very useful structure for programming in Visual FoxPro. If it does. it is most convenient to use the IF…ELSE…ENDIF .

or SCAN statements.command. . Now we select the directory of our choice and provide a name for the new project file in appeared dialog box and click Save. if we want the variable we are declaring should be available only to the program that has created the variable and also to programs that are called by the specific program. Another command is the LOOP. Using the Project Manager: The Project Manager is used to organize and manage all our files in projects. However. FOR… ENDFOR or SCAN…ENDSCAN statements. We can create procedure in the same way as we create programs. except that it resides in another program file. It causes the program control to directly return to the DO WHILE. Use this command from within a DO WHILE…ENDDO. FOR…ENDFOR or SCAN…ENDSCAN loops. Open the project manager:1. If we have created a variable in one command file and we need to use it in other command file then we should declare them Public. Procedures and Parameters: A procedure is a set of instructions that work as a unit. FOR. Visual FoxPro offers two commands. Click File menu and choose New…Now select the Project radio button in appeared dialog box and click New File button. It is a sequence of Visual FoxPro commands that is functionally equivalent to the program. then declare it as Private. When we have a large number of choices. PRIVATE and PUBLIC that are used to classify variables. Syntax: PROCEDURE <procedure_name> <commands> [Return] ENDPROC Scope of Variables: A variable’s scope specifies how the variable makes its value known to other procedures and functions. 2. it is most convenient to use the DO CASE…ENDCASE command. IF…ELSE…ENDIF Syntax: IF condition <list of commands> ELSE <list of commands> ENDIF DO CASE…ENDCASE Syntax: DO CASE CASE condition1 <list of commands> CASE condition2 <list of commands> CASE condition3 _____ <list of commands> ______________________ OTHERWISE <list of commands> ENDCASE Exit and Loop Command: The EXIT command lets us exit from the loop created by DO WHILE…ENDDO.

A window will appear asking whether you want to just remove the file from the project or you want to delete it from the disk. 8. 9. Click the New button to add a new file or object. To replace it. It can be done by either dragging to the menu bar or by double clicking the title bar of the Project Manager window.3.frx. Creating Report using Report wizard: Report Wizard is used to generate report using only table. Once clicked. Auto Reports include all the field of the table and use the field names as labels. The new file or object will get added to the currently selected item. We can create a Report Wizard in the following ways:1. You may see a list of items in the Project manager window such as Tables. which we click to collapse the expended list. The project manager window can be docked to the op of our Visual FoxPro screen. if you click the forms item. Auto Reports are given names made up of the initial letter of the file name.frx. 5. we have asked for. 4. This method is simplest to create. Reports are saved with the extension . 10. and Labels etc. This button gets enabled only when you select an item. Click the Modify button to make any changes to the added item. 11. 12. click tabs o display their contents. Using the Report Wizard Auto Report: Auto Report are adequate when all we need is a columnar listing of data in the fields. . Forms. Click the Add button to add an existing item to the currently selected item. Clicking the plus (+) sign to the left of an item will display the sub-items. For example. Click the Build button to build a project. 7. application or an executable or OLE server. followed by an underscore (_) and a number. Queries. just drag it back to its original position or click the Close box. Reports. all the forms added to this project will be displayed. Ex. the plus sign changes to a minus sign. choose Wizard and select Report.Employee_1. To create Auto Report firstly we open a table then click the Auto Report Wizard button on the standard toolbar. This is done in the Build Options dialog box that appears. We can tear off a tab by dragging them away from the menu bar. When the Project window is active. From the Tools menu. Visual FoxPro displays the Project menu on the menu bar. 6. A plus sign appears to the left of items if there are further items of that type in the project. Click the Remove button to eliminate the selected file or object from the project. However it offers the least flexibility in presenting our data. When the window is docked.

Now we choose Report style from the Report dialog box namely Executive. Now we click on Next> button. 3. To select all the fields click the button. click the button. From the Available Fields: area. After this we click on Next> button. 9. To remove all the fields. After choosing the style click Next> button. Now we click on Next> button. 6. We can close the Preview by press ESC key. Now we choose Report in appeared dialog box and click on Wizard and select Report Wizard. 5. select the field which we want in our form. 7. In the Wizard selection dialog box. Ledger and Presentation. 4. Click on New button on the standard toolbar. click the button. To remove a field from the selected fields.2. 8. Now we select field form Available field box. In the next step we type a title for our report and click on Preview to view the report without leaving the Wizard. Now after Report dialog box appearing we define the Report layout of our report. Creating a Group/Total Report: . Click as save report and modify in the report designer and click on Finish button. the click button. In the field layout: we can select columns or Rows. If we pick a column again we need to decide whether the orientation should be Portrait or Landscape. choose Report Wizard and click OK. In the next step we select sorting order of record by selected field in ascending or descending order.

Sign up to vote on this title
UsefulNot useful