m.var1 = mytable.&FieldName * Direct conversation to Name expresion wouldn't work m.var1 = mytable.(FieldName) * But this will m.var1 = ("mytable." + m.FieldName)I would suggest that you change your code as shown below. There's no reasonto use macro substitution in this case.
replace &lcfldnm1 with .t. * --> replace (lcfldnm1) with .t. ... replace &lcfldnm2 WITH a.&lcfldnm1 && accepted * --> replace (lcfldnm2) WITH EVALUATE("a." + lcfldnm1)See the reasons for errors below each line
replace (lcfldnm2) WITH a.(lcfldnm1) &&syntax error * Name expression has to replace whole name replace b.lcfldnm2 WITH a.lcfldnm1 &&accepted,when executed can't find lcfldnm1&2 * The command references fields with names 'b.lcfldnm2' and 'a.lcfldnm1' * which don't exist replace (b.lcfldnm2) WITH (a.lcfldnm1) &&accepted,when executed can't find lcfldnm1&2 * The command references fields which names aro stored in the * fields 'b.lcfldnm2' and 'a.lcfldnm1' and they don't existThere're also cases when macro substitution is only way to achive something. For example, building dynamic SQL command. In other cases performance may be better with macro substitution. For example, SCAN command with dynamic FOR clause.
>PARAMETERS m.lcdir, m.lcfil >MESSAGEBOX("in yahinv") >CD (lcdir) >SET MULTILOCKS ON >m.liwkarea1=1 >m.liwkarea2=2 >SELECT 1 &&wk area a >USE (lcfil) >COPY STRUCTURE EXTENDED TO hdr >SELECT 2 >USE hdr >GO 2 >m.lcfldnm1=FIELD(5) >replace &lcfldnm1 with .t. >CREATE temp from hdr >ERASE hdr.dbf >SELECT 2 >USE temp >SELECT a >m.lircdcnt=RECCOUNT(1) >SELECT b >FOR m.icnt = 1 TO m.lircdcnt > APPEND BLANK >ENDFOR >GO top >CURSORSETPROP("Buffering",5) >SELECT a >FOR m.lifldcnt = 1 TO FCOUNT() > GO bottom > DO WHILE m.lircdcnt => 1 > m.lcfldnm1=FIELD(m.lifldcnt) > SELECT b > m.lcfldnm2=FIELD(m.lifldcnt) > replace &lcfldnm2 WITH a.&lcfldnm1 && accepted > replace (lcfldnm2) WITH EVALUATE("a."+lcfldnm1) &&accepted > REPLACE (lcfldnm2) WITH (lcfldnm1) IN m.liwkarea1 &&accepted > replace (lcfldnm2) WITH a.(lcfldnm1) &&syntax error > replace b.lcfldnm2 WITH a.lcfldnm1 &&accepted,when executed can't find lcfldnm1&2 > replace (b.lcfldnm2) WITH (a.lcfldnm1) &&accepted,when executed can't find lcfldnm1&2 > WAIT "stop" > SKIP 1 > SELECT a > m.lircdcnt = m.lircdcnt - 1 > ?m.lircdcnt > SKIP -1 > ENDDO > m.lircdcnt=RECCOUNT(1) > SELECT b > GO top > SELECT a > WAIT "ready for next for loop" >ENDFOR