Building a 4D Application

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 2003 (Modified)


An application is a database designed to fill a specific need. It has a user interface designed specifically to facilitate its use. The tasks that an application performs are limited to those appropriate for its purpose. Creating applications with 4th Dimension is smoother and easier than with traditional programming. 4th Dimension can be used to create a variety of applications, including:

An invoice system

An inventory control system

An accounting system

 A payroll system

 A personnel system

 A customer tracking system

A database shared over the Internet or an Intranet

It is possible that a single application could even contain all of these systems. Applications like these are typical uses of databases. In addition, the tools in 4th Dimension allow you to create innovative applications, such as:

 A document tracking system

 A graphic image management system

 A catalog publishing application

 A serial device control and monitoring system

 An electronic mail system (E-mail)

 A multi-user scheduling system

 A list such as a menu list, video collection, or music collection

An application typically starts as a database used in the User environment. The database "evolves" into an application as it is customized. What differentiates an application is that the systems required to manage the database are hidden from the user. Database management is automated, and users use menus to perform specific tasks.

When you use a 4th Dimension database in the User environment, you must know the steps to take to achieve a result. In an application, you use the Custom Menus environment, in which you need to manage all the aspects that are automatic in the User Environment. These include:

Table Navigation: The Choose Table/Form dialog box and List of Tables window are not available to the user. You can use menu commands and methods to control navigation between tables.

Menus: In the Custom Menus environment, you only have the default File menu with the Quit menu command, Edit menu, and the Help menu (Windows only) or the Apple menu (Macintosh only). If the application requires more menus, you have to create and manage them using 4D methods.

 Editors: The editors, such as the Query and Order By editors, are no longer automatically available in the Custom Menus environment. If you want to use them in the Custom Menus environment, you have to call them using 4D methods.

The following sections include examples showing how the language can automate the use of a database.

Custom Menus: an Example


Custom Menus are the primary interface in an application. They make it easier for users to learn and use a database. Creating custom menus is very simple—you associate methods or automatic actions with each menu command (also called menu items) in the Menu editor.

"The User's Perspective" section describes what happens when the user chooses a menu command. Next, "Behind the Scenes" describes the design work that made it happen. Although the example is simple, it should be apparent how custom menus make the database easier to use and learn. Rather than the "generic" tools and menu commands in the User environment, the user sees only things that are appropriate to his or her needs.

The User's Perspective

The user chooses a menu item called Create from the People menu to add a new person to the database.

The Input form for the People table is displayed.

The user enters the person's first name and then tabs to the next field.

The user enters the person's last name.

The user tabs to the next field: the last name is converted to uppercase.

The user finishes entering the record and clicks the validation button (generally the last button in the button bar).

Another blank record appears, and the user clicks the Cancel button (the one with the "X") to terminate the "data entry loop." The user is returned to the menu bar.

Behind the Scenes

The menu bar was created in the Design environment, using the Menu Bar Editor.

The menu item New has a project method named New Person associated with it. This method was created in the Design environment, using the Method editor.

When the user chooses this menu item, the New Person method executes:

   Repeat
      ADD RECORD([People])
   Until (OK=0)

The Repeat...Until loop with an ADD RECORD command within the loop acts just like the New Record menu item in the User environment. It displays the input form to the user, so that he or she can add a new record. When the user saves the record, another new blank record appears. This ADD RECORD loop continues to execute until the user clicks the Cancel button.

When a record is entered, the following occurs:

There is no method for the First Name field, so nothing executes.

There is a method for the Last Name field. This Object Method was created in the Design environment, using the Form and Method editors. The method executes:

   Last Name:=Uppercase(Last Name)

This line converts the Last Name field to uppercase characters.

After a record has been entered, when the user clicks the Cancel button for the next one, the OK variable is set to zero, thus ending the execution of the ADD RECORD loop.

As there are no more statements to execute, the New Person method stops executing and control returns to the menu bar.

Comparing an Automated Task with the Actions to be performed in the User environment


Let's compare the way a task is performed in the User environment and the way the same task is performed using the language. The task is a common one:

Find a group of records

Sort them

Print a report

The next section, "Using a Database in the User Environment," displays the tasks performed in the User environment.

The following section, "Using the Built-in Editors within the Custom Menus environment," displays the same tasks performed in an application.

Note that although both methods perform the same task, the steps in the second section are automated using the language.

Using a database in the User environment

The user chooses Query>Query... in the Records menu.

The Query editor is displayed.

The user enters the criteria and clicks the Query button. The search is performed.

The user chooses Order by from the Records menu.

The Order By editor is displayed.

The user enters the criteria and clicks the Sort button. The sort is performed.

Then, to print the records, these additional steps are required:

The user chooses Print from the File menu.

The Choose Print Form dialog box is displayed, because users need to know which form to print.

The Printing dialog boxes are displayed. The user chooses the settings, and the report is printed.

Using the built-in editors within the Custom Menus environment

Let's examine how this can be performed in the Custom Menus environment.

The User chooses Report from the People menu.

Even at this point, using an application is easier for the users—they did not need to know that querying is the first step!

A method called My Report is attached to the menu command; it looks like this:

   QUERY ([People])
   ORDER BY ([People])
   OUTPUT FORM ([People]; "Report")
   PRINT SELECTION ([People])

The first line is executed:

   QUERY ([People])

The Query editor is displayed.

The user enters the criteria and clicks the Query button. The query is performed.

The second line of the My Report method is executed:

   ORDER BY ([People])

Note that the user did not need to know that ordering the records was the next step.

The Order By Editor is displayed.

The user enters the criteria and clicks the Sort button. The sort is performed.

The third line of the My Report method is executed:

   OUTPUT FORM ([People]; "Report")

Once again, the user did not need to know what to do next; the method takes care of that.

The final line of the My Report method is executed:

   PRINT SELECTION ([People])

The Printing dialog boxes are displayed. The User chooses the settings, and the report is printed.

Automating the Application Further


The same commands used in the previous example can be used to further automate the database.

Let's take a look at the new version of the My Report method.

The user chooses Report from the People menu. A method called My Report2 is attached to the menu command. It looks like this:

   QUERY([People];[People]Company="Acme")
   ORDER BY([People]; [People]Last Name;>;[People]First Name;>)
   OUTPUT FORM([People];"Report")
   PRINT SELECTION([People];*)

The first line is executed:

   QUERY([People];[People]Company="Acme")

The Query editor is not displayed. Instead, the query is specified and performed by the QUERY command. The user does not need to do anything.

The second line of the My Report2 method is executed:

   ORDER BY([People];[People]Last Name;>;[People]First Name;>)

The Order By editor is not displayed, and the sort is immediately performed. Once again, no user actions are required.

The final lines of the My Report2 method are executed:

   OUTPUT FORM ([People]; "Report")
   PRINT SELECTION ([People]; *)

The Printing dialog boxes are not displayed. The PRINT SELECTION command accepts an optional asterisk (*) parameter that instructs the command to use the print settings that were in effect when the report form was created. The report is printed.

This additional automation saved the user from having to enter options in three dialog boxes. Here are the benefits :

The query is automatically performed: users may select wrong criteria when making a query.

The sort is automatically performed: users may select wrong criteria when defining a sort.

The printing is automatically performed: users may select the wrong form to print.

Help for Developing 4D Applications


As you develop a 4D application, you will discover many capabilities that you did not notice when you started. You can even augment the standard version of 4D by adding other tools and plug-ins to your 4D development environment.

Tools and 4D plug-ins

4D provides several tools and plug-ins that can be used for increasing the capabilities of your 4D applications.

4D Insider allows you to cross-reference your 4th Dimension databases. You can use it to view and print methods, variables, commands, externals, structures, lists, and forms. The cross-referencing utility tells you where each of these objects is used throughout your database. It also helps you to move objects like tables, forms, methods, menu bars, lists, packages, and styles from one database to another.

4D provides the following plug-ins:

4D Write: Word-processor

4D Draw: Graphical drawing program

4D View: Spreadsheet and list editor

4D Internet Commands (built-in): Communication utilities via Internet.

4D ODBC Pro: Connectivity via ODBC

4D for OCI: Connectivity with ORACLE Call Interface

4D Open for Java: Connectivity with Java applications

4D Open for 4D: Connectivity (from 4D to 4D) for building distributed 4D information systems.

For more information, contact 4D or its Partners. Visit our Web Sites:

USA & International:

http://www.4d.com

France:

http://www.4d.fr

The 4D community and third party tools

There is a very active worldwide 4D community, composed of User Groups, Electronic Forums, and 4D Partners. 4D Partners produce Third Party Tools. Browse your 4D CD—it contains demos and information from 4D Partners. Find out about them on the Web. You can suscribe to the user forum of 4th Dimension at the following address:

http://forums.4D.fr

The 4D community offers access to tips and tricks, solutions, information, and additional tools that will save you time and energy, and increase your productivity.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next