4D Blog

Home Product New declaration syntax for an intuitive autocompletion

New declaration syntax for an intuitive autocompletion

August 5, 2020

Product

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

C_TEXT($text1;$text2)
C_LONGINT($num)
C_PICTURE($pict)

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

C_OBJECT($person)
$person:=cs.Person.new()

New syntax

var $person : cs.Person
$person:=cs.Person.new()

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

C_OBJECT($folder)
$folder:=Folder(Current resource folder)

New syntax

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

blank

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

C_OBJECT($dataclass)
C_OBJECT($entity)
C_OBJECT($entitySelection)

New syntax

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

 blank

 

Discuss

Tags Code editor, Language, Programming, User Experience, v18 R4, v19

Latest related posts

  • February 3, 2026

    4D Write Pro – Adding a margin automatically when bullets are set using standard actions

  • January 22, 2026

    Transform Static Documents into Actionable Knowledge with AIKit

  • January 22, 2026

    Deploy Fluent UI effortlessly in your 4D applications

Vanessa Talbot
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.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • AI
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy