Solved

A String Thing

Posted on 1998-12-18
2
150 Views
Last Modified: 2010-04-04
I am still in the early learning stages of Delphi(4) and have been experimenting with using a Common Unit(no form) that other units(with forms) can feed from. I'm trying to set something up where a Label Caption is set within the Common Unit and under certain conditions will show in designated labels on other forms. Any help? This is what I have so far:

{this is Unit2, my common unit}
procedure TryOut(Trial: boolean; TheLabel: TLabel; Cap: string);
begin
TheLabel.Caption := Cap;
if Trial = True then
Cap := 'True' else
Cap := 'False';
end;

{This is one of my Units(with Form)}
procedure TForm1.FormCreate(Sender: TObject);
begin
TryOut(True, Label1, Cap);
end;

If TryOut is set to True I want Label1.Caption as 'True'. On FormCreate Cap shows as an 'Undeclared Identifier'. How can I overcome this, bearing in mind I want the caption to come from the Common Unit.

PS Sorry for low points but almost bankrupt.
0
Comment
Question by:xpher
2 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 20 total points
ID: 1351842
You have described two independant things you want to do:

1. Place a caption in a label given that the caption is defined in some other unit.
2. Place a caption of 'true' or 'false' in a label given an appropriate flag.


For option 1 rewrite you code like this:

Unit Common;

const
  TheCaption = 'The caption';

end.

{this is Unit2, my common unit}
    procedure TryOut(TheLabel: TLabel);
    begin
    TheLabel.Caption := TheCaption;
    end;

    {This is one of my Units(with Form)}
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    TryOut(Label1);
    end;

For option 2 rewrite you code like this:

{this is Unit2, my common unit}
    procedure TryOut(Trial: boolean; TheLabel: TLabel);
    begin
    if Trial = True then
    TheLabel.Caption:= 'True' else
    TheLabel.Caption:= 'False';
    end;

    {This is one of my Units(with Form)}
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    TryOut(True, Label1);
    end;

If i have missed something here perhaps could could give me some more details of exactly what you want to do.

Cheers,

Raymond.
0
 
LVL 1

Author Comment

by:xpher
ID: 1351843
Thanks for prompt and excellent reply.
Works great, I used option 2.

Cheers
Chris :))
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question