New declaration syntax for an intuitive autocompletion

Have you ever wondered about 4D’s autocompletion feature or asked yourself why 4D suggests all functions used in the code? Since an object is a very generic type, 4D only knows what it’s really storing at runtime. However, that doesn’t help much when you’re writing your code.

4D now offers a new, alternative syntax which will greatly enhance autocompletion when declaring your variables.

The new syntax is very simple and consists of the “var” keyword, the name of the variable, and its type.

var <variableName> : <type>

You can declare variables with both the classic and the new syntaxes in the same database.

For data types

This syntax can be used to define variable data types. The following are some examples showing the correspondence between both syntaxes for variables of text, numeric, and image data types.

Previous syntax


New syntax

var $text1; $text2 : Text
var $num : Integer
var $pict : Picture

For user classes

The idea of classes was introduced in 4D v18 R3. If you haven’t already done so, you should read this blog post.

Until now, all instances of a class were declared as an object. Now with the new syntax, you can define which class instance your object belongs to using the cs command and the name of your class. This gives you access to the functions and attributes of the class.

Previous syntax


New syntax

var $person : cs.Person

For 4D classes

Objects such as File or Folder are objects belonging to internal 4D classes. You can access them with the 4D command.

Previous syntax

$folder:=Folder(Current resource folder)

New syntax

var $folder : 4D.Folder
$folder:=Folder(Current resources folder)


What about ORDA?

In a previous blog post, we showed you that you can override the ORDA classes (Dataclass, Entity, and Entity selection) with your own classes. You can also use this new syntax to enjoy autocompletion.

Previous syntax


New syntax

var $dataclass : cs.Company
var $entity : cs.CompanyEntity
var $entitySelection : cs.CompanySelection



Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.