4D Blog

Home Product Access your component classes from your host project

Access your component classes from your host project

April 25, 2022

Product

Components can now publish classes! And even better, if your application is still in binary mode, you can now benefit from classes and object-oriented development by using a component (in project mode) to create your own classes and use them from your (binary mode based) application.

A 4D component is a set of methods and forms. As of 4D v19 R5, it is also a group of classes representing one or more functionalities that can be installed in different applications. The code editor’s completion system and other help systems have been updated to support your components’ classes and methods to make your coding smoother.

Component namespace

You can make your classes usable in your host project by adding a namespace in your component settings when you generate your component. For the internal classes you want to hide in your host project, just prefix their names with an underscore (“_”).

To avoid naming conflicts with existing classes in the host database, you need to create a namespace for your component. In the class store, all your classes will be accessible through this namespace:

New options have been added in the Settings window to make it happen. You can define the namespace for your class, and decide if you want to generate the syntax file to enable auto-completion when a developer uses your component:

blank

After generating your component as usual, and putting it in your host database, you can write this type of code to use your class:

var $class : cs.myComponent.Class1

$class:=cs.myComponent.Class1.new()

Completions and tips

When compiled, you can choose to activate the completion and the prototype displaying in the host base by setting the Generate syntax file for code completion option.

If the option is selected, you can use your component’s classes and methods with:

  • Completion:

blank

  • Tips:

blank

  • And prototype at the bottom of the code editor windows:

blank

Take a look at the documentation for more information, and don’t hesitate to give us feedback on the 4D forum!

Discuss

Tags Class, Code editor, Component, v19 R5, v20

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 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-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio 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