TDict - Data Dictionary

Source: source/classes/tdict.prg

Standalone class

TDict implements a data dictionary system that manages a collection of database tables (DBFs), menus, and reports. It stores metadata across 15+ system tables (oTables) covering table definitions, field definitions, indexes, relations, menus, reports, users, and security. The dictionary can auto-build missing system tables (lAutoBuild) and provides methods for creating tables, opening databases, loading menus, running reports, and importing files.

Key DATA Members

DATATypeDescription
cPathCharacterBase path where dictionary files are stored
lAutoBuildLogical.T. to automatically create missing system tables
oTablesArrayArray of 15+ TDatabase objects for system tables

Methods

MethodDescription
New( cPath )Create a new data dictionary at the given path
Activate()Open all system tables and activate the dictionary
CreateTable( cTbl )Create a new user table defined in the dictionary
OpenDataBase( cDbName )Open a named database and all its tables
OpenTable( cTbl )Open a specific table by name
LoadMenu( cMenu )Load a menu definition from the dictionary; returns TMenu
Report( cReport )Run a report defined in the dictionary
Import( cMask )Import files matching a file mask into the dictionary
LoadWebBrowse( cTbl )Load web browse configuration for a table
LoadWebRecord( cTbl )Load web record form configuration for a table
WebRecSave( cTbl )Save web record configuration for a table

Example: Create and Use Dictionary

#include "FiveWin.ch"

function Main()

   local oDict

   // Create a data dictionary in the data directory
   oDict := TDict():New( ".\data\" )
   oDict:lAutoBuild := .T.
   oDict:Activate()

   // Create a new user table
   oDict:CreateTable( "INVOICES" )

   // Open a database
   oDict:OpenDataBase( "SALES" )

   // Load a menu
   DEFINE WINDOW oWnd TITLE "Dictionary Demo" SIZE 800, 600
   oDict:LoadMenu( "MAIN" ):Activate( oWnd )

   // Run a report
   oDict:Report( "CUSTOMER_LIST" )

   ACTIVATE WINDOW oWnd

return nil

Notes

See Also