set default command function: specifies the default drive and directory. syntax: set default to...

75
Some of Visual Foxpro’s Commands

Upload: alicia-bruce

Post on 04-Jan-2016

233 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Some of Visual

Foxpro’s Commands

Page 2: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

SET DEFAULT Command

•Function: Specifies the default drive and directory.

•Syntax:SET DEFAULT TO [cPath]

Page 3: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters

cPath. Specifies one of the following: •A drive designator•A drive designator with a directory name•A child directory name•Any of the above using Microsoft MS-DOS shorthand notation ( \ or ..)

Page 4: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks

•SET DEFAULT changes the default directory to the directory you specify.•Microsoft® Visual FoxPro® searches for a file in the default Visual FoxPro directory. The default directory is the one from which you start Visual FoxPro. However, you can specify a different default directory in your Visual FoxPro configuration file or in a startup program.

Page 5: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks…

•If Visual FoxPro cannot find a file in the default directory, it then searches the Visual FoxPro path if one has been specified. Use SET PATH to specify the Visual FoxPro path.

•If you create a file and do not specify where to place it, the file is placed in the default Visual FoxPro directory.

Page 6: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks…

•The SET DEFAULT command is not supported in either single or multithreaded DLL servers. This command changes the default directory of the entire process, so all threads which are part of the process are affected. Use the SET PATH command in DLL servers, in place of CD and CHDIR.

Page 7: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Tips

•SYS(5) returns the default drive.

•SYS(2003) returns the default directory with no drive designator.

•SYS(5) + SYS(2003) returns the default drive and the directory.

Page 8: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Examples

Set Default to D && Changes default drive to D

Set Default to D: && Changes default drive to D

Set Default to D:\Bruno\ExercisesSet Default to D:\Bruno && Specifies a specific directory

Set Default to Exercises && Changes the default directory to D:\Exercises if the root directory on drive D is the default directory of Visual Foxpro.Note: && indicates the start of an inline comment.

Page 9: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Examples…

Set Default to \ && Makes the root directory the default directory – that is, if the current directory is other than the root directory (e.g., D:\Bruno\Exercises)

Set Default to .. && Moves the default directory one level (up) towards the root directory.

Page 10: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

CREATE Command

•Function: Opens the Table Designer so you can create a Visual FoxPro table.

•Syntax:Create [filename│?]

Page 11: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters

[ FileName| ?] Specifies the name of the table to create or opens the Create dialog box so you can browse for a location to save the table and specify the name of the table to create.• If FileName is specified, it opens the Table Designer so you

could define the fields and their attributes in the table.• If ? is used, it opens the Create dialog box so you can

browse for a location to save the table and specify the name of the table to create.

Page 12: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks

• If a database is open when you create a table, the table is added automatically to the database.•When running on the Windows operating system, you cannot create a table with the name of an MS-DOS device, such as CON, NUL, PRN, and COM1. Avoid using hyphens in a table name because hyphenated table names do not appear in the Data Session window and can cause confusion with the alias pointer (->).

Page 13: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks…

•After opening the Table Designer, you need to define attributes for the fields in the table. After you create the table structure, you can add records to the table. For more information, see Creating Tables.•The SQL CREATETABLE command makes it possible to specify fields and their attributes programmatically. For more information, see CREATE TABLE - SQL Command.

Page 14: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Examples

Set Default to F:\BrunoCreate Students

Set Default to D:\BrunoCreate ?

Page 15: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

APPEND Command

•Function: Adds one or more new records to the end of a table.

•Syntax:APPEND [BLANK] [IN nWorkArea | cTableAlias] [NOMENU]

Page 16: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters

BLANK adds one blank record to the end of the current table. Visual FoxPro does not open an editing window when you issue APPEND BLANK. You can edit the new record with BROWSE, CHANGE, or EDIT.

IN nWorkArea specifies the work area of the table to which a new record is appended.

Page 17: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

IN cTableAlias specifies the alias of the table to which a new record is appended. If you omit nWorkArea and cTableAlias, a new record is appended to the table in the currently selected work area. If you issue APPEND, a blank record is added to the table you specify with nWorkArea or cTableAlias and the table is automatically selected. If you issue APPEND BLANK, a blank record is added to the table you specify with nWorkArea or cTableAlias and the table is not selected.

Page 18: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

NOMENU specifies that the Table menu title is removed from the system menu bar, preventing changes to the format of the editing window.

Page 19: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

DELETE Command

•Function: Marks records for deletion.

•Syntax:DELETE [Scope] [FOR lExpression1] [WHILE lExpression2] [IN nWorkArea | cTableAlias] [NOOPTIMIZE]

Page 20: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters

Scope. Specifies a range of records to mark for deletion. The default scope for DELETE is the current record (NEXT 1). The scope clauses are: ALL, NEXT nRecords, RECORD nRecordNumber, and REST. For more information on scope clauses, see Scope Clauses.

Page 21: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

FOR lExpression1. Specifies a condition whereby only the records that satisfy the logical condition lExpression1 are marked for deletion. Rushmore Query Optimization optimizes a query created with DELETE ... FOR if lExpression1 is an optimizable expression and the table is indexed on DELETED( ). For best performance, use an optimizable expression in the FOR clause. For information on Rushmore optimizable expressions, see SET OPTIMIZE, and Using Rushmore Query Optimization to Speed Data Access in Optimizing Applications.

Page 22: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

WHILE lExpression2. Specifies a condition whereby records are marked for deletion for as long as lExpression2 evaluates to true (.T.).

IN nWorkArea. Specifies the work area of the table in which records are marked for deletion.

Page 23: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

IN cTableAlias. Specifies the alias of the table in which records are marked for deletion. If you omit nWorkArea and cTableAlias, records are marked for deletion in the table in the currently selected work area.

NOOPTIMIZE. Disables Rushmore optimization of DELETE.

Page 24: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks

•Records marked for deletion aren't physically removed from the table until PACK is issued. Records marked for deletion can be recalled (unmarked) with RECALL.

Page 25: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Example

The following example opens the Customer table in the TestData database. DELETE is used to mark all records for deletion where the Country field contains USA. All the records marked for deletion are displayed. RECALL ALL is used to unmark all records marked for deletion.

Page 26: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Example…

CLOSE DATABASES OPEN DATABASE (HOME(2) + 'Data\testdata') USE customer && Opens Customer table DELETE FOR country = 'USA' && Marks for deletion CLEAR LIST FIELDS company, country FOR DELETED( ) && Lists marked records RECALL ALL && Unmark all records marked for deletion.

Page 27: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

SET PATH Command

•Function: Specifies a path for file searches.

•Syntax:SET PATH TO [Path] [ADDITIVE]

Page 28: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters

TO [Path] specifies the directories you want Visual FoxPro to search. Use commas or semicolons to separate the directories.

[ADDITIVE] appends additional paths to the end of the current path.

Page 29: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Note

•Visual FoxPro will not recognize a path name properly if a disk or directory name contains an exclamation point (!)•On all FoxPro platforms, functions that return path information, such as CURDIR( ), DBF( ), and SYS(2003), use Microsoft MS-DOS path-naming conventions in their return values.

Page 30: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks

• Issue SET PATH TO without Path to restore the path to the default directory. Use SET DEFAULT to specify the default directory and CURDIR( ) to return the current default directory.•SET PATH is not scoped to the current data session; changes

you make to the default path using the SET PATH command affect all data sessions.•SET PATH is limited to a maximum of 4095 characters.•When using the ADDITIVE parameter, paths must be included

either as a quoted string or valid expression.

Page 31: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Examples

ff = [“Bruno3"]SET PATH TO &ff ADDITIVE ** or **ff = “Bruno3“SET PATH TO '&ff' ADDITIVE

Note: * indicates the start of a line comment.

Page 32: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Go │ Goto Command• Function: Moves the record pointer to the specified record

number.• Syntaxes:•GO [RECORD] nRecordNumber [IN nWorkArea | IN

cTableAlias]•GO TOP | BOTTOM [IN nWorkArea | IN cTableAlias]•GOTO [RECORD] nRecordNumber [IN nWorkArea | IN

cTableAlias]•GOTO TOP | BOTTOM [IN nWorkArea | IN cTableAlias]

Page 33: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters

•RECORD nRecordNumber. Specifies the physical record number to move the record pointer to. You can omit GO or GOTO entirely and specify just the record number. If you specify just the record number, you can move the record pointer only within the current work area.

•IN nWorkArea. Specifies the work area of the table in which the record pointer is moved.

Page 34: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters …

• IN cTableAlias. Specifies the alias of the table in which the record pointer is moved.

•TOP. Positions the record pointer on the first record in the table. If the table has an ascending index in use, the first record is the record with the lowest key value. If the index is in descending order, the first record is the record with the highest key value.

Page 35: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

•BOTTOM. Positions the record pointer on the last record in the table. If the table has an ascending index in use, the last record is the record with the highest key value. If the index is in descending order, the last record is the record with the lowest key value.

Parameters …

Page 36: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks

•GO and GOTO can be used interchangeably. These commands operate on the table in the current work area unless you specify another work area with the IN clause.

Page 37: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Example

CLOSE DATABASES OPEN DATABASE (HOME(2) + 'data\testdata') USE products && Opens Products table USE customer IN 0 && Opens Customer table GO BOTTOM IN products CLEAR ? RECNO('products') GO TOP ? RECNO( ) && Displays 1 GO 5 ? RECNO( ) && Displays 5

Page 38: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

? │ ?? Command

• Function: Evaluates expressions and sends the results to the main Visual FoxPro window, an active user-defined window, or the printer.• Syntax:•? | ?? Expression1 [PICTURE cFormatCodes] | [FUNCTION cFormatCodes] | [VnWidth] [AT nColumn] [FONT cFontName [, nFontSize [, nFontCharSet]] [STYLE cFontStyle | Expression2]] [, Expression3] …

Page 39: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters

•? Expression1. Evaluates the expression specified by Expression1 and sends a carriage return and line feed preceding the expression results. The results display on the next line of the main Visual FoxPro window or the active user-defined window and are printed at the left margin of a page unless a function code specified by cFormatCodes or the _ALIGNMENT system variable specifies otherwise.

Page 40: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

If you omit the expressions, a blank line is displayed or printed. A space is placed between expression results when multiple expressions are included. If Expression1 is an object, the ? command returns the character string, "(Object)".

Page 41: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

•?? Expression1. Evaluates the expression specified by Expression1 and displays the expression results on the current line at the current position of the main Visual FoxPro window, an active user-defined window, or the printer. A carriage return and line feed are not sent before the results.

Page 42: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

•PICTURE cFormatCodes. Specifies a picture format in which the result of Expression1 is displayed. cFormatCodes can consist of function codes, picture codes, or a combination of both. You can use the same codes available in the Format Property and InputMask Property. Function codes affect the overall format of the result; picture codes act on individual characters in the result.

Page 43: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

If function codes are used in cFormatCodes, they must appear before the picture codes and they must be preceded by an at (@) sign. Multiple function codes with no embedded spaces can immediately follow the @ sign. The last function code must be followed by one or more spaces. The space or spaces signal the end of the function codes and the start of the picture codes.

Page 44: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

•FUNCTION cFormatCodes. Specifies a function code to include in the output from the ? and ?? commands. If the function clause is included, do not precede the function codes with an @ sign. Function codes must be preceded by a @ sign when included in PICTURE.

Page 45: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

•V nWidth. Specifies a special function code that enables the results of a character expression to stretch vertically within a limited number of columns. nWidth specifies the number of columns in the output.

? 'This is an example of how the V function code works.' ; FUNCTION 'V10'

Page 46: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

•AT nColumn. Specifies the column number where the output is displayed. This option makes it possible for you to align output in columns to create a table. The numeric expression nColumn can be a user-defined function that returns a numeric value.

Page 47: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

•FONT cFontName[, nFontSize [, nFontCharSet]]. Specifies a font for output by the ? or ?? command. cFontName specifies the name of the font, and nFontSize specifies the point size. You can specify a language script with nFontCharSet. See the GETFONT( ) Function for a list of available language script values. For example, the following command displays the system date in 16-point Courier font:

Page 48: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

•FONT cFontName[, nFontSize [, nFontCharSet]]. Specifies a font for output by the ? or ?? command. cFontName specifies the name of the font, and nFontSize specifies the point size. You can specify a language script with nFontCharSet. See the GETFONT( ) Function for a list of available language script values. For example, the following command displays the system date in 16-point Courier font: • ? DATE( ) FONT 'Courier',16

Page 49: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters…

If you include the FONT clause but omit the point size nFontSize, a 10-point font is used. If you omit the FONT clause, and output for the ? or ?? command is placed in the main Visual FoxPro window, the main Visual FoxPro window font is used for the output. If you omit the FONT clause, and output for the ? or ?? command is placed in a user-defined window, the user-defined window font is used for the output. Note: If the font you specify is not available, a font with similar font characteristics is substituted.

Page 50: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

??? Command

•Function: Sends output directly to the printer.•Syntax:•??? cExpression

Page 51: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Parameters

•cExpression. Specifies the characters that are sent to the printer.

Page 52: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks

• A group of three question marks bypasses the printer driver and sends the contents of cExpression directly to the printer. cExpression must contain valid printer codes.• Printer control codes make it possible for you to reset the printer,

change type styles and sizes, and enable or disable boldface printing. These codes can consist of any combination of printable or nonprintable characters that are specific to the printer you are using. You can direct control codes to the printer in several different ways: • Use combinations of CHR( ) and quoted strings concatenated

with + to send ASCII characters directly to the printer.

Page 53: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks…

• Tables store data in a row and column format, similar to a spreadsheet. Each row represents a record, and each column represents the fields in each record. Tables in Visual FoxPro can exist as a free table or as a database table. •A free table is a table (.dbf) file that is not associated with

any database. A database table is a table file that is associated with a database. Database tables can have properties that free tables do not have, such as field-level and record-level rules, triggers, and persistent relationships.

Page 54: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Format Property

• Function: Specifies the input and output formatting of a control's Value property. Available at design time and run time.

• Syntax:Control.Format[ = cFunction]

Page 55: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Return Value

•cFunction. Specifies the character constraints for data entry and formatting for display. The following table lists the valid cFunction values for the appropriate controls.

Page 56: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

cFunction Description EditBox control

K Selects all the text when the control gets focus.

Page 57: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

cFunction Description

Spinner control

$ Displays the currency symbol.

^ Displays numeric data using scientific notation.

K Selects all the text when the control gets the focus.

L Displays leading zeros instead of spaces in the text box.

Page 58: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

cFunction Description

Spinner control…

R

Displays the format mask for the text box that is specified in the InputMask property. The mask formats data for easier entry and clearer display (for example, if the mask is 99-999, the number 12345 is displayed as 12-345), but is not stored as part of the data. Use only with character or numeric data.

Page 59: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

cFunction Description TextBox control and Column object

! Converts alphabetic characters to uppercase. Use with data of Character type only.

$Displays the currency symbol. The ControlSource property must specify a numeric source for the text box.

^Displays numeric data using scientific notation. The ControlSource property must specify a numeric source for the text box.

Page 60: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

cFunction Description

TextBox control and Column object …

A Allows alphabetic characters only with no spaces or punctuation marks.

D Uses the current SET DATE format.E Edits Date values as British dates.

FPrevents Varchar values from being padded with trailing spaces in text boxes or Varbinary values from being padded with trailing zeroes (0s).

Page 61: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Notes

•For text boxes bound to data with Varchar type, the MaxLength property must be set to a nonzero value to permit input for the desired number of characters.•When you drag a field with Varchar type to a form, the

created text box's Format property is set to "F", and the MaxLength property is set to the maximum length for the Varchar field. When you drag a Grid control to a form and create TextBox controls for columns with Varchar type, the Format property is set to "F", and the MaxLength property is set to the maximum length for the Varchar field.

Page 62: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Notes

•When you drag a field with Varbinary type to a form or when you drag a Grid control to a form and create TextBox controls for columns with Varbinary type, the following occur:Format property is set to "F".MaxLength property is set to the maximum length multiplied by 2 for the Varchar field.

InputMask property is filled with "H" up to the value of the MaxLength property.

Page 63: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

cFunction Description

TextBox control and Column object …

K Selects all the text when the control gets the focus.

LDisplays leading zeros instead of spaces in the text box. The ControlSource property must specify a numeric source for the text box.

M Included for backward compatibility.

Page 64: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

cFunction Description TextBox control and Column object …

RDisplays the format mask for the text box that is specified in the InputMask property. The mask formats data for easier entry and clearer display. For example, if the mask is 99-999, the number 12345 is displayed as 12-345 but is not stored as part of the data. Use only with Character or Numeric data.

T Trims leading and trailing blanks from the input field.

YSDisplays Date values in a short date format determined by the Windows Control Panel short date setting.

YL Displays Date values in a long date format determined by the Windows Control Panel long date setting.

Page 65: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

cFunction Description

EditBox control, TextBox control, Column object, and Spinner control

Z

Displays the value as blank if it is 0, except when the control has focus.Dates are also supported in these controls. The / / date delimiters are not displayed unless the control has focus.

Page 66: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Remarks

•Applies To: Column | ComboBox | EditBox | Spinner | TextBox•The Format property specifies a behavior for the entire

input field. You can mix several Format codes, but they always affect everything in the input field. This property contrasts to the InputMask property in which each entry in the input mask corresponds to an entry in the input field.•The Format property mimics the behavior of the

FUNCTION clause in the @ ... GET and @ ... EDIT commands

Page 67: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Table Creation

•Tables store data in a row and column format, similar to a spreadsheet. Each row represents a record, and each column represents the fields in each record. Tables in Visual FoxPro can exist as a free table or as a database table. •A free table is a table (.dbf) file that is not associated with

any database. A database table is a table file that is associated with a database. Database tables can have properties that free tables do not have, such as field-level and record-level rules, triggers, and persistent relationships.

Page 68: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Table Creation…

•The following list includes some of the benefits database tables offer: Long names for the table and for each field in the table.Captions and comments for each table field.Default values, input masks, and format for table fields.Default control class for table fields.Field-level and record-level rules.Primary key indexes and table relationships to support

referential integrity rules.One trigger for each INSERT, UPDATE, or DELETE event.

Page 69: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Table Creation…

•However, free tables are useful for storing information outside of a database. For example, for example, you can use free tables to store lookup information that multiple databases share. For more information about the benefits of associating tables with a database, see Databases in Visual FoxPro.•To view a sample table, open one of the table (.dbf) files for the Northwind database located in the Visual FoxPro ...\Samples\Northwind directory. For more information, see How to: View Records in Tables.

Page 70: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

Considerations for Table Creation

•When creating tables, remember the following considerations: Make sure field's data type matches the type of information you

want to store.Make sure the field is wide enough to accommodate the

information it stores and displays.Set an appropriate number of decimal places for Numeric or

Float fields.Make sure that fields that can accept null values are configured

to accept them.

Page 71: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

How to: View Records in Tables

•You can view the records in a table by opening it in a browse window. A browse window displays data in a table as rows (records) and columns (fields) that you can scroll through. For more information, see Browse Window.

Page 72: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

To browse data in a free table

1. On the File menu, click Open. 2. In the Open dialog box, browse to the

location of the table you want to view.3. In the Files of type box, select the Table

(*.dbf) file type to display only table files. 4. Select the table file you want to view.5. On the View menu, click Browse. The table you selected opens in a browse window.

Page 73: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

To browse data in a database table

1. Open the database in the Database Designer.

2. Select the table you want.3. On the Database menu, click Browse.

The table opens in a browse window.

Page 74: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

To browse data in a table from a project

1. Open the project in the Project Manager.2. Expand the Data node and choose one of the following: • To browse a database table, expand the Databases node,

then the Tables node.-OR- • To browse a free table, expand the Free Tables node.

3. Click the table you want to view, and then Browse.

The table you selected opens in a browse window.

Page 75: SET DEFAULT Command Function: Specifies the default drive and directory. Syntax: SET DEFAULT TO [cPath]

To browse a table programmatically

1. Open the table with the USE command.2. Follow USE with the BROWSE command.

Tip:To prevent users from adding records to a table while browsing a table, include the NOAPPEND clause in the BROWSE command.