Cédric Joubert wrote:
> I'mnew on the list... happy to see that there is such a list...
>
> Can you tell me to pass "nothing" to a function/proc that waits for an Var
> argument ?

I can tell you to do that, but you won't be able to obey because it's not
possible.

> Let's take the System
>     procedure Val(S;var V;var Code:Integer);
>
> Val(S, 0, 0);  OR  Val(S, Null, Null);     doesnt' work of course
>
> var
>    S: String;
>    myV : Integer;
>    myCode : Integer;
> begin
>    Val(S, myV, myCode);     works fine until I don't use the 2 var after
> so it makes a warning (hint) i don't want
>
>
> How may I delete the warning/hint if the myV or myCode argument are never
> used after so i don't need a to declare a new var ?
> (even i know that the arguments are to be used, of course :-)  )
>
> Proc "Val" is juste an example...

No, it's not just an example. It's actually a special case. You will not
see the same warning with any other procedures that have "var" parameters.
The Val procedure is a compiler-magic function. The compiler takes your
code and rewrites it as this:

myCode := System._ValLong(S, myV);

That's the code that the code-analyzer sees. It sees an assignment to the
myCode variable, and when it does not see you use that variable, it issues
its usual "assigned but never used" hint.

Other code is _not_ rewritten like that, so there is no unused assignment
statement to hint about.

You can use something other than Val. You could use TryStrToInt, for
example. Or, you could use both output parameters from Val. You mustn't
ignore the Code parameter, anyway, since it tells you whether the Value
parameter is meaningful.

-- 
Rob


_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to