Constants in an Array declaration. 
Author Message
 Constants in an Array declaration.

Anybody know why I can't do the following :

VAR     Engs : Array[1..Engineers.RecordCount] of String[10];

Engineers is a variable of type TTable, relating to a Paradox
database.  I want the maximum size of the array to be the same as
the number of records in the table.  It is to be used for looking
up the value of one field (Name) against another field (Reference
Number).

Any help gratefully accepted.

Rob.

\* Robert G. Lawson                          Lancashire, England */
\*---------------------------------------------------------------*/
\*       "Praise does wonders for the sense of hearing"          */



Mon, 04 May 1998 03:00:00 GMT  
 Constants in an Array declaration.

Quote:

> Anybody know why I can't do the following :

> VAR     Engs : Array[1..Engineers.RecordCount] of String[10];

The compilers wants (needs?) to know Engineers.RecordCount at compile time, which it obviously can't.

The way You'll want to implement this is using a (dynamic) String list:

var
  mylist: TStrings;
begin
  mylist := TStringList.Create;
  try
    { somehow set the size of the list, e.g. adding 10 String[10]'s here, see help
  finally
    mylist.free; {Need to make sure were not wasting resources}
  end;
end

Hope this helps

Thomas  



Fri, 08 May 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Dynamic array declaration

2. Untyped array constants?

3. Big typed constant array definition?

4. Conversion of Pascal Real constants to C/C++ float constants

5. Pointer declarations

6. Variant fields in object declaration in TP7 or DELPHI

7. declaration error

8. Program name declaration

9. ODBC32 API Declaration Unit for Delphi 2.0

10. {10:3 declaration}????

11. write / writeln declaration

12. Help: Unfamiliar type declaration

 

 
Powered by phpBB® Forum Software