4D (4th Dimension, or Silver Surfer, as it was known during early development) is a relational database management system and integrated development environment developed by Laurent Ribardière. 4D was created in 1984 and had a slightly delayed public release for Macintosh in 1987 with its own programming language. Apple tried at the time to ensure well-known software publishers supported the Macintosh platform, and as a result the project reverted to Laurent Ribardière, who with the French businesswoman Marylene Delbourg-Delphis published 4th Dimension. Although independently published, Apple supported the new venture and used 4D extensively throughout the organization for projects including fitness center management and CIM (Computer Integrated Manufacturing). A number of Apple personnel became 4D experts, including Lance McAndrew in Apple's Cupertino headquarters and Andrew O'Donoghue in Apple's Ireland-based European manufacturing headquarters, where a 4th Dimension application managed the European Service Center administration.
Over the next few years 4th Dimension's installed base grew, and the publisher ACI established a US-based subsidiary called ACIUS, initially led by Guy Kawasaki. After 16 years of operating as ACIUS up to 2000, the name was officially changed to 4D Inc.
In 1993, 4D Server v1.1, the client/server version of 4th Dimension was introduced along with the release of 4th Dimension v3.1.
In 1995, 4D v3.5 went cross-platform and has since then supported both the Microsoft Windows and Apple Macintosh operating systems.
In 1997, 4D v6 was the first version of 4D to contain a fully integrated web server, allowing developers to translate 4D forms into HTML on the fly using only the 4D language.
In 2004, 4D 2004 was the first version of 4D to allow developers to create standalone, client/server, web and Service Oriented Applications (SOA) without changing any code.
In 2008, 4D v11 added a SQL layer to the 4D database engine and extending native SQL in to the 4D programming language which allowed 4D developers to write native SQL code to connect to either local or remote servers.
In 2010, 4D v12 integrated the ability to execute PHP functions/scripts from within the 4D programming language. This version also supported new replication and synchronization commands and included a 64 bit version of 4D Server.
Version history
{| class="wikitable"
!Branch
!Latest version
!Initial release
!Final release
!Status Feb 2022
!Notes
|-
|v19.x
|v19.LTS
|12 Jul 2021
|Ongoing
|Supported
|Native support for Apple Silicon, Classes
|-
|v18.x
|v18.LTS
|16 Jan 2020
|Ongoing
|Supported
|Project Databases for Version Control, Built-in encryption tools, 4D for iOS, 4D Write Pro, 4D View Pro
|-
|v17.x
|v17.4
|10 July 2018
|13 Dec 2020<br />(4D v17.5)
|Support ended 13 Dec 2020
|ORDA (Object Relational Data Access), Collections, Object Notation, Dynamic forms
|-
|v16.x
|v16.6
|10 Jan 2017
|24 Jul 2019<br />(4D v16.6)
{| class="wikitable"
|-
! Data Type
! Field
! Variable
! Expression
|-
|String
|
|
|
|-
| Number (double)
|
|
|
|-
| Date
|
|
|
|-
| Time
|
|
|
|-
| Boolean
|
|
|
|-
| Picture
|
|
|
|-
| Pointer
|
|
|
|-
| BLOB
|
|
|
|-
| Array
|
|
|
|-
| Integer 64 bits
|
|
|
|-
| Float
|
|
|
|-
| Object
|
|
|
|-
| Collection
|
|
|
|-
| Undefined
|
|
|
|}
More info on 4D data type can be found on the [ 4D Data Types] documentation page
Variable Scope
Local variables are prefixed with a <code>$</code> like <code>$myLocalVariable</code> and only live for the duration of the method.
Process variables have no prefix like <code>myProcessVariable</code> and live throughout the duration of the process.
Inter-process (or Global) variables are prefixed with a <code><></code> like <code><>myGlobalVariable</code> and live throughout the duration of the application.
Comparison of looping
For
<pre>
For(vCounter;1;100)
// Do something
End for
</pre>
While
<pre>
$i :=1 // Initialize the counter
While($i<=100) // Loop 100 times
// Do something
$i :=$i +1 // Need to increment the counter
End while
</pre>
Repeat
<pre>
$i :=1 // Initialize the counter
Repeat
// Do something
$i :=$i +1 // Need to increment the counter
Until($i=100) // Loop 100 times
</pre>
Nested Loops
The following example goes through all the elements of a two-dimensional array:
<pre>
For($vlElem;1;Size of array(anArray))
// ...
// Do something with the row
// ...
For($vlSubElem;1;Size of array(anArray{$vlElem}))
// Do something with the element
anArray{$vlElem}{$vlSubElem}:=...
End for
End for
</pre>
The following example builds an array of pointers to all the date fields present in the database:
<pre>
ARRAY POINTER($apDateFields;0)
$vlElem:=0
For($vlTable;1;Get last table number)
// loop over each table number with $vTable as the number
If(Is table number valid($vlTable))
// check if table number $vTable is valid
// only loop on the valid table
For($vlField;1;Get last field number($vlTable))
// loop over each field number within current table
// with $vlField as the current field number
If(Is field number valid($vlTable;$vlField))
// check if field number is valid
$vpField:=Field($vlTable;$vlField) // get pointer to field
If(Type($vpField->)=Is date)
// check if current field is a date
// only performs these actions if field is a date
$vlElem:=$vlElem+1
INSERT IN ARRAY($apDateFields;$vlElem)
$apDateFields{$vlElem}:=$vpField
End if
End If
End for
End If
End for
</pre>
References
External links
- 4D Documentation (new & legacy)
- New 4D Forum (http://discuss.4d.com/)
- 4D Knowledge Base
