Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Macro substitution
Message
From
26/12/2002 10:20:29
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00735756
Message ID:
00735828
Views:
15
>Hi,
>how do I write the code for the following example in order to use name expression and to avoid macro substitution?
>
>I have the names of tables named like tablename1, tablename2 etc. The names are created by lcDbf="tablename"+ALLTRIM(STR(i)), where i is a number 1,2 etc. In each table I have a field named "cfield". the referenced field is stored in the variable lcField=lcDbf+".cfield". Further I have the following string in a form lcString="Thisform.Check"+ALLTRIM(STR(i))+".Caption"
>To set the caption I use &lcString=&lcDir, which works. I have tried to avoid macro substitution by doing the following:
>
>&lcString=(lcDir), does not work
>&lcString=EVALUATE(lcDir), works (but EVALUATE() is not a name expression?)
>(lcString)=EVALUATE(lcDir), generates the error "unrecognized command verb"
>EVALUATE(lcString))=EVALUATE(lcDir), generates the error "syntax error"
>
>In this case it looks like you can not entirely avoid macro substitution, or do you have any sugestion?

You could use :
store eval(m.lcDir) to (m.lcString)
or :
store eval(m.lcDir) to ("Thisform.Check"+ALLTRIM(STR(i))+".Caption")
or :
store eval("tablename"+ALLTRIM(STR(ix))+".cField") to ;
("Thisform.Check"+ALLTRIM(STR(i))+".Caption")

Genarally I need to set more than one properties thus I prefer a style like :
for ix=1 to lnObjects
  with eval("Thisform.Check"+ALLTRIM(STR(ix)))
    .Caption = eval("tablename"+ALLTRIM(STR(ix))+".cField")
    .Someproperty = ...
  endwith
endfor
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform