FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour OT macro operator
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
OT macro operator
Posted: Wed Oct 24, 2007 10:35 AM
Hi All,

a very stupid question but it's driving me nuts.
I want to update a field in a dbf.
The field name is defined in an array.

#define DB_DBF 1
#define DB_FLD 2

LOCAL aDbf := {;
            { "dbf_1", "fiel_name_1" },;
            { "dbf_2", "fiel_name_2" },;
             ...
            { "dbf_n", "fiel_name_n" },;
    }

I can do
use ( aDbf[n][DB_DBF] ) shared alias wrk new

But i can not
wrk->&aDbf[n][DB_FLD] := uVal


I tried several variations. Either i get "invalid lvalue" at compile time or "&syntax error" at runtime.

So many years clippering but stumbling over such stupidity.
Sorry for bothering you. :-)

Regards,
Detlef
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: OT macro operator
Posted: Wed Oct 24, 2007 11:32 AM

Detlef,

I remember some time ago having a similar problem

This is how i got it working

DT := "CLIENT" + ALLTRIM(SUBS(TABVAR[15][J],63,6))
REPLACE (MYFILE)->&DT WITH .....

HTH

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
OT macro operator
Posted: Wed Oct 24, 2007 11:44 AM
Richard,

thanks a lot for your answer.
I just found an other workaround which i will also show, allthough it is dangerous code if the field doesn' t exist.

wrk->( fieldput( fieldpos( aDbf[ n ][ DB_FLD ] ), uVal ) )


But thanks again, Richard.
Regards,
Detlef
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
OT macro operator
Posted: Wed Oct 24, 2007 12:00 PM
This works:

wrk->&( aDbf[n][DB_FLD] ) := uVal


Anyway my personal preference in such cases is fieldput and fieldpos. I try to avoid macros. Again its a matter of choice.
Regards



G. N. Rao.

Hyderabad, India
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
OT macro operator
Posted: Wed Oct 24, 2007 12:14 PM

NageswaraRao,

many thanks for your answer.
As you i always avoided the use of the macro operator.
But therefor i have a poor knowledge about it.

Thanks again for your hint.

Regards,
Detlef

Posts: 9
Joined: Tue Aug 28, 2007 09:09 AM
OT macro operator
Posted: Wed Oct 24, 2007 01:49 PM
Hi Detlef,

I had a similar problem just yesterday trying to do:

cDBField := "ACNT_NBR"
REPLACE PAYMENT->&cDBField WITH cValue


This was causing the "&syntax error" you mentioned.

I fixed it by doing the following:

cDBField := "PAYMENT->ACNT_NBR"
REPLACE &cDBField WITH cValue


Not sure if this will help in your circumstances but it worked for me.

Kind regards,

Barry
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
OT macro operator
Posted: Wed Oct 24, 2007 02:12 PM

Thanks, Barry

the response in this forum is unbelievable.

Regards,
Detlef

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
OT macro operator
Posted: Thu Oct 25, 2007 01:28 AM

Detlef,

Aren't you using TData? Did you know that the data is already buffered?

In TData the fieldnames are stored in aFldnames.

Perhaps if you explain what you are trying to do, I can help with a TData solution.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
OT macro operator
Posted: Thu Oct 25, 2007 08:06 AM

James,

thanks for your kind offer.
But my problem concerned a mere MS DOS program where i had dbf and field names in an array and had to update those fields in a loop from each dbf.

Thanks and regards,
Detlef

Posts: 1446
Joined: Mon Oct 10, 2005 02:38 PM
OT macro operator
Posted: Thu Oct 25, 2007 10:59 AM
James Bott wrote:Detlef,

Aren't you using TData? Did you know that the data is already buffered?

In TData the fieldnames are stored in aFldnames.

Perhaps if you explain what you are trying to do, I can help with a TData solution.

James


Where is Tdata class?

Thanks,
Carlos G.

Un Saludo

Carlos G.



FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
OT macro operator
Posted: Thu Oct 25, 2007 09:05 PM

>Where is Tdata class?

TData is a commercial product I developed. You can read more about it and download a demo on my website.

http://ourworld.compuserve.com/homepage ... rogram.htm

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion