瀏覽代碼

Use constant as array upper bound for easier maintenance

Reinier Olislagers 11 年之前
父節點
當前提交
ce937ea643
共有 1 個文件被更改,包括 7 次插入6 次删除
  1. 7 6
      comparison.pas

+ 7 - 6
comparison.pas

@@ -9,7 +9,8 @@ uses
   Buttons, ComCtrls, IBConnection, sqldb, QueryWindow;
   Buttons, ComCtrls, IBConnection, sqldb, QueryWindow;
 
 
 const
 const
-  dbObjects: array [1 .. 13] of string = ('Tables', 'Generators', 'Triggers', 'Views', 'Stored Procedures', 'UDFs',
+  NumObjects = 13; //number of different objects in array below
+  dbObjects: array [1 .. NumObjects] of string = ('Tables', 'Generators', 'Triggers', 'Views', 'Stored Procedures', 'UDFs',
     'Sys Tables', 'Domains', 'Roles', 'Exceptions', 'Users', 'Indices', 'Constraints');
     'Sys Tables', 'Domains', 'Roles', 'Exceptions', 'Users', 'Indices', 'Constraints');
 
 
 type
 type
@@ -50,9 +51,9 @@ type
   private
   private
     fdbIndex: Integer;
     fdbIndex: Integer;
     DiffCount: Integer;
     DiffCount: Integer;
-    dbObjectsList: array [1 .. 13] of TStringList;
-    dbExistingObjectsList: array [1 .. 13] of TStringList;
-    dbRemovedObjectsList: array [1 .. 13] of TStringList;
+    dbObjectsList: array [1 .. NumObjects] of TStringList;
+    dbExistingObjectsList: array [1 .. NumObjects] of TStringList;
+    dbRemovedObjectsList: array [1 .. NumObjects] of TStringList;
     MissingFieldsList: TStringList;
     MissingFieldsList: TStringList;
 
 
     ExistFieldsList: TStringList;
     ExistFieldsList: TStringList;
@@ -339,7 +340,7 @@ begin
 
 
     fQueryWindow.meQuery.Lines.Add('');
     fQueryWindow.meQuery.Lines.Add('');
 
 
-    for x:= 1 to 13 do
+    for x:= 1 to NumObjects do
     begin
     begin
       if (x = 1) and cxTables.Checked then // Tables
       if (x = 1) and cxTables.Checked then // Tables
       for i:= 0 to dbObjectsList[x].Count - 1 do
       for i:= 0 to dbObjectsList[x].Count - 1 do
@@ -1560,7 +1561,7 @@ var
 begin
 begin
   FieldsList:= TStringList.Create;
   FieldsList:= TStringList.Create;
   try
   try
-    for x:= 13 downto 1 do
+    for x:= NumObjects downto 1 do
     begin
     begin
       if (x = 1) and cxTables.Checked then
       if (x = 1) and cxTables.Checked then
       begin
       begin