Beruflich Dokumente
Kultur Dokumente
Sample Structure
Let us assume the Clients.DBF for the following illustrations. The structure/layout is as follows: NAME .........Character ADDRESS ......Character CITY .........Character STATE ........Character ZIP ..........Character PHONE ........Character BALD .........Logical AGE. .........Numeric NOTES ........Memo 16 16 12 2 5 8 1 3 4
Help
Help FoxProCommand <-- enter the on-line FoxPro help system and display the information about the specified command. Help Use <-- enter the on-line help system and show the information about the command use. Help List <-- enter the on-line help system and show the information about the command list .
Modify Structure
Modify Structure<-- change the layout/structure of the database open in the current work area. Fields may be deleted with the delete button. Fields may be added with the insert button. Fields sizes and datatypes may be changed. Field positions may be switched. All of this can be done quite easily and quickly. All database records will be automatically adjusted. (See Below)
Wait
Wait Message Window Wait Window Message <-- creates a small system type window in the top right corner of the screen. This window contains the message . All processing is delayed until the user strikes a key or depresses the mouse button. When the key/mouse is depressed window disappears and processing continues. Wait "Record Not Found" Window<-- creates a small system type window in the top right corner of the screen. This window contains the message "Record Not Found". All processing is delayed until the user strikes a key or depresses the mouse button. Wait Window "Hit Any Key To Continue" Timeout 5 <-- creates a small system type window in the top right corner of the screen. This window contains the message "Hit Any Key
To Continue". All processing is delayed until the user strikes a key or depresses the mouse button or 5 seconds (which ever occurs first). (See Below)
Holding down the Ctrl or the Shift key will temporarily hide the wait window. (Try It!)
Modify Command
All of the FoxPro commands learned thus far may be entered into the Command Window. In order to avoid re-typing collections of commands, all of our FoxPro commands may also be placed into a program file and executed with a single command. The command illustrated in this section shall be used to group and order our commands. Modify Command FileName <-- create/modify a program file and enter the program editor. The program file will have a .PRG extension. Program files contain one or more FoxPro commands. The menu-driven program editor has the standard cut, paste, copy, etc. text processing options. Modify Command ListState<-- edits a file, called ListState, and enters the program editor. If the file ListState.PRG does not exit, it iis created and then opened to edit. If the file ListState.PRG does exit, it is opened to edit. (See Below)
File->Save <-- to save file from inside the editor File->Close <-- to exit editor ESC <-- to exit editor
Clear Display All Name, Phone, State Wait "Display of Names is Complete - Hit Any Key To Continue" Window Clear
3] File->Save [pull down the File Menu and select Save to save program file ListState.PRG] 4] ESC [ hit the ESC key to close editor]
Do
Do FileName <-- execute the commands in a program file. Do ListState <-- execute program file ListState.PRG (not case sensitive) Do liststate.PRG <-- execute program file ListState.PRG . (all program files must have a .PRG extension; including the extension is optional) Do LISTSTATE.PRG<-- execute program file ListState.PRG .
Holding down the Ctrl or the Shift key will temporarily hide the wait window. (Try It!)
1. Use blank lines to separate logic chunks 2. Indent logic chunks and loops 3. Document program code Define Window
Define Window WindowName From X1, Y1 To X2, Y2 Define Window OutputWin From 5,10 To 10,50 <-- by default, it uses the font and size of the parent window. Uses 10 point FoxFont by default. Window OutWin is defined approximately 5 rows and 40 characters to a row; the border is included in the size. When activated the window will look like the following:
Display Memory <-- displays local variables, FoxPro system variables, window definitions, menu definitions, and pop-up window definitions. The default number of user variables that may exit at any one time is 1024; this may be increased to as many as 65,000. (Only the window variables are displayed below). Window Definitions
Name From To Size
OUTPUTWIN 8.188,62.500
1 Window Defined
368
5.000,10.000 bytes
Define Window WindowName At X1, Y1 Size X2, Y2 Define Window OutputWin At 5,10 Size 5,40 <-- by default, it uses the font and size of the parent window. Uses 10 point FoxFont by default. Window OutWin is defined approximately 5 rows and 40 characters to a row; the border is included in the size.
Activate Window
Activate Window WindowName <-- open window and make it current user-defined the window must be previously defined. Activate Window OutputWin <-- open window Output as the current window.As long as OutputWin is the current window, all List, Display, etc. will appear in that window. Activate Window OutputWin, InputWin, GetStateWin ... <-- open more than one window in one command; the last window in a series becomes the current window. Input is the current window. Activate Window all <-- open all defined windows in one command; the last window in a series becomes the current window.
Activate Window OutputWin Noshow <-- direct output to a window without display.
Deactivate Window
Deactivate Window WindowName <-- close the activated window the previously defined window must be activated. Deactivate Window OutputWin <-- close the window Output. Deactivate Window OutputWin, InputWin, DisplayWin... <-- close more than one window in one command Deactivate Window all <-- closes all active windows.
Release Window
Release Window WindowName <-- close the activated window and delete the window definition. Release Window OutputWin <-- close the activated window and delete the window definition for window Output. Release Window OutputWin, InputWin, ... <-- close and delete more than one window in one command Release Window<-- close and delete the current window.
Define Window (Advanced - Fonts & Titles) Define Window OutputWin at 1, 2 Size 8, 40 Font 'ROMAN' , 16 <-- Roman 16 Font (See Below)
Define Window OutputWin at 1, 2 Size 8, 40 Font 'ROMAN' , 16 Style 'BI' <-- Bold Italic Font
Style Key Bold = B Italic = I Normal = N Outline = O Shadow = S Strikeout = Transparent = T Underline = U
Define Window OutputWin at 1, 2 Size 4, 60 Font 'ROMAN', 16 ; Style 'BI' Title 'Output Window' <-- Title Window
Define Window OutputWin at 1, 2 Size 4, 60 font 'ROMAN', 12 ; Style 'OIU' Title 'Output Window' <-- Title Window
Program NamePhone
The purpose of the program DisplayNamePhone is to (1) set the default drive and directory to folder Demo on drive C, (2) open the Clients.DBF table, (3) clear the screen, (4) define an output window, called ClientWin - include an appropriate title, (5) bring ClientWin to the desktop as the active window, (6) display the Name, Phone, and State fields of all records in ClientWin with a pause, (6) activate a wait window which displays the string "Hit Any Key To
Continue" and (7) takes down the command window.. All of these commands could be entered into the Command Window. Let us assume that this is a sequence of commands which the user wishes to do on a regular basis.
Set Default to c:\Demo Use Clients Clear Define Window ClientWin at 1, 2 size 8, 40 ; font 'ROMAN', 16 style 'BI' Title 'Client State Listing' Activate Window ClientWin Display All Name, Phone, State Wait "Done - Hit Any Key To Continue" Deactivate Window ClientWin
Do DisplayNamePhone<-- execute program file NamePhone.PRG . Do DisplayNamePhone.PRG<-- execute program file NamePhone.PRG .
Display Status
Display Status <-- display FoxPro environment information. Databases open, indexes, relations, the procedure file in use, the default drive, the current work area, etc. All of the set option variables, such as bell, escape, print, near, status bar, autosave, etc. will be displayed. As is the case with all display options, the output will pause when the screen is full. The following is output from display status:
Processor is Pentium
Currently Selected Table: Select area: 1, Table in Use: C:\CLIENT\CLIENT.DBF CLIENT Code page: 1252 Structural CDX file: C:\CLIENT\CLIENT.CDX Index tag: STATE Machine Key: ALLTRIM(UPPER(STATE)) Index tag: NAME Machine Key: ALLTRIM(UPPER(NAME)) Memo file: C:\CLIENT\CLIENT.FPT Lock(s): Exclusive USE
File search path:
Alias:
Collate: Collate:
Default directory: C:\CLIENT Print file/device: Work area Margin Decimals Memowidth Typeahead Blocksize Reprocess Refresh DDE Timeout DDE Safety
Code page: 1252
Collating sequence: Machine Compiler code page: 1252 Date format: American Macro Hot Key = UDF parameters are passed by: Textmerge Options Delimiters: Left = Show
Alternate - off
Fullpath
- on
on on on off on on off
Clear Color Compatible Confirm Console Cursor Deleted Device Echo Escape Exact Exclusive Fields Fixed
Near Null Optimize Print Readborder Safety Space Status Bar Sysmenus Talk Textmerge Title Unique
List Status
List Status <-- display FoxPro environment information. Databases open, indexes, relations, the procedure file in use, the default drive, the current work area, etc. All of the set option variables, such as bell, escape, print, near, status bar, autosave, etc. will be displayed. As is the case with all display options, the output will not pause when the screen is full. List Status To File Status<-- displays the FoxPro environment information on the screen and creates a text copy in file Status.TXT in the current directory. (no pause) List Status To Print<-- print the FoxPro environment information. (no pause)