Re: [twsocket] Design problem: function result and getAsync

2005-11-03 Thread Francois Piette
 How do I have to design my unit so that I
 create a nice and simple function call in
 my main program but the actual
 code resides in a different unit?

This is a perfect case where writing a component (or a class) is very helpful. 
In the component or
class, you can encapsulate everything related to a process and then use it from 
any other unit.

--
Contribute to the SSL Effort. Visit
http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be



- Original Message - 
From: Lutz Schröer [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Thursday, November 03, 2005 3:26 AM
Subject: [twsocket] Design problem: function result and getAsync


 Hi,

 I've got a small design problem with the GetAsync method. My basic
 understanding is that after I called the getAsync method I have to do
 the further processing in httpRequestDone. This is no problem until I
 want to put the code in a different unit. For example:

 unit1.pas:
 --
 function xxx.getResult(): string;
 begin
http.getAsync;
 end;

 procedure xxx.httpRequestDone(Sender: TObject; RqType: THttpRequest;
   ErrCode: Word);
 begin
   // do some result processing
 end;


 main.pas:
 --
 [...]
 result := unit1.getResult();
 [...]

 Obviously this can't work. How do I have to design my unit so that I
 create a nice and simple function call in my main program but the actual
 code resides in a different unit?

 Cheers
 Lutz



 -- 
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Design problem: function result and getAsync

2005-11-03 Thread Wilfried Mestdagh
Hello Lutz,

Just write as always but you have a typical code that need to be
executed in a separate object. So let the object behave as a normal
ojbect. Later it is also very easy to use the thing in other
applications. And you can use the normal async methods.

unit uJob

type
  TJobResult = procedure(Sender: TObject; const TheResult: string) of
object;
  TJob = class
  private
FCli: THTTPCli;
FOnResult: TJobResult;
procedure TriggerResult(const TheResult: string);
  public
procedure GetResult;
property OnResult: TJobResult read FOnResult write FOnResult;
  end;

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Thursday, November 3, 2005, 03:26, Lutz Schröer wrote:

 Hi,

 I've got a small design problem with the GetAsync method. My basic 
 understanding is that after I called the getAsync method I have to do 
 the further processing in httpRequestDone. This is no problem until I 
 want to put the code in a different unit. For example:

 unit1.pas:
 --
 function xxx.getResult(): string;
 begin
http.getAsync;
 end;

 procedure xxx.httpRequestDone(Sender: TObject; RqType: THttpRequest;
   ErrCode: Word);
 begin
   // do some result processing
 end;


 main.pas:
 --
 [...]
 result := unit1.getResult();
 [...]

 Obviously this can't work. How do I have to design my unit so that I 
 create a nice and simple function call in my main program but the actual
 code resides in a different unit?

 Cheers
 Lutz




-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Design problem: function result and getAsync

2005-11-02 Thread Arno Garrels
Lutz Schröer wrote:
 Hi,
 
 I've got a small design problem with the GetAsync method. My basic
 understanding is that after I called the getAsync method I have to do
 the further processing in httpRequestDone. This is no problem until I
 want to put the code in a different unit. For example:
 
 unit1.pas:
 --
 function xxx.getResult(): string;
 begin
http.getAsync;
 end;
 
 procedure xxx.httpRequestDone(Sender: TObject; RqType: THttpRequest;
   ErrCode: Word);
 begin
   // do some result processing
 end;
 
 
 main.pas:
 --
 [...]
 result := unit1.getResult();
 [...]
 
 Obviously this can't work. How do I have to design my unit so that I
 create a nice and simple function call in my main program but the actual
 code resides in a different unit?
 
It does not have to do with different units but with asynchronous nature of
method GetAsync. Most async methods are also available as blocking methods,
for instance GetAsync/Get. 

---
Arno Garrels [TeamICS]


 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be