Jump to content
Ian Branch

Procedure out parameter question..

Recommended Posts

Hi Team,

Given the following

TTable.EditError(DataSet:TDataSet; E: EDatabaseError; var Action: TDataAction);

If I now feed the parameters to a second procedure via..

  _EditError(Action, E, DataSet);

Given that _EditError is defined as..

procedure _EditError(out Action: TDataAction; E: EDatabaseError; DataSet: TDataSet);

And in _EditError, Action may be set to daRetry or daAbort..

Will the Action be passed back up to the TTable.EditError or do I need to make the 'out Action: TDataAction;' in the _EditError definition a var??

 

Regards & TIA,

Ian

Share this post


Link to post
Guest

maybe help you

  1. OUT works like just a "container to changes on the variant", any value "IN it" will be discarded. any literal passed dont will be accepted
    1. Deeper( 'my value') == NOT!
    2. Deeper( myValuInAvar ) == YES!
  2. VAR works in 2 way  (IN-OUT)!
  3. both works quickly equals... :()

NOTE: MyVarREF == in fact, it's a "MyVarByVALUE"

 

image.png.e4c898960900447fe10e1e2ac879e115.png

implementation

{$R *.dfm}

var
  MyVarIn: string;

procedure Deeper(out MyOutVar: string);
begin
  MyOutVar := random(1000).ToString;
  //
  Form1.Memo1.Lines.Add('MyOutVar: ' + integer(pointer(MyOutVar)).ToString + ' === ' + MyOutVar);
  //
  Form1.Memo1.Lines.Add('MyVarIn 4: ' + integer(pointer(MyVarIn)).ToString + ' === ' + MyVarIn);
end;

procedure NonSoDeeper(MyVarVALUE: string);
begin
  Deeper(MyVarVALUE);
  //
  Form1.Memo1.Lines.Add('MyVarVALUE: ' + integer(pointer(MyVarRef)).ToString + ' === ' + MyVarVALUE);
  //
  Form1.Memo1.Lines.Add('MyVarIn 3: ' + integer(pointer(MyVarIn)).ToString + ' === ' + MyVarIn);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  MyVarIn := 'hello out-world';
  //
  Form1.Memo1.Lines.Add('MyVarIn 1: ' + integer(pointer(MyVarIn)).ToString + ' === ' + MyVarIn);
  //
  NonSoDeeper(MyVarIn);
  //
  Form1.Memo1.Lines.Add('MyVarIn 2: ' + integer(pointer(MyVarIn)).ToString + ' === ' + MyVarIn);
end;

end.

 

Edited by Guest

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×