4D Blog

Home Product New Option for the Command Formulas from string!

New Option for the Command Formulas from string!

October 23, 2023

Product

As a 4D developer, you’ve probably already created and used formulas. They can be created via two commands, Formula and Formula from string. The latter has just been enhanced in 4D v20 R3 to be used without limits from components!

Formulas and execution context

Formulas, whatever their content, are intimately linked to the database from which they are created. When called, they are always executed in the context in which they were created.

This applies to 4D commands and functions like Structure file and formulas based on method calls.

A simple example

Let’s imagine a FormatedCurrentDate method that returns a formatted string.

#DECLARE($format : Integer)->$formatedDate : Text
$formatedDate:=String(Current date; $format)

This method can be used within a formula, which can be created this way:

$formula:=Formula from string("FormatedCurrentDate(System date abbreviated)")

In this case, the formula will return the formatted date as expected.

$date:=$formula.call()

When the method and the formula are in the same environment, all is fine… but if this not shared method is in the host database, and the formula that tries to use this method is created within a component, it won’t be able to execute.

A new parameter is now available

A new parameter has been added to the Formula from the string function to give you the choice and allow you to decide in which context the formula will be executed.

#1) sk execute in the host database

If we return to the previous example, where the FormatedCurrentDate unshared method belongs to the host database, it will be possible to execute it anyway from a component by creating the formula as follows:

$formula:=Formula from string("FormatedCurrentDate(System date abbreviated)";sk execute in host database)

#2) sk execute in the current database

If the value sk execute in the current database is passed (or is simply omitted), then the formula will be executed in the database that created the formula”.

Conclusion

This new option will enable you to easily create your own interface components (for 4D Write Pro, for example) using methods or variables from the host database.
More freedom and more power mean more responsibility, too, but this openness is still very practical and allows components to access functions of their host databases straightforwardly.

Don’t hesitate to share your impressions on the forum!

Discuss

Tags 21, 4D Write Pro, Formula, v20 R3

Latest related posts

  • December 3, 2025

    Give AI to a 30 years old 4D application

  • November 28, 2025

    ORDA – Handle an event-driven logic during database operations

  • November 27, 2025

    ORDA – Permissions – Restrict / allow web access to the resources in one click

Roland Lannuzel
Roland Lannuzel
• Product Owner & 4D Expert • After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 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 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 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 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 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