Solved

Function

Posted on 2000-04-03
6
152 Views
Last Modified: 2010-04-04
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?
0
Comment
Question by:nafa2221
  • 5
6 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2681130
i havent tested this but it should work declare the functions globally so instead of calling
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);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.
0
 

Author Comment

by:nafa2221
ID: 2681170
MatchedWindow:=TForm1.FindWindowThatContainSubString(AOWindows,'Welcome'); <-- Thay gives me the error undeclared indentifier...help!
0
 
LVL 17

Expert Comment

by:inthe
ID: 2681223
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.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 17

Expert Comment

by:inthe
ID: 2681241
oh i didnt see your posting.

what is this?

MatchedWindow:=TForm1.FindWindowThatContainSubString(AOWindows,'Welcome'); <-- 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.


0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 2681331
well i guess it is procedure your using not function but it is same principal..
 
this will work if you declare globally :
your procedure and a boolean var.

private
    { Private declarations }
procedure FindWindowThatContainSubString
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  MatchedWindow : Boolean;

implementation

procedure FindWindowThatContainSubString(blah,blah);
begin
blah blah
end;

procedure Tform1.Button1Click(sender : tobject);
begin
MatchedWindow:=FindWindowThatContainSubString(AOWindows,'Welcome');  
end;



0
 
LVL 17

Expert Comment

by:inthe
ID: 2681734
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,AolWelcomeWnd : 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(AolWelcomeWnd,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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ddeman not working in activex 3 92
Delphi XE10, MySQL Query 4 125
Internet Explorer View Settings Question 15 105
Can Viruses spread while transferring Binary data with Winsock 2 66
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now