ThScm
Serves as the main manager for schema definitions and runtime database objects.Encapsulates access to tables, fields, and associated data records under a unified structure.
Coordinates schema-based operations such as loading, translating, linking, and validating structured data.
Acts as the top-level controller for working with both metadata and data in schema-driven systems.
FindTable
Locates a schema table by its internal name. Used to retrieve metadata and field definitions for a given table identifier.function FindTable(CONST TName: String): ThScmTable;
Parameters
- TName: String; The internal name of the schema table to locate.
Return Value
Returns the matchingThScmTable
if found; otherwise returns empty instance (NIL).FindField
Searches for a specific field within a given table using internal field name. This method combines table and field name resolution into one step.function FindField(CONST TName, TField: String): ThScmField;
Parameters
- TName: String; Internal name of the table.
- TField: String; Internal name of the field to locate.
Return Value
Returns theThScmField
from the specified table if found; otherwise returns empty instance (NIL).FindField_By_VisualName
Searches for a field by its visual (caption) name within a specific table. Supports localization-aware lookup based on user-facing field labels.function FindField_By_VisualName(CONST TblName, VisualName: String): ThScmField;
Parameters
- TblName: String; The name of the schema table.
- VisualName: String; The translated or visible name of the field.
Return Value
Returns theThScmField
that matches the visual name in the given table; otherwise returns empty instance (NIL).FindField_By_JsonName
Finds a field within a table based on its JSON-compatible name. Used when resolving fields during import/export or API interaction.function FindField_By_JsonName(CONST TblName, JsonName: String): ThScmField;
Parameters
- TblName: String; The name of the table.
- JsonName: String; The JSON-formatted name to match.
Return Value
Returns theThScmField
from the specified table that matches the JSON name; otherwise returns empty instance (NIL).Sort_Schema_Tables_List
Sorts the internal list of schema tables by name or another predefined logic. Ensures consistent ordering for UI presentation or export operations.procedure Sort_Schema_Tables_List;
Reset_Developer_Selection_Flags
Clears theDeveloper_Selection
flag on all loaded database objects. Used to reset developer filters or debugging states between sessions.procedure Reset_Developer_Selection_Flags;
Export_Schema_To_Json
Exports the current schema definitions into a JSON file using the selected export option.The generated JSON can be used for documentation, import into other systems, or versioning.
procedure Export_Schema_To_Json(FileName: String; Option: ThScm_Export_Options);
Parameters
- FileName: String; Full path to the output JSON file.
- Option: ThScm_Export_Options; Export mode controlling output content or format.
ThScm_Export_Options
Specifies the export mode used when saving schema definitions to JSON.Each option controls the scope and filtering of the exported data.
Option | Description |
---|---|
he_To_Server | Exports the schema in a compact format suitable for uploading to a server. |
he_By_User_Selection | Exports only tables or fields explicitly selected by the user. |
he_Full_Schema | Exports the entire schema structure, including all tables and fields. |
Import_Schema_From_Json
Imports schema definitions from a JSON file, updating the internal structure accordingly.Supports flexible options for merging, replacing, or validating schema entries.
function Import_Schema_From_Json(FileName: String; Import_Options: ThScm_Import_Options_Set): Boolean;
Parameters
- FileName: String; Path to the JSON file containing schema definitions.
- Import_Options: ThScm_Import_Options_Set; Set of flags defining import behavior.
ThScm_Import_Options
Specifies import behavior flags used when loading schema definitions from external sources.These options define how the imported schema interacts with existing structures.
Option | Description |
---|---|
he_Add_New_Tables | Only adds tables that do not already exist in the current schema. |
he_Update_Exist_Tables | Updates existing tables by merging or replacing their definitions. |
he_Reset_Tables_Before | Clears existing schema tables before importing new ones. |
ThScm_Import_Options_Set
Defines a set of import options for schema loading operations.Allows combining multiple
ThScm_Import_Options
flags to control the behavior of schema import functions.Used in functions like
Import_Schema_From_Json
and Import_Schema_From_Legacy_XML
.ThScm_Import_Options_Set = SET OF ThScm_Import_Options;
Return Value
ReturnsTrue
if the import was successful.Returns
False
if the file was invalid or the process failed.Import_Schema_From_Legacy_XML
Loads schema definitions from a legacy XML file and applies import options as needed.Supports backward compatibility with earlier versions of schema export formats.
function Import_Schema_From_Legacy_XML(FileName: String; Import_Options: ThScm_Import_Options_Set): Boolean;
Parameters
- FileName: String; Path to the XML file containing legacy schema data.
- Import_Options: ThScm_Import_Options_Set; Import behavior flags for legacy handling.
Return Value
ReturnsTrue
if schema import from XML was completed successfully.Returns
False
in case of parsing errors or unsupported format.Translate_Caption
Translates a given string into the specified language using the loaded translation table.Used to retrieve localized versions of field titles, labels, or messages.
function Translate_Caption(CONST Text: String; CONST Lang: ThTranslation_Language): String;
Parameters
- Text: String; The original text to be translated.
- Lang: ThTranslation_Language; The target language for translation.
Return Value
Returns the translated string if a match is found; otherwise returns the original text.Execute_Translation_Editor
Opens the built-in translation editor UI to allow manual editing or reviewing of translations.function Execute_Translation_Editor: Boolean;
Return Value
ReturnsTrue
if the translation editor was launched successfully.Returns
False
if the operation was canceled or not applicable.Export_Translation_File
Generates a file containing the current translation mappings for export or version control.Typically used to update translation resources or transfer them between environments.
function Export_Translation_File: Boolean;
Return Value
ReturnsTrue
if the export completed successfully.Returns
False
if the process failed or was aborted.Import_Translation_From_Json
Loads field caption translations from a JSON file into the internal translation system.Supports applying optional local currency formatting during import.
procedure Import_Translation_From_Json(CONST Filename, Local_Currency: String);
Parameters
- Filename: String; Path to the JSON file containing translation data.
- Local_Currency: String; Currency symbol or code to embed in relevant captions.
Import_Translation_From_Legacy_XML
Imports translations from an older XML-format file into the current schema translation system.Preserves support for legacy data sources while allowing currency substitution.
procedure Import_Translation_From_Legacy_XML(CONST Filename, Local_Currency: String);
Parameters
- Filename: String; Path to the legacy XML file.
- Local_Currency: String; Currency text to insert into translated captions where applicable.
Set_Application_Translation
Sets the active application translation language and optionally refreshes UI elements to reflect changes.Updates visual captions, field labels, and other translatable elements.
function Set_Application_Translation(UseLanguage: ThTranslation_Language; Refresh_Visual_Controls: Boolean): Boolean;
Parameters
- UseLanguage: ThTranslation_Language; The language to apply to the application UI.
- Refresh_Visual_Controls: Boolean; If
True
, triggers UI refresh to apply translated captions immediately.
Return Value
ReturnsTrue
if the language was set successfully.Returns
False
if the operation failed or translation was not available.Build_App_TimeZone_Cache
Initializes the internal timezone cache with entries from the specified year range.Optionally retrieves the data from a supervisor service or file.
function Build_App_TimeZone_Cache(FromYear{0=curr year}, UntilYear: Integer; Read_From_Supervisor: Boolean): Boolean;
Parameters
- FromYear: Integer; The starting year for the timezone data (0 = current year).
- UntilYear: Integer; The final year to include in the cache.
- Read_From_Supervisor: Boolean; If
True
, retrieves data from a central supervisor or external source.
Return Value
ReturnsTrue
if the cache was built successfully.Returns
False
if initialization failed or no data was available.Find_TimeZone_Index
Searches the internal timezone cache for the specified time zone name.function Find_TimeZone_Index(TimeZone: String): Integer;
Parameters
- TimeZone: String; The name or identifier of the timezone to locate.
Return Value
Returns the index of the timezone in the internal cache.Returns
-1
if the time zone is not found.Set_Default_App_TZ
Sets the default application-wide time zone by name. This default is used whenever a record or field does not explicitly define a time zone.function Set_Default_App_TZ(TimeZone: String): Boolean;
Parameters
- TimeZone: String; The name of the time zone to set as default.
Return Value
ReturnsTrue
if the default time zone was set successfully.Returns
False
if the specified name was invalid or not found.Get_TZ_List_By_Order
Returns a string containing the full list of known time zones, ordered alphabetically or by usage.Used for populating dropdowns or validating user selections.
function Get_TZ_List_By_Order: String;
Return Value
Returns a formattedString
containing the ordered list of available time zones.Timezone_Is_Loaded
Checks whether the internal timezone cache has been initialized and is ready for use.function Timezone_Is_Loaded: Boolean;
Return Value
ReturnsTrue
if timezone data is loaded and available.Returns
False
if the cache is empty or uninitialized.Tables
Provides access to the full collection of schema tables managed by the system.Each table defines its own set of fields, layout, and metadata.
property Tables: ThScmTables;
DB_Objects
Holds the runtime list of database object folders associated with the schema.Each object corresponds to a record set or physical data container.
property DB_Objects: ThDB_Objects;
Backup_Json
Path to the backup JSON file used to store schema data snapshots or recovery information.property Backup_Json: String;
Backup_Json_Enabled
Indicates whether the system should actively create and maintain backup JSON snapshots.property Backup_Json_Enabled: Boolean;
ThScmTables
Manages a collection ofThScmTable
instances that define multiple data schemas.Provides centralized access and lookup mechanisms for schema tables by name, index, or translated caption.
Used when a system contains multiple related schemas, such as for datasets with multiple record types.
Supports schema discovery, translation-aware searches, and dynamic manipulation of table definitions.
Add
Creates and adds a new schema table to the collection.The returned table instance can be configured with fields, captions, and storage properties.
function Add: ThScmTable;
Return Value
Returns aThScmTable
representing the newly added schema table.Items
Provides indexed access to individualThScmTable
entries in the collection.Allows reading or modifying schema tables by position.
property Items[Index: Integer]: ThScmTable;
Parameters
- Index: Integer; Zero-based index of the schema table in the collection.
Return Value
Returns theThScmTable
at the specified index.