Introduction
4D distribute a complete family of database development tools based around 4th Dimension - the leading cross-platform relational database. The product line consists of a wide variety of programs to assist you in developing and deploying relational database applications. This document will help you to understand briefly what each product is and where, and how, you would use it. Specification sheets for the products are available from the 4D website at http://www.4D.com
Single-User 4D
4th Dimension (4D)
4D 2003 is the single-user version of 4D. It is a cross-platform relational database application. Databases developed with 4D can be written and deployed on either Mac OS or Windows 95/98/NT.
Typical Uses
Create your own custom applications such as:
Multi-User 4D
4D Server is the multi-user version of 4D that supports Client/server processing. You install 4D Server on a computer that is dedicated to acting as an application server. Normally this will be a more powerful computer, with a large amount of memory, larger and faster hard disk drive, and a high CPU speed. This computer will store the 4D application and the datafile - therefore it should have an uninterruptible power supply and have backup capability - a mirror disk drive or tape backup for example.
The structure and datafile are installed only on this computer. This makes installation, updates and security much easier to manage.
Any 4D single-user application, written for Mac OS or Windows, can be run
on 4D Server with no modifications. 4D handles most record locking issues
automatically although some modifications might be desirable in a high use
environment (to avoid record modification conflicts).
4D Client is the software that you install on each users computer to connect to the server.
4D Client connections to the server are based on a concurrent licensing system. Consider the following example:
Your network has a Windows NT server computer with 4D Server for Windows installed. There are 100 computers connected to the network: some by ethernet and some using dial-in modem connections. Some are Macintoshes, some Windows computers. At any one time there are likely to be 20 people who need to use your 4D application. But according to the time of day and workload they may be on any of the computers, Macintoshes or Windows computers - even the remote computers. You purchase a 20 client license (plus perhaps a few `spares').
You can then install 4D Client on every computer, Mac OS and Windows that may ever require connection to your database application.
If at any time in the future you need further connections you may purchase, and install, further connection licenses as required. These are all managed on 4D Server.
4D's Implementation of Client/server
4D client does not store any data locally - except in RAM. After 4D client connects to the server the user can execute some code such as a query "find all customers in Oregon". This request is sent to 4D Server. Since this command is only a few bytes it creates very little network activity.
The server receives this request and creates the required selection. Only a copy of the data that matches the criteria is sent back to the client (again minimizing network activity). It is still stored on the server's hard disk.
The client receives the data, processes it and sends back the only the changes to the server. The server updates the records that have changed.
4D's Client/server implementation has many practical advantages:
4D's implementation of client/server minimizes network traffic - optimising the speed of the application without coding by the user.
Development
If you are going to develop more sophisticated applications you will probably want to use the following tools, which are bundled with 4D in the 4D Desktop package.
An application that you develop with 4D/4D Server is referred to as `Interpreted'. When you run the application each line of code is interpreted one after another. Interpreted means that 4D looks at each line of code and decodes it into a sequence of lower-level instructions that can be understood by the computer. This slows down the execution of the program.
To make the application run faster we can do the decoding before we need it and save these decoded instructions. This is what 4D Compiler does. 4D Compiler handles two main tasks:
Syntax Checking
As you type your code into a 4D application it is possible to either mistype a command, or leave out part of the syntax of the command. If this part of the code is not executed before you attempt to compile the application you may never notice your error. Consider this code:
If ([Invoice]Date_Payment_Due < Current date(*))
[Customer]Bad = TRUE
SAVE RECORD ([Customer])
Alert ("This invoice is past due!")
End if
There is a subtle error here: the code should read [Customer]Bad := TRUE. Firstly the bad code will only execute when the date due is past and therefore may not execute for years. Secondly the omission of the ":" means that the field [Customer]Bad will never be set to TRUE. You may never notice this error and it may cause serious problems in your application.
4D Compiler checks for these errors on your behalf. When you compile a 4D application the compiler checks every line of code to ensure that the syntax is correct, and generates an error file listing all the error codes. You can then open your 4D application and jump immediately to each error and fix it. Your application will not compile until all syntax errors are fixed.
Compilation
When you close any method in 4D it is tokenised - that is it is turned into a series of compact codes that reduce storage space and speed up execution. When you compile an application this code is turned into a series of machine level instructions specific to the platform and processors that you wish to execute the application on. On Mac OS, for example, these would be (primarily) 68K and PPC processors. On Windows this would be 486 or Pentium.
The interpreted application that you wrote is referred to as the source code and the compiled code that the compiler generates is referred to as the object code. The compiled application:
After compilation you are left with the original interpreted structure.
4D Insider is also included in the 4D Desktop bundle. 4D Insider allows you to:
Utilities
4D Tools
4D Tools can work on your structure or data file.
Structure File
The structure file can be:
If you have deleted a lot of objects, such as forms, from a database you will end up with `holes' in the structure file. This does not affect performance but means that the structure is larger than it need be. You can use 4D Tools to compact the structure and reclaim this unused space. This can be useful if you plan to frequently send updates to users by email for example.
Occasionally database objects may become damaged or corrupted. 4D tools can check the structure for certain problems, and in most cases fix them automatically. If they can't be fixed you can use 4D Insider to copy the undamaged objects to a new, clean structure.
Data File
The data file can be:
Check for Errors
Occasionally records or indexes may become corrupted. This option can fix most record and index damage.
Compacted
After deleting records a 4D Database will have `holes' in the data file. 4D will reuse these whenever possible - new records will be automatically inserted into the empty spaces if the spaces are large enough. Depending on the size and format of records, it is possible that after extended periods of deleting records you will end up with a number of small unused areas in the data file. This may slightly affect performance. You can use the compact option to reclaim this unused space.
Recover by Tags
Power failure or a hard disk crash could cause extensive damage to your data file (that's why you have uninterruptible power supplies and backups). 4D Tools can recover the undamaged record data from your database into a fresh data file.
4D Transporter
Composition of a 4D Database
Mac OS
On Mac OS a 4D database consists two parts:
There may optionally be a folder named `Mac4DX' which contains optional plug-ins that are needed for a particular application. This folder may be in one of two locations - in the same folder as the structure file or in the 4D folder, in the System Preferences folder.
Windows
Windows 4D applications follow the same format except that the structure file is in two parts - the structure file and its resource file. The data file may optionally have a resource file as well. The plug-in folder is called `Win4DX' and may be located in either the same directory as the structure or in C:\Windows\4D\Win4DX
Resources
The Mac OS supports a programming concept called `Resources'. These are components within an application that contain objects such as menus, screens, icons and so on. Application code calls these resources as needed. Programs can be localised into other languages by changing only the resources with a Resource Editor without the need to recompile the code. Windows has no standard for supporting these resources.
Mac OS versions of all 4D databases contain a significant number of resources (whether you use them or not). To convert a database that has been developed on Mac OS to run on Windows you need to convert your applications with 4D Transporter.
This Mac OS only program will convert a Mac OS 4D database to a Windows equivalent format in a few seconds. It achieves this by stripping the resources from a 4D database into a separate resources file. The Windows version of 4D then manages these resources as if they were on Mac OS. For converting Windows 4D databases to Mac OS the reverse takes place, the resources file is merged back into the structure.
Since 4D Transporter needs to manage resources in either direction it is a Mac OS only program. It ships with all versions of 4D.
4D customiser
This tool allows you to customise certain aspects of a 4D application (such as 4D or 4D Server), a 4D structure or data file. 4D applications can be customised whether they are interpreted or compiled.
Network Components
4D supports different network protocols on different computer platforms. These are:
You can install and remove protocols as required for your platform.
Plug-ins
4D supports a plug-in architecture. Any 4D compatible plug-ins are placed in the Mac4DX folder (Win4DX on Windows) and are automatically loaded on starting the application. Plug-ins placed in the new universal 4DX folder (see previous note) are available to all 4D applications running on that computer. Plug-ins placed in the 4DX folder in the same folder/directory as the 4D application are available only to that application.
Plug-ins enhance 4D's capabilities with new commands, these appear in the method editor just as if they were part of 4D. 4D Write, for example, allows you to build word processing functionality into your applications, combining word processed text with data from the database.
4D Backup provides a variety of back-up features into an application including the ability to create single back-up copies, back-up sets, mirrored back-ups and a log file. Back-ups can be implemented programmatically.
4D Chart
4D Chart, although a plug-in, is included within 4D. It enables you to create 2D and 3D charts from records within your database. You can create preprogrammed charts or allow the user access to the chart editor where they can create their own.
4D Write is a full-featured word processor that handles multiple columns, paragraph and character style sheets, font styles, find and replace and nearly every other feature you would expect from a word processor. As a 4D plug-in it allows you to create documents programmatically from record data.
4D Draw allows the creation of 2D graphics objects that can be created from, and linked to, record data. You could use 4D Draw to create hierarchy diagrams, network diagrams, stock location maps, charts, maps, and software design tools.
4D Internet Commands
4D Internet Commands is also bundled with 4D. It allows you to quickly create 4D applications that:
Connectivity
4D Open allows different 4D applications, whether single-user or server, to communicate with each other. Using 4D Open you could create applications that are separate, perhaps for security reasons, yet can share data with each other when required.
Open Database Connectivity (ODBC) is a Microsoft standard that allows databases to communicate with each other through a common protocol. 4D can act as an ODBC client or server. You will also need platform specific ODBC drivers.
4D Oracle is a plug-in optimised for connections to Oracle databases. It works in a similar way to 4D SQL but is optimised specifically for Oracle, rather than generic SQL databases.
ODBC driver for 4D Server allows client applications to communicate with 4D Server via SQL commands.
With the ODBC Driver, many types of applications (word-processors, spreadsheets,
report generators, etc.) running on Windows (only) may access 4D Server
to carry out database tasks. ODBC Driver for 4D Server allows client applications
to send ODBC calls and SQL queries to 4D Server, thereby transforming a
4D Server application into an ODBC data source, providing access to all
standard Windows applications. These Windows applications may execute ODBC
calls and SQL queries.
Plug-ins Availability
A variety of powerful third-party 4D plugins available at the following
sites:
After completing your application you may wish to deploy it to other users. They may be coworkers, friends, or customers. There are several different ways of deploying your application.
Each copy of 4D ships with 4D Runtime Interpreted. You can distribute this software, subject to the license agreement, to any user so that they can run your application in interpreted mode.
This allows users to run compiled applications. Again they cannot be modified by the user. You purchase a single copy of Runtime Classic for each user that you wish to distribute your application to. This is an ideal way to distribute a small number of applications - probably up to about ten in number.
4D Engine is only available to members of the 4D Partner Program. Used in conjunction with 4D Compiler, it allows you to merge a compiled database with a 4D Engine to create a single, stand alone, double-clickable application. There is a separate version for Mac OS and Windows. The resulting program can be distributed free of charge to anyone. This is the most economical way of distributing more than a few copies of a single-user 4D application.
There is no multi-user deployment option for 4D Server. If you wish to deploy a multi-user application the end user will need to have a copy of 4D Server and as many client connection licenses as they need. 4D Application Server will only run compiled applications and is a cheaper option than 4D Server Standard Edition.
If you anticipate distributing more than a few copies of a server-based
application you can enter into an OEM agreement with 4D. This allows you
to distribute your applications with a copy of 4D Server and pay a royalty
based on a percentage of the value of the shipping product.
Cross-Platform Development
4D is cross-platform between Mac OS and Windows:
There are a few differences between Mac OS databases and Windows databases:
4D databases can detect which platform they are running on and display
the appropriate interface appearance automatically.
Some 4D products are purchased individually and others are bundled together in packages. The easiest way to understand what you may need to purchase is to contact 4D customer service at: (800) 785 3303.