Is it possible to pass nil as an undeclared constant to the untyped parameter of some function? I have such functions, and I would like to pass some constant to the Data parameter to satisfy the compiler. Inside, I make a decision on the "Size" parameter. I know that I can use Pointer instead of the untyped parameter, but this is much more convenient for my case.
Now I get E2250 There is no overloaded version of 'RS232_SendCommand' that can be called with these arguments
function RS232_SendCommand(const Command: Integer): Boolean; overload; begin // is it possible to pass here an undeclared constant like nil in this example? Result := RS232_SendCommand(Command, nil, 0); end; function RS232_SendCommand(const Command: Integer; const Data; const Size: Integer): Boolean; overload; begin ... end;
This works, but I would be glad if I could leave a variable declaration.
function RS232_SendCommand(const Command: Integer): Boolean; overload; var Nothing: Pointer; begin Result := RS232_SendCommand(Command, Nothing, 0); end;
The solution is to use something like this.
function RS232_SendCommand(const Command: Integer): Boolean; overload; begin // as the best way looks for me from the accepted answer to use this Result := RS232_SendCommand(Command, nil^, 0); // or it also possible to pass an empty string constant to the untyped parameter // without declaring any variable Result := RS232_SendCommand(Command, '', 0); end;
I do this because some of my commands have data sent after passing the commands.
thanks for the help
TLama
source share