Board index » delphi » "code segmet too large" - problem

"code segmet too large" - problem

Hi, I am an enthusiastic but not very talented delphi user.
I have encountered the "Error 48 code segment too large" -problem, and
don't know what to do.
Delphi suggest that i should split my unit into two or more units.
  The problem is that i don't get it to work when i try to create a new
unit
and simply paste my procedures into the new unit. I guess i have to do
something
in the new units interface part as well but i dont know what. I need both
units to be assigned with one form, and when i click upon a label (the
program is mainly built upon labels, 46 labels, each with a rather big
procedure) i want to automaticly end up in the unit where the specific
procedure is, just like when using only one unit.

I am using Delphi 1.0 since that is the only version i can afford (got it
free with a computer magazine) and i also wonder if this, and other
limitations is solved in newer
versions of the program.

The best solution for my problem would be if there was a way to create a
general procedure for all my 46 labels, but for i have to mix the label
names with a variable, something like:

           n:=22
               ....
               label(n).color:=clRed

but so far Delphi just don't seems to understand what i mean :)

so if anyone reads this and has a solution (or suggestions) for my
problem....

thank you

 

Re:"code segmet too large" - problem


Quote
Sven Ake Wahlqvist wrote:

> Hi, I am an enthusiastic but not very talented delphi user.
> I have encountered the "Error 48 code segment too large" -problem, and
> don't know what to do.
> Delphi suggest that i should split my unit into two or more units.
>   The problem is that i don't get it to work when i try to create a new
> unit
> and simply paste my procedures into the new unit. I guess i have to do
> something
> in the new units interface part as well but i dont know what. I need both
> units to be assigned with one form, and when i click upon a label (the
> program is mainly built upon labels, 46 labels, each with a rather big
> procedure) i want to automaticly end up in the unit where the specific
> procedure is, just like when using only one unit.

> I am using Delphi 1.0 since that is the only version i can afford (got it
> free with a computer magazine) and i also wonder if this, and other
> limitations is solved in newer
> versions of the program.

> The best solution for my problem would be if there was a way to create a
> general procedure for all my 46 labels, but for i have to mix the label
> names with a variable, something like:

>            n:=22
>                ....
>                label(n).color:=clRed

> but so far Delphi just don't seems to understand what i mean :)

> so if anyone reads this and has a solution (or suggestions) for my
> problem....

> thank you

Hi Sven,

You can make a general procedure to process all your labels:
- Loop through all the components on your form
- check if component type is a label
- if you don't want to process all labels on your form, check the name (give
the labels specific names, e.g. MyLabel1, MyLabel2, ...., MyLabel46
- do your stuff

  procedure TYourForm.ProcessLabels;
  var
    a: integer;
  begin
    for a:=0 to ComponentCount-1 do
    begin
      if (Components[a] is TLabel) then
      begin
        with (Components[a] as TLabel) do
        begin
          if Copy(Name,1,7)='MyLabel' then
          begin
            Color:=clRed;
            Caption:=....
            ......
          end;
        end;
      end;
    end;
  end;

Good luck,
Sasan.

Other Threads