Modify database table outside the database will cause field name to be truncated

Tables within the database container can use field names longer than 10 characters while free table cannot use field names longer than 10 characters. Therefore, if you use Modify Stru command to modify the tables outside the database container, Visual Foxpro will truncate the field names longer than 10 characters to 10 characters when you save the table. This will cause your program to hit runtime error because the field cannot be found by the program anymore.

Therefore, when you want to modify tables that are attached to database, make sure you open it and modify it within the database. Do not modify it as it is a free table.

How to suspend Visual Foxpro 6.0 execution for debugging ?

One of the most commonly used debugging method in visual programming is to set a break-point in the code where you want the execution of the program to suspend and then debug into the code line by line. To do this in Visual Foxpro 6.0 is not as straight forward as in Visual Basic 6.0. In Visual Foxpro 6.0, you need to type the following code to the point where you want the program to suspend:

SET STEP ON

When Visual Foxpro hit the set step on command, it will suspend the program and open the debugger windows for you. From there, you can step into the code line by line by pressing the F8 key.

While in debugging mode, if you want to check the content of your cursor, you can add the Brow command at the point where you want to check the content of your cursor.

Data sorting in a Table

Data in Foxpro table is sorted by the order the data is entered. However, you can peridiocally re-sort the data according to the field that is meaningful to you by using the SORT TO command. For example,

SORT TO cust ON name

You can also soft the data to another new table. For example,

SORT TO cust2 ON name

This method will create a new table and soft the data from the original table to the new table. The data in the original table will remain untouched.

The SORT command will physically sort the data in the table. This SORT command is not a good approach to soft data for user viewing. If you have many users and every user want to see view the data in different sorting order, you cannot issues a soft command for each user. Anoter better approach to sort data for user viewing is by using Index.

Add data to a table

1) Open the table that you want to add data.

2) In the Command window, type APPEND and the Enter. An entry screen as shown below will appear.

3) Enter your data with the entry screen.

Create a new Table in Visual Foxpro 6.0

1) Open the Project that you want to create the table to.


2) On the Project Manager, click on the Data tab.


3) choose Free Tables and then click New.


4) You are given the option to use Table Wizard or New Table. For this time, click on the New table to design the table with Table Designer.


5) You will be prompted with a file name. Enter a name for your table. For this time, use cust.dbf.


6) Visual Foxpro will open up a Table Designer. Please note that there are 3 tabs in the Table Designer: Fields, Indexes and Table.


7) Enter field information at the Fields tab as below:


Please note that there is a checkmark in the Null column for fields name2, address2 and phoneno. This will set these 3 fields to allow Null value. If the Null field is not checked, Foxpro will throw an error when you try to insert a new record to the table without supplying a value to the fields. But before you can make the system check for null value use must issue the SET NULL ON command.


8) Click on the OK button to create the table.


9) You will be prompted to enter data. Click No to close the table.

OK. YOu have created a Free Table with Visual Foxpro 6.0. You can see this under the Free Table in the Project Manager.

Create a new Project in Visual Foxpro 6.0

1) Open Visual Foxpro 6.0.
2) Click on File -->New.
3) Choose Project in the File type option and the click on the New file button.
4) Select a directory and choose a file name.
5) Click on the OK button.

OK. Your new project been created and Visual Foxpro will open it for you automatically. There are 2 files created for your project, one with .pjt and one with .pjx extension.

Function to return current date and tim.

DateTime()