Here's routine which I've had for the last quarter century. I just
tweaked it today to get rid of dependencies.
// ----------------------------------------------------
// Project Method: Structure Description {(Include Relations)}
// Creates a text description of the structure
// by default this includes relation data
// pass False in $1 to just report on fields
// Parameters:
// $1 : Boolean : Include elationship data (optional)
// Created by somebody on the iNUG
//-- Date Prog Change Made
//-- -------- ----- --------------------------------------
//-- 10/09/92 WPF Program Written.
//-- 24/02/94 WBS Modification by Wayne Stewart
//-- 2019-02-26 WBS Tidied it up so not dependent on any
other methods
// ----------------------------------------------------
If (False)
End if
C_BOOLEAN($1)
C_BOOLEAN($IncludeRelations_b;$indexed_b;$invisible_b;$unique_b)
C_LONGINT($CurrentField_i;$CurrentTable_i;$element_i;$fieldLength_i;$fieldType_i;$NumberOfFields_i;$NumberOfTables_i;$oneField_i;$oneTable_i;$Position_i)
C_TIME($DocumentReference_h)
C_POINTER($field_ptr)
C_TEXT($CR_t;$fieldLength_t;$fieldType_t;$file_line_t;$indexDescription_t;$invisibleDescription_t;$isIndexed_t;$isInvisible_t;$isUnique_t;$ReportText_t)
C_TEXT($StructureName_t;$Tab_t;$uniqueDescription_t)
If (False)
C_BOOLEAN(Util_StructureDescription;$1)
End if
If (Count parameters=1)
$IncludeRelations_b:=$1
Else
$IncludeRelations_b:=True
End if
$CR_t:=Char(13)
$Tab_t:=Char(9)
$file_line_t:=(8*"=")+$Tab_t+(15*"=")+$CR_t
$indexDescription_t:="Indexed"
$uniqueDescription_t:="Unique"
$invisibleDescription_t:="Invisible"
//-- determine the number of files in the database
$NumberOfTables_i:=Get last table number
If (True) // Get the database name
$StructureName_t:=Structure file
$Position_i:=Position(Folder separator;$StructureName_t)
While ($Position_i>0)
$StructureName_t:=Substring($StructureName_t;$Position_i+1)
$Position_i:=Position(Folder separator;$StructureName_t)
End while
$StructureName_t:=Replace string($StructureName_t;".4DB";"")
$StructureName_t:=Replace string($StructureName_t;".4DC";"")
End if
If (True) // Build a type array
ARRAY TEXT($Types_at;255)
For ($element_i;1;255) // set them all to a default value
$Types_at{$element_i}:="Unknown Type"
End for
$Types_at{0}:="Is alpha field"
$Types_at{1}:="Is real"
$Types_at{2}:="Is text"
$Types_at{3}:="Is picture"
$Types_at{4}:="Is date"
$Types_at{5}:="Is undefined"
$Types_at{6}:="Is boolean"
$Types_at{7}:="Is subtable"
$Types_at{8}:="Is integer"
$Types_at{9}:="Is longint"
$Types_at{11}:="Is time"
$Types_at{13}:="Array 2D"
$Types_at{14}:="Real array"
$Types_at{15}:="Integer Array"
$Types_at{16}:="LongInt Array"
$Types_at{17}:="Date Array"
$Types_at{18}:="Text Array"
$Types_at{19}:="Picture Array"
$Types_at{20}:="Pointer Array"
$Types_at{21}:="String Array"
$Types_at{22}:="Boolean Array"
$Types_at{23}:="Pointer"
$Types_at{24}:="Is string var"
$Types_at{25}:="Is integer 64 bits"
$Types_at{30}:="Blob"
$Types_at{31}:="Blob array"
$Types_at{32}:="Time array"
$Types_at{35}:="Is float"
$Types_at{38}:="Is object"
$Types_at{39}:="Object array"
$Types_at{42}:="Is collection"
$Types_at{255}:="Is null"
End if
// Start building the report
$ReportText_t:="Structure Description for "+$StructureName_t+(2*$CR_t)
For ($CurrentTable_i;1;$NumberOfTables_i) //-- For each file…
If (Is table number valid($CurrentTable_i))
//-- determine the number of fields in this file
$NumberOfFields_i:=Get last field number($CurrentTable_i)
//-- create a new "header" for this file
$ReportText_t:=$ReportText_t+"Table:
"+String($CurrentTable_i)+$Tab_t+Table
name($CurrentTable_i)+$CR_t+$file_line_t
For ($CurrentField_i;1;$NumberOfFields_i) //-- For each field…
If (Is field number valid($CurrentTable_i;$CurrentField_i))
//-- get a pointer to the field
$field_ptr:=Field($CurrentTable_i;$CurrentField_i)
//-- determine the field’s attributes
GET FIELD
PROPERTIES($field_ptr;$fieldType_i;$fieldLength_i;$indexed_b;$unique_b;$invisible_b)
//-- get a text-description of the data type
$fieldType_t:=$Types_at{$fieldType_i}
//-- the length is meaningful only if the field is alphanumeric
Case of
: ($fieldType_i=Is Alpha Field) & ($fieldLength_i=0)
$fieldLength_t:=""
$fieldType_t:="UUID"
: ($fieldType_i=Is Alpha Field)
$fieldLength_t:=String($fieldLength_i)
Else
$fieldLength_t:=""
End case
// Field properties
$isIndexed_t:=Choose($indexed_b;$indexDescription_t;"")
$isUnique_t:=Choose($unique_b;$uniqueDescription_t;"")
$isInvisible_t:=Choose($invisible_b;$invisibleDescription_t;"")
$ReportText_t:=$ReportText_t+"Field: "+String($CurrentField_i)+$Tab_t\
+Field name($field_ptr)+$Tab_t\
+$fieldType_t+$Tab_t\
+$fieldLength_t+$Tab_t\
+$isIndexed_t+$Tab_t\
+$isUnique_t+$Tab_t\
+$isInvisible_t+$Tab_t\
+$CR_t
If ($IncludeRelations_b)
GET RELATION PROPERTIES($field_ptr;$oneTable_i;$oneField_i)
//;$choiceField_i;$autoOne_i;$autoMany_i)
If ($oneTable_i>0)
$ReportText_t:=$ReportText_t+$Tab_t+"Related to: "+$Tab_t\
+"["+Table name($oneTable_i)+"]"+Field name($oneTable_i;$oneField_i)+$Tab_t+\
"Table: "+String($oneTable_i)+$Tab_t+"Field: "+String($oneField_i)+$CR_t
End if
End if
Else
$ReportText_t:=$ReportText_t+"Field:
"+String($CurrentField_i)+$Tab_t+"Deleted field"+$CR_t
End if
End for
//-- add an extra return after each file
$ReportText_t:=$ReportText_t+$CR_t
Else
$ReportText_t:=$ReportText_t+"Table:
"+String($CurrentTable_i)+$Tab_t+"Deleted table"+$CR_t+$file_line_t
$ReportText_t:=$ReportText_t+$CR_t
End if
End for
SET TEXT TO PASTEBOARD($StructureName_t)
$DocumentReference_h:=Create document("";"TEXT")
SEND PACKET($DocumentReference_h;$ReportText_t)
CLOSE DOCUMENT($DocumentReference_h)
Regards,
Wayne
On Wed, 27 Feb 2019 at 16:22, Tom Benedict via 4D_Tech
<[email protected]> wrote:
>
> Hi Robert,
>
> Do you just need to compare the schema (the tables and fields) or do you also
> need to compare the methods and forms? If it’s the former, then Miyako’s
> recommendation to use 4D’s Export to XML feature will suffice. If you need to
> compare methods/forms you’ll need to export them then use a tool like Dani
> Beaubien’s OpenRoad Code Analysis
> <http://openroaddevelopment.com/projects_4dComponent_CodeAnalysis.html>
> <http://openroaddevelopment.com/projects_4dComponent_CodeAnalysis.html> to do
> the diff.
>
> HTH,
>
> Tom Benedict
>
> > On Feb 26, 2019, at 18:42, Robert ListMail via 4D_Tech
> > <[email protected]> wrote:
> >
> > I’ve inherited a v13-based 4D database and I have a need to determine the
> > differences amongst two. So, what are my structure comparison options?
> >
> > Thanks,
> >
> > Robert
> > **********************************************************************
> > 4D Internet Users Group (4D iNUG)
> > Archive: http://lists.4d.com/archives.html
> > Options: https://lists.4d.com/mailman/options/4d_tech
> > Unsub: mailto:[email protected]
> > **********************************************************************
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive: http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub: mailto:[email protected]
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************