Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic Label
Message
From
03/03/2024 16:08:51
 
 
To
01/03/2024 10:12:37
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
01687658
Message ID:
01687670
Views:
71
You are probably correct. Still *just from syntax* it is the best way
to sidestep the need for an init method defined for additional parameters,
as named parameters are only possible via parsing wrapper and
directly setting *only* non-default properties is good with add abject.

Probably could be enhancement hacked in Vfp Advanced or Vfp-C-Compiler,
as it only needs a pointer to start of object hierarchy and name, value pairs list,
which can be resolved. OTOH in many dynamic building I can think of
the use cases would benefit from defined added class with specific .init(),
which here would have those 2 dynamic parameters from OP
filled either in create or addobject(), rest done in define class defaults.

>Don't think so, ADD OBJECT belongs to the DEFINE CLASS syntax, not to code running.
>
>>can be done in more ways...
>>
>>oLabel = createobject( "Label")
>>with oLabel
>>endwith
>>loForm.Addobject("elbl"+Alltrim(Recno()), "label", oLabel )
>>
>>upd: not really certain if
>>scan
>>  cLabel = "elbl"+Alltrim(Recno())
>>  ADD OBJECT ("loForm."+m.cLabel)  AS label WITH ;
>>    Top = , ;
>>    Left = , ;
>>    Visible = .T., ;
>>    Name = m.cLabel
>>endscan
>>would work
>>
>>
>>
>>>>>>I'm really sorry for my earlier wrong comments. It seems that you can't use With-Endwith the way you do. Try the following workaround instead:
>>>>>>
>>>>>>  oLabel = "elbl"+Alltrim(Str(i))
>>>>>>  loForm.Newobject(oLabel, "Label")
>>>>>>  With eval("loform."+olabel)
>>>>>
>>>>>Another option is my favorite trick (stolen from Fabio, he found it)
>>>>>
>>>>>with getpem(loForm, oLabel)
>>>>
>>>>There are always several ways to the same goal with FoxPro. :-)
>>>
>>>There were two versions of the proverb, can't decide which one I prefer:
>>>
>>>if it can't be done three ways in fox
>>>- it's not worth doing at all
>>>- it can't be done anyway
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform