KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using the .Match file
PRODUCT: 4D | VERSION: 11.6 | PLATFORM: Mac & Win
Published On: June 8, 2010

When a database is opened with 4D 11.5 or any newer version a new file is automatically generated: "Database_name.Match". (Database_name is the actual name of the .4DB file which was opened.) This file links table numbers and UUID's as described in the Tech Tip "What is the .Match file?"

The .Match file is formatted as an XML file where every table is a "DataTable" element containing a given table number and its associated UUID as two attributes. For example:

<DataTable num="1" TableDefID="41BF0DC5AD9146E1A716AB00604149C5"/>


The table number attribute is called "num" and the UUID is named "TableDefID".

Many developers track changes to key data in an application, saving information such as table number, field number, and the overwritten, "old" data. This can be thought of as a revision tracking system. With the .Match file developers can now include table UUID's. Sample code to get the UUID into the variable $uuid_val using 4D's DOM XML commands follows (in this code it is assumed that $mytable_ptr is a pointer to the desired table):

C_TEXT($uuid_val;$file;$xml_ref;$child;$name;$value;$num_value;$uuid_val)
$uuid_val:="none_found"
$file:=Structure file
$file:=Substring($file;1;Length($file)-3)+"Match"
$xml_ref:=DOM Parse XML source($file)
$child:=DOM Get first child XML element($xml_ref;$name;$value)
DOM GET XML ATTRIBUTE BY NAME($child;"num";$num_value)
If ($num_value=String(Table($mytable_ptr)))
  DOM GET XML ATTRIBUTE BY NAME($child;"TableDefID";$uuid_val)
Else
  $child:=DOM Get next sibling XML element($child;$name;$value)
  While ((ok=1) & ($uuid_val="none_found"))
    DOM GET XML ATTRIBUTE BY NAME($child;"num";$num_value)
    If ($num_value=String(Table($mytable_ptr)))
      DOM GET XML ATTRIBUTE BY NAME($child;"TableDefID";$uuid_val)
    End if
    $child:=DOM Get next sibling XML element($child;$name;$value)
  End while
End if