Get Datadictionary object from File Number: Difference between revisions

m
Updated the code a bit to be more clear and self explanatory
(Created page with '== Get DataDictionary Object from File Number == If you have nothing except the table number, you can find the table name, construct the data dictionary class name from that, an...')
 
m (Updated the code a bit to be more clear and self explanatory)
Line 3: Line 3:
If you have nothing except the table number, you can find the table name, construct the data dictionary class name from that, and use Eval to get the class id:
If you have nothing except the table number, you can find the table name, construct the data dictionary class name from that, and use Eval to get the class id:
   Function DDO_From_TableName String sTableName Returns Handle
   Function DDO_From_TableName String sTableName Returns Handle
     String sClassID  
     String sClassID  
     String sEvalClassId
     String sEvalClassId
     Handle hoDD
    Integer iClassID
     Handle hoDD
      
      
     Move "" To sClassID
     Move "" To sClassID
Line 12: Line 13:
     Move (SFormat("U_%1_DataDictionary", sTableName)) to sClassId
     Move (SFormat("U_%1_DataDictionary", sTableName)) to sClassId
     Move (Eval(sClassId)) to sEvalClassId
     Move (Eval(sClassId)) to sEvalClassId
   
    Send Trap_Error Of Error_Object_ID 54
   
     If (sClassId <> sEvalClassId) Begin
     If (sClassId <> sEvalClassId) Begin
       Move (Cast(sEvalClassId,Handle)) To hoDD
       Move (Cast(sEvalClassId,Handle)) To iClassID
      Get Create of Desktop iClassID to hoDD
      If (hoDD<>0) Begin
        // set a name so it is easier to recognize in the debugger
        Set Name of hoDD to ("Global_"+sTableName+"_DD")
      End 
     End
     End
    Send Trap_Error Of Error_Object_ID 54
     Function_Return hoDD
     Function_Return hoDD
   End_Function // DDO_From_TableName
   End_Function // DDO_From_TableName
Line 22: Line 28:
This assumes your DD's are called TableName_DataDictionary, like the pre 14.1 standard was.
This assumes your DD's are called TableName_DataDictionary, like the pre 14.1 standard was.


After you have the class id, just use Create of Desktop to create an instance of the class.


==== External links ====
==== External links ====


[http://support.dataaccess.com/Forums/showthread.php?40381-Get-DataDictionary-Object-from-File-Number Get DataDictionary Object from File Number]]
[http://support.dataaccess.com/Forums/showthread.php?40381-Get-DataDictionary-Object-from-File-Number Get DataDictionary Object from File Number]]