TTable / TAccTable

Fuente: source/classes/ttable.prg, source/classes/tacctbl.prg

TTable provides DBF table metadata management — it stores the table name, alias, field definitions and index list, and can create or import DBF structures. TAccTable manages Windows accelerator tables, allowing keyboard shortcuts (virtual key + modifier state) to be associated with control IDs.

TTable — DBF Table Metadata

Key DATA Members

DATATypeDescription
cNameCharacterTable file name (without extension)
cAliasCharacterAlias used when opening the table
lSharedLogicalOpen table in shared mode
aFieldsArrayArray of TField objects defining the structure
aIndexesArrayArray of index definitions

Methods

MethodDescription
New( cName, cAlias, lShared, cComments )Create a new table metadata descriptor
Import( cDbfFile )Import the field structure from an existing DBF file
Create( cPath )Physically create the DBF file on disk from the stored field definitions

TAccTable — Accelerator Table

Key DATA Members

DATATypeDescription
nHandleNumericWindows accelerator table handle (returned by SetAccTable)
aItemsArrayArray of items, each is { nVirtKey, nVKState, nId }

Methods

MethodDescription
New()Create an empty accelerator table
Add( nVK, nState, nId )Add an accelerator entry (virtual key + modifier state + command ID)
Del( nVK, nState )Remove an accelerator entry by virtual key and state
Activate()Set this accelerator table as active for the calling thread
DeActivate()Restore the previous accelerator table (pass nil to SetAccTable)
End()Destroy the accelerator table and deactivate it if currently active

Example: Create Table and Accelerator

#include "FiveWin.ch"

function Main()

   local oTable, oAccel

   // TTable: define and create a DBF
   oTable := TTable():New( "customers", "CUST", .F. )
   AAdd( oTable:aFields, TField():New( "customers", 1, .F., "NAME", "C", 40, 0 ) )
   AAdd( oTable:aFields, TField():New( "customers", 2, .F., "CITY", "C", 30, 0 ) )
   oTable:Create( "c:\data" )

   // TAccTable: define keyboard shortcuts
   oAccel := TAccTable():New()
   oAccel:Add( VK_F2, 0, 101 )
   oAccel:Add( VK_F3, 0, 102 )
   oAccel:Add( VK_S, MOD_CONTROL, 103 )
   oAccel:Activate()

return nil

Notes

Ver También