Delphi Error E2283 Too Many Local Constants

I have a compilation problem with my code in Delphi 2006. I am using a static String array:

fsi_names : array [0..FSI_NUM_VARS-1] of string;

In the procedure that I call at the beginning of the program, I assign values ​​to this array. This code is automatically generated by the script I wrote. It consists of lines similar to the following:

fsi_names[idFSI_FLIGHT_PATH_ANGLE] := 'FSI_FLIGHT_PATH_ANGLE';

About 2,000 elements should be specified in this array. I could not find out the magic number where the compiler dies, but it has been working since 1853 and not since 2109.

The thing is, I need this array to convert the identifier (which is an index into an array) into a name as a string for various applications.

I know that if I split the list of assignments and put the parts in different procedures, then this will work. But since the code is auto-generated and often changes, this method is not entirely convenient.

I also thought about putting the contents into a file and reading it at runtime, but I would rather keep the number of files that I have to deliver to a minimum. In addition, I would like to protect the content from the ordinary user so that he does not mess with him.

Do you have an idea how I can either overcome the compiler limitation or change my code to achieve my goal?

Help is much appreciated.

+5
source share
3 answers

I have found a solution!

, , :

const
  fsi_names : array [0..FSI_NUM_VARS-1] of string = (
    'NAME 0',
    'NAME 1',
    ...
    'LAST NAME'
    );

, , .

, mj2008!

+1

, ASCII , idFSI_FLIGHT_PATH_ANGLE + 1 "FSI_FLIGHT_PATH_ANGLE". . , EXE, :

function GetNthString(const N: integer): string;
var
  RS: TResourceStream;
begin
  RS := TResourceStream.Create(hInstance, 'NAMEOFRESOURCE', RT_RCDATA);
  with TStringList.Create do
    try
      LoadFromStream(RS);
      result := Strings[N];
    finally
      Free;
    end;
  RS.Free;
end;
+3

from
fsi_names : array [0..FSI_NUM_VARS-1] of string;

to
fsi_names: array of string;
SetLength(fsi_names, FSI_NUM_VARS);

-2

All Articles