Nate,
That's exactly what I came up with.  We were just wondering if that was the
only way to do it.

What's cool about this is I can refer to the object by doing the
following...

for i in range(1, 10):
   exec("o=self.biz%s = dabo.biz.dBizObj()" % i)
   o.CurrentSql=....
   o.do_something_else  

Thanks 
Larry Long

p.s  If I executed the code above, does
o=None
Release the bizobj? I don't think it does.  if not, then how can I release
it?

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Nate Lowrie
Sent: Wednesday, September 12, 2007 5:55 PM
To: Dabo Users list
Subject: Re: [dabo-users] what is the replacement of VFP macro's

for i in range(1, 10):
    exec("self.biz%s = dabo.biz.dBizObj()" % i)

exec works in this instance.  Gotta be careful when using it, although it is
a powerful tool.

On 9/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Paul,
>
> We are actally trying to initialize a new object.  The getattr appears 
> to work for existing object.
>
> For example, we want to create x instances of a bizobj
>
> Looking for code that would do the equivalent of
>
> For i=1 to x
> Self.biz1=dabo.biz.dBizObj
> Self.biz2=dabo.biz.dBizObj
> ...
> Self.bizx=dabo.biz.dBizObj
> Etc,
>
> Thanks,
> Larry
>
> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Paul McNett
> Sent: Wednesday, September 12, 2007 4:47 PM
> To: Dabo Users list
> Subject: Re: [dabo-users] what is the replacement of VFP macro's
>
> Paul McNett wrote:
> > johnf wrote:
> >> Hi,
> >> in VFP I would use "&variable."  How do I do the same for Dabo?
> >> I.e I want the following to work
> >>
> >> curlabel = "test"+"01"
> >> self.&curlabel. = "somestr"  ## where self is an object
> >
> > self.getattr(curlabel).Caption = "somestr"
> >
> > This assumes that self has a label that is named 'test01'.
>
> Oops, sorry, I keep forgetting that getattr() is a builtin function, 
> and not a method of Python objects. Here's the actual answer:
>
> getattr(self, curlabel).Caption = "somestr"
>
> Actually, you'd be better off checking that you have an object first:
>
> lbl = getattr(self, curlabel, None)
> if lbl:
>         lbl.Caption = "somestr"
>
> HTH
>
> --
> pkm ~ http://paulmcnett.com
>
>
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/dabo-users/!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAafA2fnYuPUOMNFpIYnBEQcKAAAAQAAAA7Z4F4Uolt0Kse61x/[EMAIL
 PROTECTED]

Reply via email to