Olá!
Não sei se é o seu caso. Mas um lembrete.
xHarbour does not support auto-add on access or reference operations and
passing hash array items by reference does not work (see passing array and
hash item by reference).
In xHarbour only passing array items by reference works but does not work
passing hash items by reference though it does not generate either
compile time or run time errors so the above code can be compiled and
executed but it shows:
abc klm xyz 123 456 789
abc [1] xyz 123 456 789
Tem diferença do Harbour para o xHarbour.
Código: Selecionar todos
It can be seen in code like:
proc main
local p1 := "A", p2 := "B", p3 := "C"
? p1, p2, p3
p( { @p1, p2, @p3 } )
? p1, p2, p3
proc p( aParams )
local x1, x2, x3
x1 := aParams[ 1 ]
x2 := aParams[ 2 ]
x3 := aParams[ 3 ]
x1 := Lower( x1 ) + "1"
x2 := Lower( x2 ) + "2"
x3 := Lower( x3 ) + "3"
Harbour and Clipper shows:
A B C
a1 B c3
but xHarbour:
A B C
A B C
PASSING ARRAY AND HASH ITEMS BY REFERENCE
Código: Selecionar todos
Harbour supports passing array and hash items by reference, f.e.:
proc main()
local aVal := { "abc", "klm", "xyz" }, ;
hVal := { "qwe"=>"123", "asd"=>"456", "zxc"=>"789" }
? aVal[1], aVal[2], aVal[3], hVal["qwe"], hVal["asd"], hVal["zxc"]
p( @aVal[2], @hVal["asd"] )
? aVal[1], aVal[2], aVal[3], hVal["qwe"], hVal["asd"], hVal["zxc"]
proc p( p1, p2 )
p1 := '[1]'
p2 := '[2]'
Compiled by Harbour above code shows:
abc klm xyz 123 456 789
abc [1] xyz 123 [2] 789
In xHarbour only passing array items by reference works but does not work
passing hash items by reference though it does not generate either
compile time or run time errors so the above code can be compiled and
executed but it shows:
abc klm xyz 123 456 789
abc [1] xyz 123 456 789
PASSING OBJECT VARIABLES BY REFERENCE
Both compilers support passing object variables by reference though this
functionality in xHarbour is limited to pure instance or class variables
only and does not work for SETGET methods. In Harbour it works correctly.
This code illustrates the problem:
proc main()
local oBrw := TBrowseNew()
? oBrw:autoLite
oBrw:autoLite := !oBrw:autoLite
?? "=>", oBrw:autoLite
p( @oBrw:autoLite )
?? "=>", oBrw:autoLite
proc p( x )
x := !x
Harbour prints:
.T.=> .F.=> .T.
but xHarbour prints:
.T.=> .F.=> .F.
without generating any compile or run time errors.
Saudações,
Itamar M. Lins Jr.