Command APPEDIT Foundation
Creates an Application Part to edit databases
[INTO <oAppEdit>] ;
[ FIELDS <cFieldName,...> ] ;
[ PARENT <oParent> ] ;
[ POSITION <pos1> [, <pos2>] ] ;
[ SIZE <size1> [, <size2>] [PERCENT] ] ;
[ TITLE <cTitle> ] ;
[ COLOR <nForeGround> [, <nBackGround>] ] ;
[ FONT <cFontCompoundName> ] ;
[ HEADING <headingOptions> ] ;
[ CAPTION <captionOptions> ] ;
[ NOACTION <nSuppress> ] ;
[ STYLE PLAIN | 3D | FANCY | <nStyle> ] ;
[ BITMAP <nBitmapID> [ FIT ] ]
[ ALIAS <cAlias> ] ;
[ FOR <lForCondition> ] ;
[ WHILE <lWhileCondition> ] ;
[ SEEK <exprSeek> ] ;
[ TRIGGER <deleteFunc> [ON] DELETE ] ;
[ TRIGGER <insertFunc> [ON] INSERT ] ;
[ TRIGGER <updateFunc> [ON] UPDATE ] ;
|<pos1> is an array containing grafic coordinates for the AppEdit window
|<pos1> is a numeric value used as row coordinate, and <pos2> specifies the column coordinate according to a text mode window
|The AppEdit window is displayed
|at the top, left, bottom, right
|and/or centered within its parent,
|according to the keywords used
|A two element array defines the size in pixel
|Two numeric values specify the number of rows and columns according to a text mode window
|Pushbutton "First" is suppressed
|Pushbutton "Previous" is suppressed
|Pushbutton "Next" is suppressed
|Pushbutton "Last" is suppressed
|Pushbutton "New" is suppressed
|Pushbutton "Delete" is suppressed
|Pushbutton "Cancel" is suppressed
|Pushbutton "Edit" is suppressed
|Pushbutton "Seek" is suppressed
|Pushbuttons for navigation are suppressed
|Pushbuttons for editing are suppressed
|No pushbuttons are displayed
|Fields are not automatically created
|Is equal to STYLE FANCY
|Is equal to STYLE 3D
|Is equal to STYLE PLAIN
|The border of the dialog window is suppressed
|The title of the dialog window is suppressed
|Control elements in the title bar are suppressed (maximize, minimize button and system menu)
|The heading of the AppEdit window is suppressed
|The status bar is suppressed
|Pushbuttons are displayed as icons
|Pushbuttons have text captions
|Pushbuttons are displayed at the top of the AppEdit window
|Pushbuttons are displayed on the left in the AppEdit window
|Pushbuttons are displayed at the bottom of the AppEdit window
|Pushbuttons are displayed on the right in the AppEdit window
|Frames appear in raised style
|Fields are positioned horizontally row by row
APPEDIT is a very powerful command that allows to program standardized edit dialogs for databases in a comfortable way. It creates an object of the AppEdit class and adds Xbase Parts, which access database fields.
Although the command has many options it is easy to use. The minimum requirements to display an edit dialog are three lines of code:
These three lines open a database (USE), create an AppEdit object (APPEDIT), and display it (APPDISPLAY). The AppEdit window contains edit controls for all fields of the database. In addition, pushbuttons are included for database navigation. All other options of the APPEDIT command are used to configure the edit window in detail or to specify the fields and pushbuttons to be displayed.
|Defines the parent
|Positions the AppBrowse window within the parent
|Defines the size of the AppBrowse window
|Character string to be displayed in the title bar
|Defines colors for table columns
|Defines font for table columns
|Defines colors, font and alignment of a heading
|Defines colors, font and alignment for captions
|Defines display style
|Suppresses default controls
|Defines a background bitmap
The most important options for display are PARENT, STYLE, POS and SIZE.
The key word PARENT decides whether or not an AppEdit object is displayed within its own dialog window. When the option PARENT is used, the edit window is displayed without a dialog frame within the parent window. If PARENT is not specified, the AppEdit window is created having its own dialog window. It is then displayed on the desktop (AppDesktop()).
The option STYLE defines the appearance of an AppEdit window. The default style is 3D. Three predefined styles can be selected for an AppEdit window using key words: STYLE PLAIN, STYLE 3D and STYLE FANCY.
The option POS allows to position an AppEdit window within its parent window using different units for coordinates. The units 'pixel', 'text coordinates' and the key words TOP, LEFT, BOTTOM, RIGHT, CENTER are supported. This provides maximum flexibility for positioning of an AppEdit window. Different possibilities are shown below:
A pixel-exact positioning is achieved with a two element array containing graphic x,y coordinates (the origin of the coordinate system is bottom, left). Numeric values are interpreted as row and column text-coordinates (the origin is top, left). Using key words an AppEdit window can be placed at well defined positions. The key word LEFT means, for example, that the AppEdit is displayed on the left side of its parent window. TOP, CENTER displays it at the top and centers it horizontally.
The option SIZE defines the size of the display area of the AppEdit window (this is equal to the size of XbpDialog:drawingArea). A two element array defines the size in x and y direction (width and height), the unit is 'pixel'. Numeric values specify the number of rows and columns according to a text-mode window. If the key word PERCENT is specified, numeric values are used as percentage to calculate width and height from the size of the parent window (range 0-100).
Options for database access
The next table list all options relevant for database access:
|Names of fields to be displayed
|Alias name of the work area used for navigation
|Condition for database records to display
|Condition executed after SKIP
|Expression executed by the "Seek" pushbutton
|TRIGGER ON DELETE
|User function executed prior to DELETE
|TRIGGER ON INSERT
|User function executed prior to APPEND BLANK
|TRIGGER ON UPDATE
|User function executed prior to REPLACE
If database navigation is not to take place in the current work area, the alias name of the corresponding work area must be specified with the ALIAS option. The option FIELD specifies the fields to be edited in the AppEdit window. Field names must be programmed as literals or as character expressions in parentheses. If fields from multiple work areas are to be displayed, the field names must be alias referenced. Edit controls in the edit window are displayed in the same order like the fields are specified. Instead of using the FIELDS option, fields can be specified using the APPFIELD command prior to displaying the edit window with APPDISPLAY. If neither FIELDS nor APPFIELD is used the AppEdit window contains edit controls for all fields of the specified work area.
The other options for database operations are expressions, or code blocks, to be executed in case of particular database operations. Logical expressions must be used for the FOR and WHILE options. Both are evaluated after the record pointer is moved. If the FOR condition evaluates to .F. (false) the record pointer is moved until the result in .T. (true) or the end of file is reached.
Expressions for the SEEK and TRIGGER ON... options must return a numeric value that corresponds to #define constants listed in the next table:
|AppEdit proceeds with the database operation and refreshes the display
|AppEdit performs no database operation and does not refresh the display
|AppEdit performs no database operation and refreshes the display
The SEEK expression is used to call a user defined search routine from AppEdit when the "Seek" pushbutton is clicked. If return value of the expression is APPOP_PROCEED, the AppEdit window is refreshed. Otherwise the record pointer is positioned on the record that was current before the SEEK expression was evaluated.
After the key word TRIGGER a character string with the name of a user defined function, or a code block, receiving one parameter must be specified. AppEdit evaluates a trigger prior to one of the database operations Insert, Update and Delete. A one dimensional array containing the current buffers of all edit controls in the AppEdit window is passed to the function, or code block, respectively. The sequence of the values in the array is defined by the sequence of field names specified with the FIELDS option (the value for the first specified field is stored in the first array element aso.) All values have the same data type like the corresponding fields (except memo fields).
The return value of the user defined function, or the trigger code block, must be one of the above listed #define constants.
TRIGGER <...> ON DELETE
The user function, or code block, is executed when the "Delete" pushbutton is clicked. By default this results in a DELETE operation. Before the current record actually gets deleted, AppEdit evaluates the DELETE trigger. If this returns APPOP_PROCEED, the AppEdit object deletes the record and refreshes the window. The return value APPOP_IGNORE suppresses deletion, and AppEdit does nothing. The window is refreshed without deleting the record, if APPOP_REFRESH is returned. In this case the user function must perform the DELETE operation.
TRIGGER <...> ON INSERT
The user function, or code block, is executed when the "Save" pushbutton is clicked while AppEdit is in INSERT mode.
AppEdit appends a blank record before writing data to the database. Prior to adding a new record AppEdit evaluates the INSERT trigger. If this returns APPOP_PROCEED, the AppEdit object appends a new record and writes data from the edit controls to the corresponding database fields. The return value APPOP_IGNORE suppresses an APPEND BLANK, and AppEdit does nothing. The window is refreshed without adding a new record, if APPOP_REFRESH is returned. In this case the user function must perform the APPEND BLANK operation and must write data to the database.
TRIGGER <...> ON UPDATE
The user function, or code block, is executed when the "Save" pushbutton is clicked while AppEdit is in EDIT mode.
By default this results in REPLACE operations. Before the data from edit controls are written to the current record, AppEdit evaluates the UPDATE trigger. If this returns APPOP_PROCEED, the AppEdit object updates the record with buffered data. The return value APPOP_IGNORE suppresses the update, and AppEdit does nothing. The window is refreshed without updating the record, if APPOP_REFRESH is returned. In this case the user function must write data to the current record. It also must guarantee record locks to be set if the database is open in SHARED mode.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.