<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><channel><title>Visual FoxPro</title><description></description><managingEditor>noreply@blogger.com (Albert Chuah)</managingEditor><pubDate>Mon, 28 Sep 2026 07:15:03 -0700</pubDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">17</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage><link>http://visualfoxpro9.blogspot.com/</link><language>en-us</language><itunes:explicit>no</itunes:explicit><itunes:subtitle/><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><item><title>Choosing Data Types</title><link>http://visualfoxpro9.blogspot.com/2011/06/choosing-data-types.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:28:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-7194064752856865884</guid><description>As you create each table field you also choose a data type for the data the field is to store. When you&amp;nbsp;choose a field’s data type, you’re deciding:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;What kind of values to allow in the field. For example, you can’t store text in a Numeric field.&amp;nbsp;How much storage space Visual FoxPro is to set aside for the values stored in that field. For&amp;nbsp;example, any value with the Currency data type uses 8 bytes of storage.&lt;/li&gt;
&lt;li&gt;What types of operations can be performed on the values in that field. For example, Visual FoxPro&amp;nbsp;can find the sum of Numeric or Currency values but not of Character or General values.&lt;/li&gt;
&lt;li&gt;Whether Visual FoxPro can index or sort values in the field . You can’t sort or create an index for&amp;nbsp;Memo or General fields.&lt;/li&gt;
&lt;/ul&gt;&lt;b&gt;Tip&lt;/b&gt; For phone numbers, part numbers, and other numbers you don’t intend to use for&amp;nbsp;mathematical calculations, you should select the Character data type, not the Numeric data type.&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;To choose a data type for a field&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;In the Table Designer, choose a data type from the Type list.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
-or-&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Use the CREATE TABLE command.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
For example, to create and open the table products with three fields, prod_id, prod_name, and&amp;nbsp;Values&amp;nbsp;As you build a new table, you can specify whether one or more table fields will accept null values. When&amp;nbsp;you use a null value, you are documenting the fact that information that would normally be stored in a&amp;nbsp;field or record is not currently available. For example, an employee’s health benefits or tax status may be&amp;nbsp;undetermined at the time a record is populated. Rather than storing a zero or a blank, which could be&amp;nbsp;interpreted to have meaning, you could store a null value in the field until the information becomes&amp;nbsp;available.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;To control entering null values per field&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;In the Table Designer, select or clear the Null column for the field.&amp;nbsp;When the Null column is selected, you can enter null values in the field.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
-or-&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Use the NULL and NOT NULL clauses of the CREATE TABLE command.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
For example, the following command creates and opens a table that does not permit null values for the&lt;br /&gt;
cust_id and company fields but does permit null values in the contact field:&lt;br /&gt;
&lt;br /&gt;
CREATE TABLE customer (cust_id C(6) NOT NULL,&amp;nbsp;company C(40) NOT NULL, contact C(30) NULL)&lt;br /&gt;
&lt;br /&gt;
You can also control whether null values are permitted in table fields by using the SET NULL ON&lt;br /&gt;
command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;To permit null values in all table fields&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;In the Table Designer, select the Null column for each table field.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
-or-&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Use the SET NULL ON command before using the CREATE TABLE command.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
When you issue the SET NULL ON command, Visual FoxPro automatically checks the NULL column&amp;nbsp;for each table field as you add fields in the Table Designer. If you issue the SET NULL command before&amp;nbsp;issuing CREATE TABLE, you don’t have to specify the NULL or NOT NULL clauses. For example, the&amp;nbsp;following code creates a table that allows nulls in every table field:&lt;br /&gt;
&lt;br /&gt;
SET NULL ON&lt;br /&gt;
CREATE TABLE test (field1 C(6), field2 C(40), field3 Y)&lt;br /&gt;
&lt;br /&gt;
The presence of null values affects the behavior of tables and indexes. For example, if you use APPEND&amp;nbsp;FROM or INSERT INTO to copy records from a table containing null values to a table that does not&amp;nbsp;permit null values, then appended fields that contained null values would be treated as blank, empty, or&amp;nbsp;zero in the current table.&lt;br /&gt;
&lt;br /&gt;
For more information about how null values interact with Visual FoxPro commands, see Handling Null&lt;br /&gt;
Values.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Visual FoxPro Fields</title><link>http://visualfoxpro9.blogspot.com/2011/06/fields.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:23:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-3286919208674301085</guid><description>&lt;b&gt;Creating&amp;nbsp;Fields&lt;/b&gt;&lt;br /&gt;
When you create table fields, you determine how data is identified and stored in the table by specifying a&amp;nbsp;field name, a data type, and a field width. You also can control what data is allowed into the field by&amp;nbsp;specifying whether the field allows null values, has a default value, or must meet validation rules. Setting&amp;nbsp;the display properties, you can specify the type of form control created when the field is added onto a&amp;nbsp;form, the format for the contents of the fields, or the caption that labels the content of field.&amp;nbsp;Note Tables in Visual FoxPro can contain up to 255 fields. If one or more fields can contain null values,&amp;nbsp;the maximum number of fields the table can contain is reduced by one, from 255 to 254.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Naming Fields&lt;/b&gt;&lt;br /&gt;
You specify field names as you build a new table. These field names can be 10 characters long for free&amp;nbsp;tables or 128 characters long for database tables. If you remove a table from a database, the table’s long&amp;nbsp;field names are truncated to 10 characters.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;To name a table field&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;In the Table Designer, enter a field name in the Name box.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
-or-&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Use the CREATE TABLE command or ALTER TABLE command.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
For example, to create and open the table customer with three fields, cust_id, company, and&amp;nbsp;contact, you could issue the following command:&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;CREATE TABLE customer (cust_id C(6), company C(40), contact C(30))&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
In the previous example, the C(6) signifies a field with Character data and a field width of 6. Choosing&lt;br /&gt;
data types for your table fields is discussed later in this section.&lt;br /&gt;
&lt;br /&gt;
Using the ALTER TABLE command, you add fields, company, and contact to an existing table&amp;nbsp;customer:&lt;br /&gt;
ALTER TABLE customer ;&lt;br /&gt;
ADD COLUMN (company C(40), contact C(30))&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Using Short Field Names&lt;/b&gt;&lt;br /&gt;
When you create a table in a database, Visual FoxPro stores the long name for the table’s fields in a&amp;nbsp;record of the .dbc file. The first 10 characters of the long name are also stored in the .dbf file as the field&amp;nbsp;name.&lt;br /&gt;
&lt;br /&gt;
If the first 10 characters of the long field name are not unique to the table, Visual FoxPro generates a&amp;nbsp;name that is the first n characters of the long name with the sequential number value appended to the end&amp;nbsp;so that the field name is 10 characters. For example, these long field names are converted to the&amp;nbsp;following 10-character names:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Long Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Short Name&lt;/b&gt;&lt;br /&gt;
customer_contact_name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; customer_c&lt;br /&gt;
customer_contact_address &amp;nbsp; &amp;nbsp; customer_2&lt;br /&gt;
&lt;br /&gt;
customer_contact_city &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; customer_3&lt;br /&gt;
customer_contact_fax &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;customer11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
While a table is associated with a database, you must use the long field names to refer to table fields. It is&amp;nbsp;not possible to use the 10-character field names to refer to fields of a table in a database. If you remove a&amp;nbsp;table from its database, the long names for the fields are lost and you must use the 10-character field&amp;nbsp;names (stored in the .dbf) as the field names.&lt;br /&gt;
&lt;br /&gt;
You can use long field names composed of characters, not numbers, in your index files. However, if you&amp;nbsp;create an index using long field names and then remove the referenced table from the database, your&amp;nbsp;index will not work. In this case, you can either shorten the names in the index and then rebuild the&amp;nbsp;index; or delete the index and re-create it, using short field names. For information on deleting an index,&amp;nbsp;see “Deleting an Index”.&lt;br /&gt;
&lt;br /&gt;
The rules for creating long field names are the same as those for creating any Visual FoxPro identifier,&amp;nbsp;except that the names can contain up to 128 characters.&lt;br /&gt;
&lt;br /&gt;
For more information about naming Visual FoxPro identifiers, see Creating Visual FoxPro Names.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Saving a Table as HTML</title><link>http://visualfoxpro9.blogspot.com/2011/06/saving-table-as-html.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:16:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-288420057725169526</guid><description>You can use the Save As HTML option on the File menu when you are browsing a table to save the&amp;nbsp;contents of a table as an HTML (Hypertext Markup Language) file.&lt;br /&gt;
&lt;br /&gt;
To save a table as HTML&lt;br /&gt;
1. Open the table.&lt;br /&gt;
2. Browse the table by issuing the BROWSE command in the Command window or by choosing&amp;nbsp;Browse from the View menu.&lt;br /&gt;
3. Choose Save As HTML on the File menu.&lt;br /&gt;
4. Enter the name of the HTML file to create and choose Save.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Copying and Editing Table Structure</title><link>http://visualfoxpro9.blogspot.com/2011/06/copying-and-editing-table-structure.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:15:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-7580128302902175086</guid><description>To modify the structure of an existing table, you can use the Table Designer or ALTER TABLE.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can create a new table based on the structure of an existing table, then modify the&amp;nbsp;structure of the new table.&lt;br /&gt;
&lt;br /&gt;
To copy and edit a table structure&lt;br /&gt;
1. Open the original table.&lt;br /&gt;
2.&amp;nbsp;Use the COPY STRUCTURE EXTENDED command to produce a new table containing the&amp;nbsp;structural information of the old table.&lt;br /&gt;
3. Edit the new table containing the structural information to alter the structure of any new table&amp;nbsp;created from that information.&lt;br /&gt;
4.&amp;nbsp;Create a new table using the CREATE FROM command.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; The new table is empty.&lt;br /&gt;
5. Use APPEND FROM or one of the data copying commands to fill the table if necessary.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Duplicating a Table</title><link>http://visualfoxpro9.blogspot.com/2011/06/duplicating-table.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:13:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-420367486570392081</guid><description>You can make a copy of a tables structure, its stored procedures, trigger expressions, and default field&amp;nbsp;values by using the language. There is no menu option to perform the same function. This procedure&amp;nbsp;does not copy the contents of the table.&lt;br /&gt;
&lt;br /&gt;
To duplicate a table&lt;br /&gt;
1. Open the original table.&lt;br /&gt;
2. Use the COPY STRUCTURE command to make a copy of the original table.&lt;br /&gt;
&lt;br /&gt;
3. Open the empty table created with the COPY STRUCTURE command.&lt;br /&gt;
4. Use the APPEND FROM command to copy the data from the original table.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Deleting a Free Table</title><link>http://visualfoxpro9.blogspot.com/2011/06/deleting-free-table.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:08:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-4709695720449484604</guid><description>If a table is not associated with a database, you can delete the table file through the Project Manager or&amp;nbsp;with the DELETE FILE command.&lt;br /&gt;
&lt;br /&gt;
To delete a free table&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;In the Project Manager, select the free table, choose Remove, and then choose Delete.&lt;/li&gt;
&lt;/ul&gt;-or-&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Use the DELETE FILE command.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
For example, if sample is the current table, the following code closes the table and deletes the file from&amp;nbsp;disk:&lt;br /&gt;
&lt;br /&gt;
USE&lt;br /&gt;
DELETE FILE sample.dbf&lt;br /&gt;
&lt;br /&gt;
The file you want to delete cannot be open when DELETE FILE is issued. If you delete a table that has&amp;nbsp;other associated files, such as a memo file (.fpt) or index files (.cdx or .idx), be sure to delete those files&amp;nbsp;as well. For &amp;nbsp;example, if the file sample.dbf also has an associated memo file, you could delete both&amp;nbsp;files with the following &amp;nbsp;commands:&lt;br /&gt;
&lt;br /&gt;
USE&lt;br /&gt;
DELETE FILE sample.dbf&lt;br /&gt;
DELETE FILE sample.fpt</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Deleting a Database Table</title><link>http://visualfoxpro9.blogspot.com/2011/06/deleting-database-table.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:07:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-2531103334193690214</guid><description>&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;If a table is associated with a database, you can delete the table as a by-product of removing the table&amp;nbsp;from its database. Deleting a table is different from removing a table from a database, however. If you&amp;nbsp;just want to remove a table from a database but do not want to physically delete the table from disk, see&amp;nbsp;“Removing a Table from a Database” in &lt;span class="Apple-style-span" style="color: red;"&gt;Creating Databases&lt;/span&gt;.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To delete a database table from disk&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In the Project Manager, select the table name, choose Remove, and then choose Delete.&lt;/li&gt;
&lt;/ul&gt;-or-&lt;br /&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;From the Database Designer, select the table, choose Remove from the Database menu, and then&amp;nbsp;choose Delete.&lt;/li&gt;
&lt;/ul&gt;-or-&lt;br /&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;To delete the table plus all primary indexes, default values, and validation rules associated with the&amp;nbsp;table, use the DROP TABLE command.&lt;/li&gt;
&lt;/ul&gt;-or-&lt;br /&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;To delete just the table file (.dbf), use the ERASE command.&lt;/li&gt;
&lt;/ul&gt;Caution If you use the ERASE command on tables associated with a database, the command&amp;nbsp;does not &amp;nbsp;update the backlink to the database and can cause table access errors.&lt;br /&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;The following code opens the database testdata and deletes the table orditems and its indexes,&amp;nbsp;default values, and validation rules:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;OPEN DATABASE testdata&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;DROP TABLE orditems&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;If you delete a table using the DELETE clause of the REMOVE TABLE command, you also remove the&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;associated .fpt memo file and .cdx structural index file.&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total></item><item><title>To rename a free table</title><link>http://visualfoxpro9.blogspot.com/2011/06/to-rename-free-table.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:03:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-9014192783849086531</guid><description>&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;Use the RENAME command.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;Caution If you use the RENAME command on tables associated with a database, the command&amp;nbsp;does not update the backlink to the database and can cause table access errors.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Renaming a Table</title><link>http://visualfoxpro9.blogspot.com/2011/06/renaming-table.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:02:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-8862284914158713049</guid><description>&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;You can rename database tables through the interface because you are changing the long name. If you&amp;nbsp;remove the table from the database, the file name for the table retains the original name. Free tables do&amp;nbsp;not have a long name and can only be renamed using the language.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To rename a table in a database&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;In the Database Designer, select the table to rename.&lt;/li&gt;
&lt;li&gt;From the Database menu, choose Modify.&lt;/li&gt;
&lt;li&gt;In the Table Designer, type a new name for the table in the Table Name box on the Table tab.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Naming a Table</title><link>http://visualfoxpro9.blogspot.com/2011/06/naming-table.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:02:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-7802717781270461806</guid><description>&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;When you issue the CREATE TABLE command, you specify the file name for the .dbf file Visual&amp;nbsp;FoxPro creates to store your new table. The file name is the default table name for both database and free&amp;nbsp;tables. Table names can consist of letters, digits, or underscores and must begin with a letter or&amp;nbsp;underscore.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;If your table is in a database, you can also specify a long table name. Long table names can contain up to&amp;nbsp;128 characters and can be used in place of short file names to identify the table in the database. Visual&amp;nbsp;FoxPro displays long table names, if you’ve defined them, whenever the table appears in the interface,&amp;nbsp;such as in the Project Manager, the Database Designer, the Query Designer, and the View Designer, as&amp;nbsp;well as in the title bar of a Browse window.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To give a database table a long name&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In the Table Designer, enter a long name in the Table Name box.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;-or-&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Use the NAME clause of the CREATE TABLE command.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;For example, the following code creates the table vendintl and gives the table a more understandable&amp;nbsp;long name of vendors_international:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;CREATE TABLE vendintl NAME vendors_international (company C(40))&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;You can also use the Table Designer to rename tables or add long names to tables that were created&amp;nbsp;without long names. For example, when you add a free table to a database, you can use the Table&amp;nbsp;Designer to add a long table name. Long names can contain letters, digits, or underscores, and must&amp;nbsp;begin with a letter or &amp;nbsp;underscore. You can’t use spaces in long table names.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Creating a Free Table</title><link>http://visualfoxpro9.blogspot.com/2011/06/creating-free-table.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:01:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-6204547985986493299</guid><description>&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;A free table is a table that is not associated with a database. You might want to create a free table, for&amp;nbsp;example, to store lookup information that many databases share.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;To create a new free table&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In the Project Manager, select Free Tables, and then New to open the Table Designer.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;-or-&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Use the FREE keyword with the CREATE TABLE command.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;For example, the following code creates the free table smalltbl with one column, called name:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;CLOSE DATABASES&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;CREATE TABLE smalltbl FREE (name c(50))&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;If no database is open at the time you create the table, you do not need to use the keyword FREE.&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>Creating a Database Table</title><link>http://visualfoxpro9.blogspot.com/2011/06/creating-database-table.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 02:01:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-3958350595114674749</guid><description>&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;You can create a new table in a database through the menu system, the Project Manager, or through the&amp;nbsp;language. As you create the table, you can create long table and field names, default field values, field and&amp;nbsp;record-level rules, as well as triggers.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;To create a new database table&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;In the Project Manager, select a database, then Tables, and then New to open the Table Designer.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;-or-&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Use the CREATE TABLE command with a database open.&lt;/li&gt;
&lt;/ul&gt;For example, the following code creates the table smalltbl with one column, called name:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;OPEN DATABASE Sales&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;CREATE TABLE smalltbl (name c(50))&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;The new table is automatically associated with the database that is open at the time you create it. This&amp;nbsp;association is defined by a backlink stored in the table’s header record.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;
&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Creating Tables</title><link>http://visualfoxpro9.blogspot.com/2011/06/creating-tables.html</link><category>Working with Tables</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 01:59:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-7516221818368759954</guid><description>You can create a table in a database, or just create a free table not associated with a database. If you put&lt;br /&gt;
the table in a database, you can create long table and field names for database tables. You can also take&lt;br /&gt;
advantage of data dictionary capabilities for database tables, long field names, default field values, fieldand&lt;br /&gt;
record-level rules, as well as triggers.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Designing Database vs. Free Tables&lt;/b&gt;&lt;br /&gt;
A Visual FoxPro table, or .dbf file, can exist in one of two states: either as a database table (a table&lt;br /&gt;
associated with a database) or as a free table that is not associated with any database. Tables associated&lt;br /&gt;
with a database have several benefits over free tables. When a table is a part of a database you can create:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Long names for the table and for each field in the table.&lt;/li&gt;
&lt;li&gt;Captions and comments for each table field.&lt;/li&gt;
&lt;li&gt;Default values, input masks, and format for table fields.&lt;/li&gt;
&lt;li&gt;Default control class for table fields.&lt;/li&gt;
&lt;li&gt;Field-level and record-level rules.&lt;/li&gt;
&lt;li&gt;Primary key indexes and table relationships to support referential integrity rules.&lt;/li&gt;
&lt;li&gt;One trigger for each INSERT, UPDATE, or DELETE event.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Some features apply only to database tables. For information about associating tables with a database,&lt;br /&gt;
see&lt;span class="Apple-style-span" style="color: red;"&gt; Creating Databases&lt;/span&gt;.&lt;br /&gt;
&lt;b&gt;Database tables have properties that free tables don’t.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can design and create a table interactively with the Table Designer, accessible through the Project&lt;br /&gt;
Manager or the File menu, or you can create a table programmatically with the language. This section&lt;br /&gt;
primarily describes building a table programmatically. For information on using the Table Designer to&lt;br /&gt;
build tables interactively, see &lt;span class="Apple-style-span" style="color: red;"&gt;Creating Tables and Indexes&lt;/span&gt;, in the User’s Guide.&lt;br /&gt;
You use the following commands to create and edit a table programmatically:&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;Commands for Creating and Editing Tables&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;ALTER TABLE&amp;nbsp;&lt;/li&gt;
&lt;li&gt;CLOSE TABLES&lt;/li&gt;
&lt;li&gt;CREATE TABLE&amp;nbsp;&lt;/li&gt;
&lt;li&gt;DELETE FILE&lt;/li&gt;
&lt;li&gt;REMOVE TABLE&amp;nbsp;&lt;/li&gt;
&lt;li&gt;RENAME TABLE&lt;/li&gt;
&lt;li&gt;DROP TABLE&lt;/li&gt;
&lt;/ul&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>How shall we proceed Functions and Procedures ?</title><link>http://visualfoxpro9.blogspot.com/2011/06/how-shall-we-proceed-functions-and.html</link><category>Functions and Procedures</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 01:42:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-7891414730239734851</guid><description>In prior versions of FoxPro, applications were limited to a single active procedure file at any&amp;nbsp;time. This meant that all user-defined functions and commonly used procedures were kept in a&amp;nbsp;single file. With Visual FoxPro, the ability to have multiple procedure files active at any given&amp;nbsp;time provides much more flexibility. Such procedures can now be grouped logically, by&amp;nbsp;functionality, into different procedure files that can be loaded incrementally as needed. The&amp;nbsp;downside, of course, is that procedure files are loaded into memory by Visual FoxPro and held&amp;nbsp;until explicitly released. This may not be the best use of that precious resource.&lt;br /&gt;
&lt;br /&gt;
Fortunately, it is also possible to define procedure classes. The individual functions that&amp;nbsp;would previously have been kept in a procedure file can now become methods of a class. This&amp;nbsp;approach has the benefit that, when defined visually in the Class Designer, all the functions in&amp;nbsp;the procedure can be neatly viewed under the methods tab of the property sheet. Procedure&amp;nbsp;classes containing specific functionality can be dropped onto forms that require this&amp;nbsp;functionality. A second major benefit is that a procedure class can be sub-classed - for those&amp;nbsp;special situations when standard functionality must be augmented.&lt;br /&gt;
&lt;br /&gt;
The approach that we like is a combination of these two approaches. We recommend using&amp;nbsp;a procedure file for truly generic functions (i.e. those that are used, unchanged, by many&amp;nbsp;different applications). For example, our procedure file contains a NewID function for&amp;nbsp;generating surrogate primary keys, a SetPath function to set the path for the application and a&amp;nbsp;few key functions that Visual FoxPro should have, but doesn't. Two examples of such&amp;nbsp;functions are the Str2Exp and Exp2Str functions (used later in this chapter These functions, as&amp;nbsp;the names imply, are used to convert character strings into the values of another specified data&lt;br /&gt;
type and vice versa.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Separate Procedure Classes contain application specific functionality. For example, an&amp;nbsp;accounting application might require several functions to calculate tax and invoice totals. The&amp;nbsp;Accounting Procedures Class can be dropped onto any form that requires these functions – or&amp;nbsp;can be instantiated as an Application Level object. Clearly, such functions are not generic, nor&amp;nbsp;are they even required by the entire application. By grouping them into a single procedure&amp;nbsp;class, we can make this functionality available at the specific parts of the application that&amp;nbsp;require it without compromising the rest of the application.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Parameters (an aside)&lt;/b&gt;&lt;br /&gt;
We have all used parameters extensively in FoxPro but in Visual FoxPro’s object oriented&amp;nbsp;environment, parameters have taken on a new importance as the principle means of&amp;nbsp;implementing messaging – the very lifeblood of an OO application! (We have more to say on&amp;nbsp;this subject later!)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;By reference, by value?&lt;/b&gt;&lt;br /&gt;
Parameters are passed either by reference or by value. When a parameter is passed to a&amp;nbsp;function or procedure by reference, any changes made to its value in the called code are&amp;nbsp;reflected in the original value in the calling program. Conversely when a parameter is passed&amp;nbsp;by value, the called code can change that value but the value in the calling program remains&amp;nbsp;unchanged.&amp;nbsp;Visual FoxPro interprets the code being called by the mechanism by which parameters are&amp;nbsp;passed. So when the calling syntax looks like this:&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;luRetVal = CallMyFunction( param1, param2 )&lt;/span&gt;&lt;br /&gt;
Visual FoxPro treats this as a Function Call and passes the parameters by value. However&amp;nbsp;if the same code is called like this:&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;DO CallMyFunction WITH param1, param2&lt;/span&gt;&lt;br /&gt;
then Visual FoxPro treats this as a Procedure Call and passes the parameters by reference.&lt;br /&gt;
&lt;br /&gt;
The old coding rule that a “Function must always return a value” is not really true in Visual&amp;nbsp;FoxPro, but it does make sense when the calling syntax is considered.&lt;br /&gt;
&lt;br /&gt;
You can change this default behavior in two ways. One way is to:&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;SET UDFPARMS TO REFERENCE or SET UDFPARMS TO VALUE&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
However, we do not consider this a good idea because it affects the way all functions in&amp;nbsp;your entire application handle the parameters they are passed. (It is never a good idea to use a&amp;nbsp;global solution to solve a local problem). In this case there is a simple solution because&amp;nbsp;parameters can be passed by value explicitly just by enclosing them in parentheses. Thus:&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;DO CallMyFunction WITH (param1), (param2)&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
passes the parameters by value, even though the syntax used would normally cause them&amp;nbsp;to be passed by reference. To pass parameters explicitly by reference, simply preface the&amp;nbsp;parameter with the “@” symbol. (This is, by the way, the only way to pass an entire array to a&amp;nbsp;procedure, function or method). So we could also make our function call and pass its&amp;nbsp;parameters by reference like this:&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;luRetVal = CallMyFunction( @param1, @param2 )&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How do I know what was passed?&lt;/b&gt;&lt;br /&gt;
There are two ways for a function to determine how many parameters were passed to it. The&lt;br /&gt;
PARAMETERS() function returns the number of parameters that were passed to the most&amp;nbsp;recently called function or procedure. This can give unexpected results since it is reset each&amp;nbsp;time a function or procedure is called. Most importantly, it is also reset by functions that are&amp;nbsp;not called explicitly, such as &lt;span class="Apple-style-span" style="color: red;"&gt;ON KEY LABEL&lt;/span&gt; routines.&lt;br /&gt;
&lt;br /&gt;
A better way of determining how many parameters were passed to a function is to use the&amp;nbsp;&lt;span class="Apple-style-span" style="color: red;"&gt;PCOUNT()&lt;/span&gt; function. This always returns the number of parameters that were passed to the&amp;nbsp;currently executing code. Save yourself a lot of grief and unnecessary hair pulling by always&amp;nbsp;using &lt;span class="Apple-style-span" style="color: red;"&gt;PCOUNT()&lt;/span&gt; for determining the number of parameters passed.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How should I position my parameters?&lt;/b&gt;&lt;br /&gt;
The best advice is that if a function takes optional parameters, you should place these at the&amp;nbsp;end of the parameter list. PCOUNT() can then be used in the function to determine whether or&amp;nbsp;not the optional parameters were passed allowing the function to take the appropriate action.&lt;br /&gt;
&lt;br /&gt;
You can take advantage of the fact that Visual FoxPro always initializes parameters as&amp;nbsp;logical false. By setting up your function to expect a logical false as its default, you can invoke&amp;nbsp;the function without passing it any parameters. Then, in those cases where you want an&amp;nbsp;alternative behavior, just invoke the function by passing it a logical true.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How can I return multiple values from a function?&lt;/b&gt;&lt;br /&gt;
Of course, returning values is simply the reverse of passing parameters - with one gotcha!.&amp;nbsp;While you can easily pass multiple parameters to a function, there is no obvious mechanism for&amp;nbsp;returning multiple values! The RETURN command only allows a single value to be passed&amp;nbsp;back to the calling program.&lt;br /&gt;
&lt;br /&gt;
One solution is to pass multiple values as a comma-delimited string. This is a little messy,&amp;nbsp;however, as you will need to convert your values into character format to build the return&amp;nbsp;string and then parse out the individual values again in the receiving code.&lt;br /&gt;
&lt;br /&gt;
Another possibility is to define all the values you want populated by the function as&amp;nbsp;Private variables in the calling program. As such, they will be available to any function or&amp;nbsp;procedure that is called subsequently and they can be populated directly. However, this is&amp;nbsp;neither specific nor easy to maintain and is not really a good solution.&lt;br /&gt;
&lt;br /&gt;
A better possibility is to create an array in the calling code for the return values and then&amp;nbsp;pass that array by reference. The called function can then simply populate the array and the&amp;nbsp;values will also be available in the calling program. This is workable, at the very least, and was&amp;nbsp;probably the most common method of handling the issue prior to the introduction of Visual&amp;nbsp;FoxPro.&lt;br /&gt;
&lt;br /&gt;
Once again Visual FoxPro has made life a lot easier. Returning multiple values from a&amp;nbsp;UDF is easy if you create, and use, a parameter class. Ours is based on the Line baseclass and&amp;nbsp;is named xParameters. You can find it in the CH02.VCX class library. All it needs is one&amp;nbsp;custom array property, aParameters, to hold the return values and this line of code in its&amp;nbsp;INIT():&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;LPARAMETERS taArray&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;ACOPY(taArray, This.aParameters)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The user-defined function can then simply populate its own local array with the values it&amp;nbsp;needs to return and create the parameter object on the fly — and populate the object’s array&amp;nbsp;property with a single line of code:&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;RETURN CREATOBJECT( 'xParameters', @laArray )&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Date and time functions&lt;/b&gt;&lt;br /&gt;
Visual FoxPro has several handy dandy, built in functions for manipulating dates. The&amp;nbsp;functions below illustrate how they can be used to perform a few of the most common tasks&amp;nbsp;required when dealing with dates in your applications.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Elapsed time&lt;/b&gt;&lt;br /&gt;
Simply subtracting one DateTime expression from another gives you the elapsed time – this is&amp;nbsp;good. Unfortunately Visual FoxPro gives you this result as the number of seconds between the&amp;nbsp;two – this is bad. This value is seldom directly useful! You can use this little set of functions,&amp;nbsp;which rely on the Modulus operator (%), to calculate the components of elapsed time in days,&amp;nbsp;hours, minutes and seconds.&lt;br /&gt;
&lt;br /&gt;
FUNCTION GetDays( tnElapsedSeconds )&lt;br /&gt;
RETURN INT(tnElapsedSeconds / 86400)&lt;br /&gt;
FUNCTION GetHours( tnElapsedSeconds )&lt;br /&gt;
RETURN INT(( tnElapsedSeconds % 86400 ) / 3600 )&lt;br /&gt;
FUNCTION GetMinutes( tnElapsedSeconds )&lt;br /&gt;
RETURN INT(( tnElapsedSeconds % 3600 ) / 60 )&lt;br /&gt;
FUNCTION GetSeconds( tnElapsedSeconds )&lt;br /&gt;
RETURN INT( tnElapsedSeconds % 60 )&lt;br /&gt;
&lt;br /&gt;
Of course, there is more than one way to skin the fox. You can also use a single function&amp;nbsp;to return an array containing the elapsed time positionally, with days as its first element&amp;nbsp;through to seconds as its fourth like so:&lt;br /&gt;
FUNCTION GetElapsedTime( tnElapsedSeconds )&lt;br /&gt;
&lt;br /&gt;
LOCAL laTime[4]&lt;br /&gt;
laTime[1] = INT( tnElapsedSeconds / 86400 )&lt;br /&gt;
laTime[2] = INT(( tnElapsedSeconds % 86400 ) / 3600 )&lt;br /&gt;
laTime[3] = INT(( tnElapsedSeconds % 3600 ) / 60 )&lt;br /&gt;
laTime[4] = INT( tnElapsedSeconds % 60 )&lt;br /&gt;
RETURN CREATEOBJECT( 'xParameters', @laTime )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you prefer named parameters to the positional variety, the following code accomplishes&amp;nbsp;the task:&lt;br /&gt;
&lt;br /&gt;
FUNCTION GetElapsedTime( tnElapsedSeconds )&lt;br /&gt;
LOCAL loObject&lt;br /&gt;
loObject = CREATEOBJECT( 'Line' )&lt;br /&gt;
WITH loObject&lt;br /&gt;
.AddProperty( 'nDays', INT( tnElapsedSeconds / 86400 ) )&lt;br /&gt;
.AddProperty( 'nHours', INT(( tnElapsedSeconds % 86400 ) / 3600 ) )&lt;br /&gt;
.AddProperty( 'nMins', INT(( tnElapsedSeconds % 3600 ) / 60 ) )&lt;br /&gt;
.AddProperty( 'nSecs', INT( tnElapsedSeconds % 60 ) )&lt;br /&gt;
ENDWITH&lt;br /&gt;
RETURN loObject&lt;br /&gt;
&lt;br /&gt;
Alternatively, if you merely require a string that contains the elapsed time in words, you&amp;nbsp;can just reduce it to a single line of code!&lt;br /&gt;
&lt;br /&gt;
FUNCTION GetElapsedTime( tnElapsedSeconds )&lt;br /&gt;
RETURN PADL( INT( tnElapsedSeconds / 86400 ), 3 )+' Days ';&lt;br /&gt;
+ PADL( INT(( tnElapsedSeconds % 86400 ) / 3600 ), 2, '0' )+' Hrs ' ;&lt;br /&gt;
+ PADL( INT(( tnElapsedSeconds % 3600 ) / 60 ), 2, '0')+' Min ' ;&lt;br /&gt;
+ PADL( INT( tnElapsedSeconds % 60 ), 2, '0' )+' Sec '&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Date in words&lt;/b&gt;&lt;br /&gt;
Converting a value from date format into text can be a tricky business, especially when you are&amp;nbsp;writing international applications. Visual FoxPro makes this task a lot easier with its native&amp;nbsp;MDY(), CMONTH(), CDOW(), MONTH(), DAY() and YEAR() functions, to name but a few.&lt;br /&gt;
&lt;br /&gt;
Version 6.0, with its ability to use strict dates, makes this task even easier. The following&amp;nbsp;function provides one example of how to use these functions.&lt;br /&gt;
&lt;br /&gt;
FUNCTION DateInWords( tdDate )&lt;br /&gt;
RETURN CDOW( tdDate ) + ', ' + MDY( tdDate )&lt;br /&gt;
&lt;br /&gt;
However, the function listed above will not attach the ordinal suffix to the day portion of&amp;nbsp;the date. If your application requires these suffixes when formatting the date in words, use the&amp;nbsp;longer form of the function listed below. You could even extract the portion that calculates the&amp;nbsp;suffix and place it in a function called MakeOrdinal. It can then be invoked any time you need&amp;nbsp;to format a given number n as nth.&lt;br /&gt;
&lt;br /&gt;
FUNCTION DateInWords( tdDate )&lt;br /&gt;
LOCAL lnDay, lnNdx, lcSuffix[31]&lt;br /&gt;
*** Initialize suffix for day&lt;br /&gt;
lnDay = DAY( tdDate )&lt;br /&gt;
lnNdx = lnDay % 10&lt;br /&gt;
IF NOT BETWEEN( lnNdx, 1, 3 )&lt;br /&gt;
&amp;nbsp; &amp;nbsp;lcSuffix = 'th'&lt;br /&gt;
ELSE&lt;br /&gt;
&amp;nbsp; IF INT( lnDay / 10 ) = 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;lcSuffix = 'th'&lt;br /&gt;
&amp;nbsp; ELSE&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;lcSuffix = SUBSTR( 'stndrd', ( 2 * lnNdx ) - 1, 2 )&lt;br /&gt;
&amp;nbsp; ENDIF&lt;br /&gt;
ENDIF&lt;br /&gt;
RETURN CDOW( tdDate ) + ', ' + CMONTH( tdDate ) + ;&lt;br /&gt;
' ' + ALLTRIM( STR( lnDay )) + lcSuffix + ;&lt;br /&gt;
', ' + ALLTRIM( STR( YEAR( tdDate )))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Gotcha! Strict date format and parameterized views&lt;/b&gt;&lt;br /&gt;
Visual FoxPro's StrictDate format is especially comforting with the specter of the millennium&amp;nbsp;bug looming large in front of us. At least it is as we are writing this. There, is however, one&amp;nbsp;small bug that you should be aware of. If you have SET STRICTDATE TO 2 and try to open a&amp;nbsp;parameterized view that takes a date as its parameter, you will be in for trouble. If the view&amp;nbsp;parameter is not defined or is not in scope when you open or re-query the view, the friendly&amp;nbsp;little dialog box prompting for the view parameter will not accept anything you enter. It will&amp;nbsp;keep saying you have entered an ambiguous date/datetime constant.&lt;br /&gt;
&lt;br /&gt;
The workaround is to ensure your view parameter is defined and in scope before trying to&amp;nbsp;open or re-query the view. This means that, if your view is part of a form’s data environment,&amp;nbsp;its NoDataOnLoad property must be set to avoid getting the dialog as the form loads.&lt;br /&gt;
&lt;br /&gt;
The other workaround, setting StrictDate to 0 and then back to 2, is not recommended. As&amp;nbsp;we have already mentioned, using a global solution for a local problem is a little bit like&amp;nbsp;swatting flies with a sledgehammer.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Working with numbers&lt;/b&gt;&lt;br /&gt;
Mathematical calculations have been handled fairly well since the days of Eniac and Maniac,&amp;nbsp;except for the notable bug in the Pentium math co-processor. The most common problems arise&amp;nbsp;because many calculations produce irrational results such as numbers that carry on for an&amp;nbsp;infinite number of decimal places. Rounding errors are impossible to avoid because computing&amp;nbsp;demands these numbers be represented in a finite form. The study of numerical analysis deals&amp;nbsp;with how to minimize these errors by changing the order in which mathematical operations are&amp;nbsp;performed as well as providing methods such as the trapezoidal method for calculating the area&amp;nbsp;under the curve. A discussion of this topic is beyond the scope of this book, but we can give&amp;nbsp;you some tips and gotchas to watch out for when working with numbers in your application.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Converting numbers to strings&lt;/b&gt;&lt;br /&gt;
Converting integers to strings is fairly straightforward. ALLTRIM( STR( lnSomeNumber ) )&amp;nbsp;will handle the conversion if the integer contains ten digits or less. If the integer contains more&amp;nbsp;than ten digits, this function will produce a string in scientific notation format unless you&amp;nbsp;specify the length of the string result as the second parameter. When converting numeric values&amp;nbsp;containing decimal points or currency values, it is probably better to use another function.&lt;br /&gt;
&lt;br /&gt;
Although it can be accomplished using the STR() function, it is difficult to write a generic&amp;nbsp;conversion routine. In order to convert the entire number you must specify both the total length&amp;nbsp;of the number (including the decimal point) and the number of digits to the right of the decimal&amp;nbsp;point. Thus STR(1234.5678) will produce '1235' as its result, and to get the correct conversion&amp;nbsp;you must specify STR(1234.5678, 9, 4).&lt;br /&gt;
&lt;br /&gt;
In Visual FoxPro 6.0, the TRANSFORM() function has been extended so that when called&amp;nbsp;without any formatting parameters, it simply returns the passed value as its equivalent&amp;nbsp;character string. Thus TRANSFORM(1234.5678) will correctly return '1234.5678'.&lt;br /&gt;
&lt;br /&gt;
In all versions of Visual FoxPro you can use ALLTRIM( PADL ( lnSomeNumber, 32 ) )&amp;nbsp;to get the same result (providing that the total length of lnSomeNumber is less than thirty-two&amp;nbsp;digits).</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><title>Configuration files</title><link>http://visualfoxpro9.blogspot.com/2011/06/configuration-files.html</link><category>Controlling the VFP Environment</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 01:20:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-1694347474637448216</guid><description>There are several ways of handling the initialization of Visual FoxPro, but the easiest, and&amp;nbsp;most flexible, is still to use a configuration file. Visual FoxPro uses a simple formatted text&amp;nbsp;file, called "CONFIG.FPW" by default, as the source for a number of environmental values&amp;nbsp;which can be set as the system starts up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How to specify a config.fpw file&lt;/b&gt;&lt;br /&gt;
The actual file name does not matter as you can specify the configuration file which Visual&amp;nbsp;FoxPro is to use as a command line parameter by using the '-c' switch in the command line&amp;nbsp;which is used to start Visual FoxPro. So to set up your own configuration file (for example for&amp;nbsp;a specific application) use the following command line:&lt;br /&gt;
G:\VFP60\APPS\MYAPP.EXE –cG:\VFP60\myconfig.txt&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How VFP locates its configuration file&lt;/b&gt;&lt;br /&gt;
The default behavior of Visual FoxPro, in the absence of a specific configuration file, is to&amp;nbsp;search the following locations for a file named 'config.fpw' in this order:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;The current working directory&lt;/li&gt;
&lt;li&gt;The directory from which Visual FoxPro is being started&lt;/li&gt;
&lt;li&gt;All directories in the DOS path&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
If you are using the '-c' switch to specify a file named other than the default, or in a&amp;nbsp;specific location, you must include the fully qualified path and file name. This provides a&amp;nbsp;simple method of handling the initialization of different applications installed on the same&amp;nbsp;machine.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How VFP starts up when no configuration file is found&lt;/b&gt;&lt;br /&gt;
If no configuration file is found or specified, then Visual FoxPro will be started with only those&amp;nbsp;settings that are specified in the Options Dialog (located on the TOOLS pad of the main Visual&amp;nbsp;FoxPro menu).&lt;br /&gt;
&lt;br /&gt;
Why these settings in particular?&lt;br /&gt;
The answer is simply that all of the settings from this dialog are actually stored in the&lt;br /&gt;
Windows Registry and can be found under the Registry Key:&lt;br /&gt;
HKEY_CURRENT_USER\Software\Microsoft\VisualFoxPro\6.0\Options&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Including a configuration file in the project&lt;/b&gt;&lt;br /&gt;
One little "trap" to watch out for – if you add a configuration file named 'config.fpw' to your&amp;nbsp;project as a text file, it will be INCLUDED in the project by default. When you build an .exe&amp;nbsp;from the project, the config.fpw file will be built into the resulting file. Since Visual FoxPro&amp;nbsp;looks for a file named 'config.fpw' during startup, it will always find the built-in version first&amp;nbsp;and will not look any further. This would apply even if you were to explicitly specify a&amp;nbsp;different configuration file using the '-C' switch! Your specified file would be ignored, and the&amp;nbsp;built-in congfiguration file would be executed. The best solution is NOT to add your&amp;nbsp;configuration file to the project at all, but if you do, to make sure that it is marked as 'excluded'&amp;nbsp;from the build.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How to suppress a configuration file&lt;/b&gt;&lt;br /&gt;
Starting Visual FoxPro with the command line parameter '-c' alone suppresses the default&amp;nbsp;behavior and prevents any configuration file that may be found from being run. The result is&amp;nbsp;that you can force Visual FoxPro to start up with its default settings only.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How to determine which configuration file is being used&lt;/b&gt;&lt;br /&gt;
One of the commonest problems with configuration files is failing to ensure that Visual FoxPro&amp;nbsp;is reading the correct CONFIG.FPW. As noted above, if Visual FoxPro can't find a&amp;nbsp;configuration file, it will search the DOS path and simply use the first one it finds. This could&amp;nbsp;be anywhere on a network. The SYS(2019) function will return the full path and file name of&amp;nbsp;the configuration file that Visual FoxPro actually used. If no configuration file was found, the&amp;nbsp;function merely returns an empty string.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;What goes into the configuration file?&lt;/b&gt;&lt;br /&gt;
Now that we know something about how the configuration file is used, the next question is&amp;nbsp;what can we put into it? The answer is quite a lot! Essentially there are three categories of&amp;nbsp;things that can be specified in the configuration file as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Special settings&lt;/b&gt;&lt;br /&gt;
There are a number of settings that can ONLY be made in a configuration file. (For full details&amp;nbsp;see the "Special Terms for Configuration Files" topic in the Visual FoxPro online Help and the&amp;nbsp;entry under "Configuring Visual FoxPro" in the online documentation.) Notice that the ability&amp;nbsp;to set the location for temporary files is also available in the Options Dialog. Specifying the&amp;nbsp;TMPFILES location in the configuration file will override any setting that is made there and&amp;nbsp;can be useful when you need to differentiate between development and run time locations for&amp;nbsp;temporary files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One other setting that can be used in the configuration file only, but which is not included&amp;nbsp;in the Help file list is "SCREEN = OFF". This prevents the Visual FoxPro main screen from&amp;nbsp;being displayed when your application starts and prevents the annoying 'flash' of the VFP&amp;nbsp;screen that still occurs even if your startup program turns off the main screen with the&amp;nbsp;command _Screen.Visible = .F. (which enables you to present your application's initial&amp;nbsp;form, or a "splash" screen, without displaying the main VFP window first).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;SET Commands&lt;/b&gt;&lt;br /&gt;
Virtually all of the standard SET commands can be issued in a configuration file. The only&amp;nbsp;thing to watch out for is that some settings are actually scoped to the datasession. (See the "Set&amp;nbsp;DataSession" topic in the online Help for a full listing.) So, there is little point in specifying&amp;nbsp;them in the configuration file if you plan to use Private DataSessions for your forms. The&amp;nbsp;syntax for specifying SET commands in the configuration file is a simple assignment in which&amp;nbsp;the keyword 'SET' is omitted:&lt;br /&gt;
&lt;br /&gt;
DEFAULT = C:\VFP60\TIPSBOOK&lt;br /&gt;
DATE = BRITISH&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Commands&lt;/b&gt;&lt;br /&gt;
Well actually you can only specify one (count 'em!) command, and it must be the last line of&amp;nbsp;the configuration file. Like other configuration file entries, it is entered as a simple assignment:&lt;br /&gt;
&lt;br /&gt;
COMMAND = DO setupfox&lt;br /&gt;
&lt;br /&gt;
What is the use of just ONE command? Well, quite a lot really because that one command&amp;nbsp;can call a FoxPro program, and that can do a lot of things!&lt;br /&gt;
&lt;br /&gt;
One of the main limitations of the configuration file is that you cannot actually set things&amp;nbsp;that are internal to Visual FoxPro (e.g. system variables) because, when the configuration file&amp;nbsp;runs, Visual FoxPro hasn't actually started. Using this setting allows you to specify a program&amp;nbsp;file to run immediately after Visual FoxPro has started up – even before the command window&amp;nbsp;is displayed.&lt;br /&gt;
&lt;br /&gt;
This program can then be used to set up your development environment the way that you&amp;nbsp;really want it. For example, here are some of the things that are in our standard setup file:&lt;br /&gt;
&lt;br /&gt;
*** Standard 'SET' options (These could be entered directly into the Config&amp;nbsp;File)&lt;br /&gt;
SET TALK OFF&lt;br /&gt;
SET BELL OFF&lt;br /&gt;
SET SAFETY OFF&lt;br /&gt;
SET STATUS OFF&lt;br /&gt;
SET STATUS BAR ON&lt;br /&gt;
SET DATE BRITISH&lt;br /&gt;
SET CENTURY ON&lt;br /&gt;
*** Re-define Function Keys&lt;br /&gt;
SET FUNCTION 2 TO "CLOSE TABLES ALL;CLEAR WINDOWS;"&lt;br /&gt;
SET FUNCTION 3 TO "CANCEL;SET SYSMENU TO DEFA;ACTIVATE WINDOW COMMAND;"&lt;br /&gt;
SET FUNCTION 4 TO "CLEAR ALL;SET CLASSLIB TO;SET PROC TO;"&lt;br /&gt;
SET FUNCTION 5 TO "DISP STRU;"&lt;br /&gt;
SET FUNCTION 6 TO "DISP STAT;"&lt;br /&gt;
SET FUNCTION 7 TO "DISP MEMO LIKE *"&lt;br /&gt;
SET FUNCTION 8 TO "CLEAR;CLEAR WINDOWS;"&lt;br /&gt;
SET FUNCTION 9 TO "MODI FORM "&lt;br /&gt;
&lt;br /&gt;
SET FUNCTION 10 TO "MODI COMM "&lt;br /&gt;
SET FUNCTION 11 TO "DO setpath WITH "&lt;br /&gt;
SET FUNCTION 12 TO "=CHGDEFA(); "&lt;br /&gt;
***Set up the Screen properties&lt;br /&gt;
_SCREEN.CAPTION = "VFP 6.0 (Development Mode)"&lt;br /&gt;
_SCREEN.CLOSABLE = .F.&lt;br /&gt;
_SCREEN.FONTNAME = "Arial"&lt;br /&gt;
_SCREEN.FONTSIZE = 10&lt;br /&gt;
_SCREEN.FONTBOLD = .F.&lt;br /&gt;
*** Run Cobb Editor Extensions&lt;br /&gt;
DO G:\VFP60\CEE6\CEE6.APP&lt;br /&gt;
*** Set up some On Key Labels&lt;br /&gt;
ON KEY LABEL CTRL+F10 suspend&lt;br /&gt;
ON KEY LABEL CTRL+F11 o=SYS(1270)&lt;br /&gt;
ON KEY LABEL CTRL+F12 RELEASE o&lt;br /&gt;
*** Set up any system variables required&lt;br /&gt;
_Include = HOME() + "Foxpro.h"&lt;br /&gt;
_Throttle = 0.1&lt;br /&gt;
*** Set up any standard "Public" variables&lt;br /&gt;
PUBLIC gcUserName, gcAppPath, gcDataPath&lt;br /&gt;
STORE "" TO gcUserName, gcAppPath, gcDataPath&lt;br /&gt;
*** Run Standard Path Set-up&lt;br /&gt;
DO setpath WITH 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see, apart from setting up the basic VFP system environment and handling our&amp;nbsp;own particular requirements, this 'one' command available in the configuration file has now&amp;nbsp;been used to run a couple of other programs (CEE and our own SetPath procedure) so we get&amp;nbsp;three for the price of one. By putting these settings in a program, we also have a simple way of&amp;nbsp;re-initialising the environment by re-running this program at any time.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Giving VFP a path&lt;/b&gt;&lt;br /&gt;
Visual FoxPro has the ability to use its own search path and, as a general rule, you should&amp;nbsp;always specify a path for Visual FoxPro for both development and production environments -&amp;nbsp;although they may be very different (see above for one way of handling this requirement).&amp;nbsp;Setting a path for Visual FoxPro does not change the normal DOS search path but can&amp;nbsp;significantly speed up your application by limiting the places that Visual FoxPro has to search&amp;nbsp;in order to find its files – especially in a network environment.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How VFP looks for files&lt;/b&gt;&lt;br /&gt;
By default Visual FoxPro uses the current directory as its 'path' and you can always restore this&amp;nbsp;setting by simply issuing: SET PATH TO&lt;br /&gt;
However for more sophisticated applications, and in development, you will normally have&amp;nbsp;some sort of directory structure and you should always set a proper search path to include all&amp;nbsp;required directories.&lt;br /&gt;
Setting the default directory&amp;nbsp;Normally you still will want to set a default (or "working") directory – this is where Visual&amp;nbsp;FoxPro will look first for any file that it requires. This can be done in a number of ways,&lt;br /&gt;
depending on your requirements:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Specify a default in the Configuration File using DEFAULT = &amp;lt;path to directory&amp;gt;&lt;/li&gt;
&lt;li&gt;Set the default directly in code using SET DEFAULT TO &amp;lt;path to directory&amp;gt;&lt;/li&gt;
&lt;li&gt;Change to a directory using the CD &amp;lt;path to directory&amp;gt; and issue SET PATH TO&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Note that using the Get, Put or Locate functions (e.g. GetDir()) does not change either the&amp;nbsp;default directory or the path. To change the default directory interactively use: SET DEFAULT&amp;nbsp;TO ( GetDir() ). (The 'CD' (or 'CHDIR') command can also be used to change both drive and&amp;nbsp;directory to the specified location).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Using the SET PATH command&lt;/b&gt;&lt;br /&gt;
Setting the path is simplicity itself. Just issue the SET PATH command followed by a list of&amp;nbsp;the directories that you wish to include. You do not need to fully qualify subdirectories –&amp;nbsp;separating them with either commas or semi-colons is sufficient. The example shows a typical&amp;nbsp;Visual FoxPro search path:&lt;br /&gt;
&lt;br /&gt;
SET PATH TO G:\VFP60;C:\VFP60\TIPSBOOK\;DATA;FORMS;LIBS;PROGS;UTILS;&lt;br /&gt;
&lt;br /&gt;
To retrieve the current path setting you can use the SET() function (which will work with&amp;nbsp;most of the Visual FoxPro SET commands) as shown below. You can assign the result directly&amp;nbsp;to a variable or, as shown below, directly to the clipboard so that you can then paste the current&amp;nbsp;path into a program or documentation file:&lt;br /&gt;
&lt;br /&gt;
_ClipText = SET( 'PATH' )&lt;br /&gt;
&lt;br /&gt;
Visual FoxPro allows the use of both UNC path names, like:&lt;br /&gt;
&lt;br /&gt;
\\SERVERNAME\DIRECTORYNAME\.&lt;br /&gt;
&lt;br /&gt;
and allows the use of embedded spaces (when enclosed in quotation marks) in directory&amp;nbsp;names like:&lt;br /&gt;
&lt;br /&gt;
"..\COMMON DIRECTORY\"&lt;br /&gt;
&lt;br /&gt;
However, while the latter may be allowed, we tend to subscribe to the principle that&amp;nbsp;'although you can use embedded spaces, arsenic is quicker.' (The same, by the way, applies to&amp;nbsp;file names with spaces!) While improving readability, spaces can also cause problems when&amp;nbsp;trying to handle files and directories programmatically and we still feel that the best advice is&amp;nbsp;to avoid them wherever possible in applications. For example, the following code works&amp;nbsp;perfectly well for conventional directory names, but will fail if the selected directory contains&amp;nbsp;embedded spaces:&lt;br /&gt;
&lt;br /&gt;
LOCAL lcDir&lt;br /&gt;
lcDir = GETDIR()&lt;br /&gt;
IF ! EMPTY(lcDir)&lt;br /&gt;
&amp;nbsp;SET DEFAULT TO &amp;amp;lcDir&lt;br /&gt;
ENDIF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Making sure VFP is only started once&lt;/b&gt;&lt;br /&gt;
So far so good! We have managed to cover the process of starting VFP and setting up the basic&amp;nbsp;environments for both development and production. At this point one of the things we all come&amp;nbsp;across is the absent-minded user who minimizes an application and then, ten minutes later,&amp;nbsp;starts a fresh copy from their desktop. Within the hour they have six copies of the application&amp;nbsp;running and are complaining that their machine is slowing down. What to do? (Apart from&amp;nbsp;shooting the user which, appealing though the idea may be, is generally frowned upon and,&amp;nbsp;depending on their seniority, may also be a career-limiting move.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Closing VFP down&lt;/b&gt;&lt;br /&gt;
Thus far we have been concentrating on setting up and managing the Visual FoxPro&amp;nbsp;environment, however, the way in which you close down Visual FoxPro is just as important. In&amp;nbsp;the run-time environment there are two ways of initiating the closing down process. Firstly&amp;nbsp;through the use of the CLEAR EVENTS command, either within a menu or in the Release method&amp;nbsp;of a form. Secondly through the standard windows close button of the main Visual FoxPro&amp;nbsp;window. Fortunately, Visual FoxPro provides us with a global handler for the close down&amp;nbsp;process, irrespective if how it is initiated – the ON SHUTDOWN command.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;What is an On ShutDown procedure?&lt;/b&gt;&lt;br /&gt;
Like other ON commands, the ON SHUTDOWN command is implemented by a special handler that&amp;nbsp;is outside of the normal Visual FoxPro event processing loop. When invoked, control is&amp;nbsp;immediately transferred to whatever command, or function, has been specified as the target.&amp;nbsp;This is by far the best way (if not the only way) to ensure that Visual FoxPro closes down&amp;nbsp;cleanly without the irritating the 'Cannot Quit Visual FoxPro' message.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;What triggers an On Shutdown procedure?&lt;/b&gt;&lt;br /&gt;
The command specified in ON SHUTDOWN is executed if you try to exit Visual FoxPro by&amp;nbsp;clicking the 'Close' button in the main Visual FoxPro screen, by choosing Exit from the&amp;nbsp;FoxPro control menu, or by issuing the QUIT command in a program (or the command&amp;nbsp;window!). Additionally it will be triggered if you try to exit Windows while Visual FoxPro is&amp;nbsp;open. (Control is returned to Visual FoxPro and the specified ON SHUTDOWN procedure is&amp;nbsp;executed.)</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><title>Starting Visual FoxPro</title><link>http://visualfoxpro9.blogspot.com/2011/06/starting-visual-foxpro.html</link><category>Controlling the VFP Environment</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Tue, 14 Jun 2011 00:47:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-8328145047558694609</guid><description>Visual FoxPro, like most applications, supports several 'command line switches'. Most of the&lt;br /&gt;
time these tend to get forgotten, but they do exist and are all documented in the online Help&lt;br /&gt;
files in the 'Customizing Visual FoxPro Startup Options' topic. Probably the most useful ones&lt;br /&gt;
to remember are:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;-C which specifies the configuration file to use&lt;/li&gt;
&lt;li&gt;-T which suppresses the VFP sign-on screen&lt;/li&gt;
&lt;li&gt;-R which refreshes the VFP registry settings (Note, the settings that get refreshed are&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
those relating to information about VFP, such as file associations. The –R switch does&lt;br /&gt;
not update the settings controlled through Visual FoxPro's Options Dialog. This is&lt;br /&gt;
only done when 'Set As Default' is used to exit the dialog).&lt;br /&gt;
So to start Visual FoxPro without the sign-on screen display and with a refresh of the&lt;br /&gt;
registry settings the required command line would be:&lt;br /&gt;
G:\VFP60\VFP6.EXE –R -T</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>About Visual FoxPro</title><link>http://visualfoxpro9.blogspot.com/2011/06/visual-foxpro.html</link><category>Visual FoxPro</category><author>noreply@blogger.com (Albert Chuah)</author><pubDate>Mon, 13 Jun 2011 23:50:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-1271719377682009086.post-4264585228199902285</guid><description>&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="line-height: 1.5em; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em;"&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.4em;"&gt;&lt;span class="Apple-style-span" style="line-height: 24px;"&gt;&lt;b&gt;Visual FoxPro is a data-centric object-oriented and procedural programming language produced by Microsoft. It is derived from FoxPro (originally known as FoxBASE) which was developed by Fox Software beginning in 1984. Fox Technologies merged with Microsoft in 1992, after which the software acquired further features and the prefix "Visual". The last version of FoxPro (2.6) worked under Mac OS, DOS, Windows, and Unix: Visual FoxPro 3.0, the first "Visual" version, reduced platform support to only Mac and Windows, and later versions were Windows-only. The current version of Visual FoxPro is COM-based and Microsoft has stated that they do not intend to create a Microsoft .NET version.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="line-height: 24px;"&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div style="line-height: 24px;"&gt;&lt;b&gt;FoxPro originated as a member of the class of languages commonly referred to as "xBase" languages, which have syntax based on the dBase programming language. Other members of the xBase language family include Clipper and Recital. (A history of the early years of xBase can be found in the dBase article.)&lt;/b&gt;&lt;/div&gt;&lt;div style="line-height: 24px;"&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div style="line-height: 24px;"&gt;&lt;b&gt;Visual FoxPro, commonly abbreviated as VFP, is tightly integrated with its own relational database engine, which extends FoxPro's xBase capabilities to support SQL query and data manipulation. Unlike most database management systems, Visual FoxPro is a full-featured, dynamic programming language that does not require the use of an additional general-purpose programming environment. It can be used to write not just traditional "fat client" applications, but also middleware and web applications.&lt;/b&gt;&lt;/div&gt;&lt;div style="line-height: 24px;"&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="line-height: 24px;"&gt;In late 2002, it was demonstrated that Visual FoxPro can run on Linux under the Wine Windows compatibility suite. In 2003, this led to complaints by Microsoft: it was claimed that the deployment of runtime FoxPro code on non-Windows machines violates the End User License Agreement.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="line-height: 24px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="line-height: 24px;"&gt;In December 2005, VFP broke into the top 20 on Tiobe index for the first time. In March 2007 it was at position 19, making it a "B" language. As of August, 2010, VFP (combined with xBase) is at position 25.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="line-height: 24px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="line-height: 24px;"&gt;In March 2007, Microsoft announced that there will be no VFP 10, thus making VFP 9 (released to manufacturing on December 17, 2004) the last commercial VFP release from Microsoft. The support of Version 9 is ongoing with service packs that were released December 8, 2005 and October 11, 2007.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="line-height: 24px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="line-height: 24px;"&gt;At the time of the end of life announcement, work on the next release codenamed Sedna (named after a recently discovered dwarf planet) which was built on top of the VFP9 codebase had already begun. "Sedna" is a set of add-ons to VFP 9.0 of xBase components to support a number of interoperability scenarios with various Microsoft technologies including SQL Server 2005, .NET Framework, Windows Vista, Office 2007, Windows Search and Team Foundation Server (TFS). Microsoft released Sedna under the Shared source license on the CodePlex site. Microsoft has clarified that the VFP core will still remain closed source. Sedna was released on January 25, 2008[4]. As of March 2008, all xBase components of the VFP 9 SP2 (including Sedna) were available for community-development on CodePlex.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="line-height: 24px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="line-height: 24px;"&gt;In late March 2007 a grassroots campaign was started by the Spanish-speaking FoxPro community at MasFoxPro (MoreFoxPro in English) to sign a petition to Microsoft to continue updating Visual FoxPro or release it to the community as Open Source. On April 3, 2007 the movement was noted by the technical press.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item></channel></rss>