Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Store procedure and its parameters and then call it

Status
Not open for further replies.

knnknn

Technical User
Nov 18, 2001
7
CY
Is it possible to store the current values of a procedure to call it later?

Something like:

Code:
var [b]procdat[/b]:[COLOR=red]TCompleteProcedureData[/color red];

procedure TForm1.Memo1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  begin
  [COLOR=red]StoreAllValues[/color]([b]procdat[/b]); // procdat should contain now the pointer to TForm1.Memo1MouseMove and all the current parameters (= sender, shift, x, y)
  end;


procedure TForm1.Button1Click(Sender: TObject);
  begin
  [COLOR=red]ExecuteProcedureWithOriginalValues[/color]([b]procdat[/b]); // uses the values with which Memo1MouseMove has been called originally
  end;
 
I'm not entirely sure what you're trying to achieve. This code will do what you want - but I think you already knew that.

Code:
[navy][i]// for automatic syntax highlighting see faq102-6487 
[/i][/navy][b]type[/b]
  TMouseMoveRec = [b]record[/b]
    Sender: TObject;
    Shift : TShiftState;
    X, Y : Integer;
    Store: Boolean;
  [b]end[/b];

[b]var[/b]
  mm : TMouseMoveRec;

[b]procedure[/b] TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
[b]begin[/b]
  [b]if[/b] [b]not[/b] mm [b]then[/b]
  [b]begin[/b]
    mm.Sender := Sender;
    mm.Shift := Shift;
    mm.X := X;
    mm.Y := Y;
    mm.Store := True;
  [b]end[/b]
  [b]else[/b]
  [b]begin[/b]
    mm.Store := False;
    [navy][i]// perform MouseMove stuff
[/i][/navy]  [b]end[/b];
[b]end[/b];

[b]procedure[/b] TForm1.Button1Click(Sender: TObject);
[b]begin[/b]
  FormMouseMove(mm.Sender, mm.Shift, mm.X, mm.Y);
[b]end[/b];
 
Sorry, my fault, that's not what I mean.

I want a general way how to store a procedure's parameters: All kinds of procedures with all kinds of parameters and all kinds of numbers of parameters.

So I want a solution that would work with

Code:
procedure X(i:integer);

and

Code:
procedure Y(i, j:integer);

and

Code:
procedure Z(a:string; b:real; c:boolean);

Maybe RTTI is the way to go (GetMethodProp() etc)?
 
Hi knnknn,

I still don't see why you want to do that, but maybe it's because you're not telling us what you really want to do.
Try to give us a more concrete example and on that base we can give you more useful advice.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top