Suppose I need to dynamically create a series of objects and set their
properties at run-time. What is the syntax I would use.

For example lets suppose that under certain conditions that might occur
while I'm scanning a database, I would like to create a label on a form and
set its properties. For
convenience (and uniqueness) I'm going to name the objects based on the
record number in the database. Please help me filling what I'm missing:

SCAN
IF <condition occurs>
obname = alltrim(str(recno()))
thisform.addobject(obname, "Label")

* here is the part that I don't know the syntax for
* I need to set the top, left, width, and caption of this label that
was just created.
* the name of the object is contained in a variable
* a "c like" approach would be something like thisform->obname.top =
5 but I doubt that is correct

ENDIF
ENDSCAN

Thanks in advance

Jeff

Re: Indirect Object Reference by Jack

Jack
Sat Mar 06 17:40:51 CST 2004

On Sat, 6 Mar 2004 18:06:06 -0500, "Jeff Grippe" <jeff@door7> wrote:

>Suppose I need to dynamically create a series of objects and set their
>properties at run-time. What is the syntax I would use.
>
>For example lets suppose that under certain conditions that might occur
>while I'm scanning a database, I would like to create a label on a form and
>set its properties. For
>convenience (and uniqueness) I'm going to name the objects based on the
>record number in the database. Please help me filling what I'm missing:
>
>SCAN
> IF <condition occurs>
> obname = alltrim(str(recno()))
> thisform.addobject(obname, "Label")
>
> * here is the part that I don't know the syntax for
> * I need to set the top, left, width, and caption of this label that
>was just created.
> * the name of the object is contained in a variable
> * a "c like" approach would be something like thisform->obname.top =
>5 but I doubt that is correct

oObj = EVALUATE("Thisform." + obname)
oObj.Top =
...
oObj.Visible = .T. && Added objects are invisible by default

>
> ENDIF
>ENDSCAN

Also, I would use:
obname = '_' + ALLTRIM(STR(RECNO()))

I don't think object names can be all numeric. You can also use
SYS(2015) to get a unique name.


Re: Indirect Object Reference by Fred

Fred
Sat Mar 06 17:43:33 CST 2004

SCAN
IF <condition occurs>
obname = "lbl"+alltrim(str(recno()))
thisform.addobject(obname, "Label")

* here is the part that I don't know the syntax for
* I need to set the top, left, width, and caption of this label
that
was just created.
* the name of the object is contained in a variable
* a "c like" approach would be something like thisform->obname.top
=
5 but I doubt that is correct

oObName = EVAL("thisform."+obname)
oObName.Left = 10
or
thisform.&obname..Left = 10

ENDIF
ENDSCAN

Fred
Microsoft Visual FoxPro MVP


"Jeff Grippe" <jeff@door7> wrote in message
news:104kmattfjsqj8a@news.supernews.com...
> Suppose I need to dynamically create a series of objects and set their
> properties at run-time. What is the syntax I would use.
>
> For example lets suppose that under certain conditions that might occur
> while I'm scanning a database, I would like to create a label on a form
and
> set its properties. For
> convenience (and uniqueness) I'm going to name the objects based on the
> record number in the database. Please help me filling what I'm missing:
>
> SCAN
> IF <condition occurs>
> obname = alltrim(str(recno()))
> thisform.addobject(obname, "Label")
>
> * here is the part that I don't know the syntax for
> * I need to set the top, left, width, and caption of this label
that
> was just created.
> * the name of the object is contained in a variable
> * a "c like" approach would be something like thisform->obname.top
=
> 5 but I doubt that is correct
>
> ENDIF
> ENDSCAN
>
> Thanks in advance
>
> Jeff
>
>