When the solution matters

Tips...

Registration Documentation Knowledgebase Seminars / Training Partner Programs 4D Partner Central

Step 8) The 4th Dimension Language

Prerequisites

You should be familiar with terms such as table, field, and form. Before you learn about the 4D language, you should:

Introduction to the 4D Language

4th Dimension has its own programming language. This built-in language, consisting of over 500 commands, makes 4th Dimension a powerful development tool for database applications on desktop computers. You can use the 4th Dimension language for many different tasks – from performing simple calculations to creating complex custom user interfaces. For example, you can:

The flexibility and power of the 4th Dimension programming language make it the ideal tool for all levels of users and developers to accomplish a complete range of information management tasks. Novice users can quickly perform calculations. Experienced user without programming experience can customize their databases. Experienced developers can use this powerful programming language to add sophisticated features and capabilities to their databases, including file transfer and communications. Developers with programming experience in other languages can add their own commands to the 4th Dimension language.

4D Language Defined

The 4th Dimension language is made up of various components that help you perform tasks and manage your data.

Data types: In the language, the various types of data that can be stored in a 4th Dimension database are referred to as data types. There are seven basic data types: string, numeric, date, time, Boolean, picture, and pointer.

More information on Data Types

Operators: When you use the language, it is rare that you will simply want a piece of data. It is more likely that you will want to do something to or with that data. You perform such calculations with operators. Operators, in general, take two pieces of data and perform an operation on them that results in a new piece of data. You are already familiar with many operators. For example, 1 + 2 use the addition (or plus sign) operator to add two numbers together.

Numeric operators are just one type of operator available to you. 4th Dimension supports many different types of data, such as numbers, text, dates, and pictures, so there are operators that perform operations on these different data types.

More information on Operators

Expressions: Simply put, expressions return a value. In fact, when using the 4th Dimension language, you use expressions all the time and tend to think of them only in terms of the value they represent. Expressions are also sometimes referred to as formulas.
Expressions are made up of all the other parts of the language: commands, operators, variables, and fields. You use expressions to build statements (lines of code), which in turn are used to build methods. The language uses expressions wherever it needs a piece of data.

More information on Expressions

Variables: Data in 4th Dimension is stored in two fundamentally different ways. Fields store data permanently on disk; variables store data temporarily in memory.
When you set up your 4th Dimension database, you specify the names and types of fields that you want to use. Variables are much the same – you also give them names and different types.

More information on Variables

Commands: Built-in instructions to perform an action. All 4D commands, such as ADD RECORD, are described in the 4th Dimension Language Reference manual, grouped by theme; when necessary, the theme is preceded by an introductory section. You can use 4D Plug-ins to add new commands to your 4D development environment. For example, once you have added the 4D WRITE plug-in to your 4D system, the 4D WRITE commands become available for creating and manipulating word-processing documents. You can view the complete list of all 4D Language Commands by theme, or alphabetically by command.

Methods: A method is a series of instructions that causes 4th Dimension to perform a task. Each line of instruction in a method is called a statement. Each statement is composed of parts of the language. If you have already worked through the Quickstart tutorials, you have already written and used methods.

More info on Methods

Control Flow

Regardless of the simplicity or complexity of a method, you will always use one or more of three types of programming structures. Programming structures control the flow of execution, whether and in what order statements are executed within a method. There are three types of structures:

The 4th Dimension language contains statements that control each of these structures.

More information on Control Flow

Learning Resources

4D Design Reference (PDF)

4D 2003 Method Editor Reference (PDF)
(The method editor has been re-written for 4th Dimension 2003), p. 35 – 69

4D Language Reference On-line

Example Databases


International | Company | Contact 4D | Site Map | Privacy Policy | © 4D, Inc. 1995-2008 | Change font size: [A] [A] [A] | Print this page | 4D RSS Feeds