Bypass function "out" parameters

delphi

Solution

You can create a wrapper:

procedure test(); overload;
var
    SomeVar : string;
begin
    test(SomeVar);
end;

Note: You'll also have to mark the other version with `overload`, or you can call your wrapper something other than `test`, and remove the `overload`.

Another option: declare a dummy variable somewhere (at the top of your unit, maybe):

var 
  DummyStr : string;

Then you don't have to declare a new variable every time you want to call the function.

test(DummyStr);

Problem

Some functions need a variable to send out a value. But sometimes I don't need that value and don't want to define a variable to use it as function `out` parameter. Like this: ``` procedure test(out SomeVar: string); begin //... end; ``` I want to execute this safely: ``` test; ```

Original source