Page 1 of 1

Macro operator

Posted: Tue Sep 21, 2010 8:44 pm
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

Re: Macro operator

Posted: Wed Sep 22, 2010 6:10 am
by Antonio Linares
Raymond,

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

Re: Macro operator

Posted: Wed Sep 22, 2010 6:45 am
by Maurizio
Raymond,

Code: Select all

FOR nInd := 10 TO 20
   cFld := "D" + Str(nInd,2)
   &(cFld) := nInd
NEXT
 
Maurizio

Re: Macro operator

Posted: Wed Sep 22, 2010 10:14 am
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

Re: Macro operator

Posted: Wed Sep 22, 2010 1:09 pm
by Antonio Linares
Raymond,

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

MsgInfo( __ObjSendMsg( oTable, cFld ) )

Re: Macro operator

Posted: Sat Oct 02, 2010 8:41 pm
by Raymond Fischbach
Thanks Antonio,
Raymond