Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass "nil" constant to the untyped parameter?
    text
    copied!<p>is it possible to pass nil as an undeclared constant to the untyped parameter of some function? I have functions like these and I would like to pass some constant to the <code>Data</code> parameter to satisfy the compiler. Internally I'm deciding by the Size parameter. I know I can use Pointer instead of untyped parameter but it's much more comfortable for my case.</p> <p>Now I'm getting <code>E2250 There is no overloaded version of 'RS232_SendCommand' that can be called with these arguments</code></p> <pre><code>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; </code></pre> <p>This works, but I would be glad if I could leave the variable declaration.</p> <pre><code>function RS232_SendCommand(const Command: Integer): Boolean; overload; var Nothing: Pointer; begin Result := RS232_SendCommand(Command, Nothing, 0); end; </code></pre> <hr> <p>Solution is to use somthing like this.</p> <pre><code>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; </code></pre> <p>I'm doing this because some of my commands have a data sent after command transmission.</p> <p>Thanks for the help</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload