Skip to content

4d/4D-Macros

Repository files navigation

Static Badge Static Badge
release

The 4D-Macros component provides convenient macros that enhance code editing in 4D’s code editor.

Once installed, these macros are available directly in the editor, where you can use them to simplify tasks, convert code syntax, ensure consistent formatting, ….

Calling macros...

You can call a macros:

  • By clicking on the Macros button on the code editor toolbar.
  • By double-clicking on their name in one of the footer lists of the method editor.
  • For some of them, by selecting the name of the macro in the “Method” > “Insert Macro” submenu, or in the “Insert Macro” submenu of the editing zone context menu.
  • For some, in the predictive input window.

For more information on the use and operation of macros, you can refer to the 4D documentation.

Installation

This component is fully compatible with 4D's Project dependencies feature. You can add the component to your project by selecting Design > Project dependencies and adding 4d/4d-macros as the GitHub® repository address in the dedicated dialog box. How to.

💡 The project's dependency manager ensures that you are always using the latest available version of the components.


👴🏻 Installation for older versions or binary databases...
  1. Create a Components folder alongside your Project folder *.

  2. Place the 4D Macros.4dbase component ** into this Components folder.

    * For binary databases: Locate the Components folder next to the structure file (.4db).
    ** On macOS, the component is a package whose ".4dbase" extension is not necessarily visible depending on your display preference settings.

💡 Using an alias (macOS®) or shortcut (Windows®) file is recommended for easier updates across multiple projects.

Name Goal Automatism
C_xxx -> var Replaces the deprecated commands like “C_xxx(...)”
with the new “var ... : type” syntax.
At opening

ℹ️ This macro is automatically executed when you open a method.

The deprecated declarations such a C_LONGINT(…)*, C_TEXT(…)*, C_BLOB(…)* ... are replaced by the new syntax var ... : Integer, var ... : Text, var ... : Blob

Example transformation...

Before:

_O_C_LONGINT($1)
_O_C_TEXT(${2})

_O_C_TEXT(vDetail; $message)
// _O_C_TEXT(vMessage)
_O_C_LONGINT(vError)

_O_C_LONGINT(myMethod; $0)

After:

var $1 : Integer
_O_C_TEXT(${2})

var vDetail; $message : Text
// _O_C_TEXT(vMessage)
var vError : Integer

_O_C_LONGINT(myMethod; $0)

📍 The lines C_xx ( <method>; $… )** & the comments are not modified, nor the syntax C_xx (${n})***


* With 20R7+, C_xxx commands are preceded by the obsolete marking prefix and are displayed as _O_C_xxx.
** The C_xx ( <method> ; $... ) declarations used in COMPILER_xxx methods to define parameters and returns for project methods are obsolete. The use of the syntax #DECLARE dispenses with these declarations.
*** This syntax, which allows you to declare a variable number of parameters of the same type, is also deprecated and must be replaced by the use of the syntax #DECLARE

If you encounter a bug or have a feature request, feel free to browse and search existing issues. If you don't find your issue listed, go ahead and create a new one.

For those contributing directly, it’s recommended to:

1- Clone the repository.

2- Make modifications and submit a pull request.