Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

macro substitution

Status
Not open for further replies.

bcoats

Programmer
Jun 20, 2001
49
US
.AddObject('lblID'+ALLTRIM(STR(thisform.branchcount)),'label')
theCmd = ".lblID" + ALLTRIM(STR(thisform.branchcount))
&theCmd.caption = curbranch.Branch_Num
&theCmd.width = 100
&theCmd.top = 60 + ((thisform.branchcount - 1) * 40)
&theCmd.left = 10

this is my code embedded in a loop to try and add multiple objects at runtime. Is this right or do I need to do it thus since I am referencing a property.

This raised the question. (from the Foxpro help)

Code:
The optional period (.) delimiter and .cExpression are used to append additional characters to a macro. cExpression appended to the macro with .cExpression can also be a macro. If cExpression is a property name, include an extra period (cExpression..PropertyName).

which would sort of suggest this senario:

&theCmd..caption = curbranch.Branch_Num
&theCmd..width = 100
&theCmd..top = 60 + ((thisform.branchcount - 1) * 40)
&theCmd..left = 10

thanks for any help you migh offer

bcoats
 

What exactly are you asking? Whether you need double period or not in this case? If so, yes you do. One would end the macro substitution, the other one would indicate that you are referencing a property.

Say, I also use it in this way.

Code:
[COLOR=black gray]* Example:[/color]
 
FOR jj=1 TO someNumber4
	[COLOR=black gray]* do something [/color]
	jjj=ALLTRIM(STR(jj,2))
	[b]ThisForm.lblCheck&jjj..Caption=IIF(abnorm<>0, "!", "X")[/b]	
	[COLOR=black gray]* do something else[/color]
NEXT

In any case, you can always run it and see if it works.
 
thanks, I did need both (..). was trying to understand what was going on before I blew up my program.

Thanks
 
This code must be somewhere within WITH..ENDWITH.
You can nest another WITH..ENDWITH inside that:

Code:
With Thisform.pageframe1.page2 && or whatever
   lcTheObjectname = "lblID"+TRANSFORM(thisform.branchcount)
   .Addobject(lcTheObjectname,"label")
   With .&lcTheObjectname
      .Caption = ...
      ...
      .visible = .T.
   Endwith
Endwith

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top