Macro operator

Post Reply
User avatar
Raymond Fischbach
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium
Contact:

Macro operator

Post by Raymond Fischbach »

Hello all,

I have a table with various field named D10,D11,D12,D13, ...
I would like to update the fields in a loop using the macro operator.
Something similar to

Code: Select all

LOCAL cFld := ""
LOCAL nInd := 0

FOR nInd := 10 TO 20
   cFld := "D" + Str(nInd,2)
   oTable:&cFld := nInd
NEXT
 
This doesn't seem to work.
Can someone tell me the syntax to be used?

Many thanks in advance,
Raymond
Raymond Fischbach
www.mouches.org
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Macro operator

Post by Antonio Linares »

Raymond,

__ObjSendMsg( oTable, "_" + cFld, nInd )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Re: Macro operator

Post by Maurizio »

Raymond,

Code: Select all

FOR nInd := 10 TO 20
   cFld := "D" + Str(nInd,2)
   &(cFld) := nInd
NEXT
 
Maurizio
User avatar
Raymond Fischbach
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium
Contact:

Re: Macro operator

Post by Raymond Fischbach »

Thank you Antonio and Maurizio,

Antonio,
I did not try your solution because I asked only half of my problem and your solution works when I want to replace the value of a field but I still don't know how to retrieve the value of the field.

Maurizio,
Your syntax works perfectly.

This is my code now:

Code: Select all

cFld := "D" + cDia
nTmp := oF10b:&(cFld)
nTmp ++
oF10b:&(cFld) := nTmp
 
Many thanks for this fast help,
Raymond
Raymond Fischbach
www.mouches.org
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Macro operator

Post by Antonio Linares »

Raymond,

To retrieve a data value don't use the "_":

MsgInfo( __ObjSendMsg( oTable, cFld ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Raymond Fischbach
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium
Contact:

Re: Macro operator

Post by Raymond Fischbach »

Thanks Antonio,
Raymond
Raymond Fischbach
www.mouches.org
Post Reply