nafa2221
asked on
Function
I am writeing a function that returns a boolean(true,false) and It doesnt seem to let me call a function from within the function, how can I do this?
ASKER
MatchedWindow:=TForm1.Find WindowThat ContainSub String(AOW indows,'We lcome'); <-- Thay gives me the error undeclared indentifier...help!
erm please ignore above code it is gibberish(real bad)
here is a tested example of what i mean:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function function1(s : string):string;
function function2(t : string):string;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function TForm1.function1(s : string):string;
begin
showmessage(s);
end;
function TForm1.function2(t : string):string;
begin
showmessage(t);
function1('here is function1 in function2');
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
Function2('function2');
end;
end.
here is a tested example of what i mean:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function function1(s : string):string;
function function2(t : string):string;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function TForm1.function1(s : string):string;
begin
showmessage(s);
end;
function TForm1.function2(t : string):string;
begin
showmessage(t);
function1('here is function1 in function2');
end;
procedure TForm1.Button1Click(Sender
begin
Function2('function2');
end;
end.
oh i didnt see your posting.
what is this?
MatchedWindow:=TForm1.Find WindowThat ContainSub String(AOW indows,'We lcome'); <-- Thay gives me the error undeclared indentifier...help!
that tells me nothing..
have you made this function yourself?
is it delared globally?
if so i would need see your full function to understand the error.
and show you where to put the code in your unit.
i presume your calling it on a button click or something ..?
please take a look at the second posting of mine and i think you will see what to do.
what is this?
MatchedWindow:=TForm1.Find
that tells me nothing..
have you made this function yourself?
is it delared globally?
if so i would need see your full function to understand the error.
and show you where to put the code in your unit.
i presume your calling it on a button click or something ..?
please take a look at the second posting of mine and i think you will see what to do.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi nafa,
having read some of your questions do you think this may help you:
i also use aol sometiomes so i could check the classnames to get this function.
mm.. i see your after the
"welcome , Barry" Window ..
what do you intend to do with this window when you have it?
maybe i can help more ..
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Procedure FindAolWindow;
var
AolMainWnd,AolMdi,AolWelco meWnd : hwnd;
s : array [0..255]of char;
begin
AolMainWnd:= FindWindow('AOL Frame25',nil);
if AolMainWnd <> 0 then begin
AolMdi := FindWindowEx(AolMainWnd,0, 'MDIClient ',nil);
if AolMdi <> 0 then begin
AolWelcomeWnd := FindWindowEx(AolMdi,0,'AOL Child',nil);
if AolWelcomeWnd <>0 then
begin
getwindowtext(AolWelcomeWn d,s,255);
if pos('Welcome',s) <> 0 then
begin
showmessage('Connected ')
end
else
if pos('Goodbye',s) <> 0 then
begin
showmessage('Not Connected' );
end
else showmessage('Error..Aol running but Welcome/Goodbye Window not found');
end;
end;
end
else showmessage('Aol not running');
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
FindAolWindow;
end;
end.
having read some of your questions do you think this may help you:
i also use aol sometiomes so i could check the classnames to get this function.
mm.. i see your after the
"welcome , Barry" Window ..
what do you intend to do with this window when you have it?
maybe i can help more ..
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Procedure FindAolWindow;
var
AolMainWnd,AolMdi,AolWelco
s : array [0..255]of char;
begin
AolMainWnd:= FindWindow('AOL Frame25',nil);
if AolMainWnd <> 0 then begin
AolMdi := FindWindowEx(AolMainWnd,0,
if AolMdi <> 0 then begin
AolWelcomeWnd := FindWindowEx(AolMdi,0,'AOL
if AolWelcomeWnd <>0 then
begin
getwindowtext(AolWelcomeWn
if pos('Welcome',s) <> 0 then
begin
showmessage('Connected ')
end
else
if pos('Goodbye',s) <> 0 then
begin
showmessage('Not Connected' );
end
else showmessage('Error..Aol running but Welcome/Goodbye Window not found');
end;
end;
end
else showmessage('Aol not running');
end;
procedure TForm1.Button1Click(Sender
begin
FindAolWindow;
end;
end.
somefunction();
you can call
tform1.somefunction();
example:
private
function1(s : string);
function2(t : tdatetime);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function TForm1.function1(s : string);string;
begin
showmessage(s);
end;
function TForm1.function2(t:string)
begin
showmessage(t);
tform1.function2('here is function1 called in function2');
end;
if it dont work pates your 2 functions here so we can look at.