On Fri, 30 May 2008, Mindaugas Kavaliauskas wrote:

Hi Mindaugas,

> one more sample code:
> ----------------------
> PROC main()
> LOCAL cI := "1"
>   ProcX(@cI)
>   ? cI
> RETURN
> 
> PROC ProcX(...)
> LOCAL aArg := hb_AParams()
>   aArg[1] := "2"
> RETURN
> ----------------------
> Results are:
> xHarbour:
> 2
> Harbour:
> 1
> 
> What is expected result for this code?

Harbour gives expected result which is Clipper compatible.

> Is there any way to assign parameter by reference in case of
> variable number of parameters?

In your example:
   hb_pValue( 1, "2" )

This is not problem of parameters passed by reference to
functions/procedure with variable number of parameters
but how references in arrays are hold.
xHarbour gives different results because in xHarbour the
behavior of references stored in array items is reverted
and Harbour is strictly Clipper compatible.

Please look at this example:

proc main()
   local a, cI
   cI:="1"
   a:[EMAIL PROTECTED]
   ProcX(a)
   ? cI
return
proc ProcX(aArg)
   local x:=aArg[1]
   x:="2"
return

Clipper and Harbour show "2" when xHarbour shows "1".
Please note that if you use in your code:

   proc ProcX(aArg)
      local x:=hb_AParams()[1]
      x:="2"
   return

then variable cI will also be changed.

The above trick is quite commonly used by Clipper programmers
as workaround for limited number of parameters in function/procedure
(AFAIR 32) so it cannot be changed without breaking existing Clipper
code.


best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to