Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Macro Expansion with REPLACE
Message
De
23/04/2002 19:08:11
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
23/04/2002 17:12:22
Donald Lowrey
Data Technology Corporation
Las Vegas, Nevada, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00648428
Message ID:
00648472
Vues:
15
Int(val(lnCnt)) would return a numeric expression which means your code should be failing when you try to create lcFieldName ;). Transform() can turn lnCnt into a string.

VAL would only work if lnCnt was a character expression to begin with.

So, I'm not sure how you got to the replace command. However, if you did this...

lcFieldName = "field"+transform(int(lnCnt))
replace &lcFieldName with "myvalue"

you should be fine. The period after lcFieldName tells VFP that the macro substitution has ended. If your field names were like this...

tbl01Fld
tbl02Fld
tbl03Fld

Your code could look like this...

lcFieldNumber = transform(lnCnt)

replace tbl&lcFieldNumber.Fld with "myvalue"





>Hi all
>
>Has anyone had any success using macro (&) expansion with the REPLACE command?
>
>I am attempting to use a loop with a REPLACE inside the loop. The field names and the values to be replaced change with every iteration. I am using macro substitution, the values are correct asigned, but REPLACE crashes every time with an unrecognized command or syntax error, depending on the circumstances.
>
>The code is like this:
>
>lcfieldname = "field" + INT(VAL(lnCnt)) && ex. to illustrate changing field name
>
>lcvalue = "myvalue"
>SELECT mytable
>REPLACE &lcfieldname WITH lcvalue
>lnCnt = lnCnt + 1
>
>Any suggestions would be appreciated.
>
>Thanks
>Donald Lowrey
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform