Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The m. variable thing, the sequel
Message
De
27/01/2005 15:39:21
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
27/01/2005 15:37:15
Gary Foster
Pointsource Consulting LLC
Chanhassen, Minnesota, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Database:
Visual FoxPro
Divers
Thread ID:
00969478
Message ID:
00981450
Vues:
49
>The "&cBtnShapeRef." part evaluates to the object ref and "uses up" the first period. The second period allows the property ref. It more or less turns into:
>
>(cNewButtonRef+'.'+cBtnShapeName).visible=.t.
>
>IOW, you need two periods to blend the macro with a proprty/method ref
>
>Gary
>

Which is why I try to always terminate every macro with the period, much like open and close parentheses.

>>I concur. More specifically
>>
>>
m.oCmd = CREATEOBJECT('empty')
>>ADDPROPERTY(m.oCmd,'cString','wait window "test"')
>>lc=m.oCmd.cString
>>&lc
>>
>>works whereas
>>
>>
&'m.oCmd.cString'
>>
>>does not. It appears that macro substitution works only with base level memory variables and not with memory objects
>>
>>Could someone please enlighten me as to what the this code segment is referencing. I have included the full method further down in case more context is needed.
>>
>>
>>       &cBtnShapeRef..visible=.t.
>>
>>
>>It is part of a listbar code I downloaded. I am wondering what the ".." does.
>>
>>regards
>>Geoff Scott
>>
>>
Full code
>>
>>lparameters cCaption,cIcon,cTooltiptext,cItemform
>>local nButtonStyle,cNewButtonref,cBtnShapeName,cBtnShapeRef
>>with this
>>	.itemscount = .itemscount+1
>>	if .firstbutton = 0			&&first button added
>>		.firstbutton=1
>>	endif
>>	cNewButtonRef = 'this.button'+alltrim(str(this.itemscount))
>>	nButtonstyle = .parent.buttonstyle
>>	if nButtonstyle = 0
>>		.addobject('button'+alltrim(str(this.itemscount)),'coolbutton')
>>	else
>>		.addobject('button'+alltrim(str(this.itemscount)),'smallcoolbutton')
>>	endif
>>endwith
>>	
>>with &cNewButtonRef
>>	.bordercolor = this.backcolor
>>	.visible = .t.
>>	.width = this.width
>>	.buttonindex = this.itemscount
>>	cBtnShapeName  = 'btnShape'+alltr(str(.buttonindex))
>>	.addobject(cBtnShapeName,'btnshape')
>>	cBtnShapeRef=cNewButtonRef+'.'+cBtnShapeName
>>	&cBtnShapeRef..width = this.width
>>	&cBtnShapeRef..zorder
>>	&cBtnShapeRef..visible=.t.
>>	&cBtnShapeRef..tooltiptext = iif(vartype(cTooltiptext)='C',cTooltiptext,"")
>>	.itemform = iif(vartype(cItemform)='C',cItemform,"")
>>	.Icon.picture = cIcon
>>	.lblCaption.Caption = cCaption
>>	if nButtonstyle = 0
>>		.lblCaption.width = this.width-4
>>		.Icon.left = this.width/2-16
>>		.top = this.parent.folderheaderheight+ (this.itemscount-1)*this.buttonheight
>>	else
>>		.lblCaption.width = this.width-24
>>		.top = this.parent.folderheaderheight+ (this.itemscount-1)*this.buttonheight
>>	endif	
>>endwith
>>if this.parent.folderheaderheight+(this.itemscount*this.buttonheight) > this.height
>>	this.scrolldn.visible=.t.
>>	this.scrolldn.enabled=.t.
>>	this.scrolldn.zorder
>>endif
>>
>>
>>Regards
>>Geoff Scott
>>
>>>Hi, Gary-
>>>
>>>>I must have missed the real question here.
>>>
>>>The difference is subtle. It's not whether the variable's value has a period, but whether the variable's literal has one.
>>>
>>>>I put:
>>>>x=[messagebox(thisform.caption)]
>>>>&x
>>>>
>>>>x='thisform.caption'
>>>>messagebox(&x)
>>>
>>>In your example, The string "x" has been evaluated (no period in "x") and resulted in a perfectly legitimate command.
>>>
messagebox(thisform.caption)
>>>>
>>>>Isn't this what we're talking about? I must have misunderstood the issue.
>>>
>>>Let me give you an example, and hopefully, that'll help explain the difference. Let's say I have a form that builds a Select statement that I'll run before printing a report. So, I have a custom property called SelectCmd. Something like:
>>>
>>>ThisForm.SelectCmd = "Select * from Customers"
>>>
>>>I can't do the following:
>>>
>>>&thisform.SelectCmd.
>>>
>>>Or any other variation. Since the "." terminates the macro expression, FoxPro would try to find a string variable called ThisForm, but that's of course not available. So, I have to do this:
>>>
>>>lcCmd = thisform.SelectCmd
>>>&lcCmd. && Don't need the period in this case, but just making the point. No pun intended.
>>>
>>>The issue of prefixing literals with "m." is the same thing.
>>>
Local lcSelectCmd
>>>lcSelectCmd = "Select * from Customers"
>>>&m.SelectCmd. && Will look for a string variable "m"
>>>&lcSelectCmd. && Is okay.
>>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform