Hi all,

Is it possible to use inner classes in VFP like in Java? I've been
trying to do so, but i haven't got it working yet. Let's say I have this
code:

DEFINE CLASS MyOuter as Custom
InnerObject = NULL

PROCEDURE Init
THIS.InnerObject = NEWOBJECT("MyInner")
ENDPROC

DEFINE CLASS MyInner as Custom
...
...
ENDDEFINE
ENDDEFINE

When I run this, I get the message "Class definition MyInner is not found".
What am I doing wrong???

Thanks!

Regards,
Bami

Re: Inner classes by Lew

Lew
Tue Jul 15 05:18:03 CDT 2008

I'm not sure what an 'inner' class is, but you can't nest class defs. Try:

define class MyClass as Something
Inner = null

function init
this.Inner = createo(anotherclass)
enddef

define classs anotherclass as somethingelse
enddef


"Bamibal" <bamibal@eggs.bacon.spam.gmail.com> wrote in message
news:c3868$487c6a4d$52d99304$27268@cache60.multikabel.net...
> Hi all,
>
> Is it possible to use inner classes in VFP like in Java? I've been trying
> to do so, but i haven't got it working yet. Let's say I have this code:
>
> DEFINE CLASS MyOuter as Custom
> InnerObject = NULL
>
> PROCEDURE Init
> THIS.InnerObject = NEWOBJECT("MyInner")
> ENDPROC
>
> DEFINE CLASS MyInner as Custom
> ...
> ...
> ENDDEFINE
> ENDDEFINE
>
> When I run this, I get the message "Class definition MyInner is not
> found".
> What am I doing wrong???
>
> Thanks!
>
> Regards,
> Bami



Re: Inner classes by Stefan

Stefan
Tue Jul 15 05:20:59 CDT 2008


I think it might work when you put the second Define/Enddefine outside
the first:

Define myOuter ...
EndDefine

Define myInner ...
EndDefine


hth
-Stefan

first
"Bamibal" <bamibal@eggs.bacon.spam.gmail.com> schrieb im Newsbeitrag
news:c3868$487c6a4d$52d99304$27268@cache60.multikabel.net...
> Hi all,
>
> Is it possible to use inner classes in VFP like in Java? I've been trying to do so, but
> i haven't got it working yet. Let's say I have this code:
>
> DEFINE CLASS MyOuter as Custom
> InnerObject = NULL
>
> PROCEDURE Init
> THIS.InnerObject = NEWOBJECT("MyInner")
> ENDPROC
>
> DEFINE CLASS MyInner as Custom
> ...
> ...
> ENDDEFINE
> ENDDEFINE
>
> When I run this, I get the message "Class definition MyInner is not found".
> What am I doing wrong???
>
> Thanks!
>
> Regards,
> Bami
>



Re: Inner classes by Christof

Christof
Tue Jul 15 05:47:05 CDT 2008

Hi Bamibal,

That's not possible and not necessary. In other languages inner classes
often control the visibility of a class. In VFP classes are always public.
If you want to express that one class is only used by another one, you can
use a name like ClassA_InnerClass.

--
Christof



Re: Inner classes by Bamibal

Bamibal
Tue Jul 15 06:23:43 CDT 2008

Christof Wollenhaupt schreef:
> Hi Bamibal,
>
> That's not possible and not necessary. In other languages inner classes
> often control the visibility of a class. In VFP classes are always public.
> If you want to express that one class is only used by another one, you can
> use a name like ClassA_InnerClass.
>
Ok, i guess i'll have to live with this!

Thanks.

Re: Inner classes by Bamibal

Bamibal
Tue Jul 15 06:29:12 CDT 2008

Stefan Wuebbe schreef:
> I think it might work when you put the second Define/Enddefine outside
> the first:
>
> Define myOuter ...
> EndDefine
>
> Define myInner ...
> EndDefine
>
>
> hth
> -Stefan
>
That works, but that is not what I want. I want my inner class to be
invisible from the "outside world", so that only my outside class can
instantiate the inner class.
Thanks anyway!

Re: Inner classes by Anders

Anders
Tue Jul 15 06:42:52 CDT 2008

o = CREATEOBJECT('xx')
DEFINE CLASS xx as Form
ADD OBJECT yy as InnerClass
ENDDEFINE

DEFINE CLASS InnerClass AS Custom
FUNCTION Init
MESSAGEBOX( this.Parent.class )
IF This.ParentClass<>'Xx'
*
ENDIF
ENDFUNC
ENDDEFINE

As you see you can check that that InnerClass is used by the class xx, and
if you like, nobody else.
-Anders


"Lew" <lew@fastmail.fm> wrote in message
news:uHGjSQm5IHA.1420@TK2MSFTNGP06.phx.gbl...
> I'm not sure what an 'inner' class is, but you can't nest class defs. Try:
>
> define class MyClass as Something
> Inner = null
>
> function init
> this.Inner = createo(anotherclass)
> enddef
>
> define classs anotherclass as somethingelse
> enddef
>
>
> "Bamibal" <bamibal@eggs.bacon.spam.gmail.com> wrote in message
> news:c3868$487c6a4d$52d99304$27268@cache60.multikabel.net...
>> Hi all,
>>
>> Is it possible to use inner classes in VFP like in Java? I've been trying
>> to do so, but i haven't got it working yet. Let's say I have this code:
>>
>> DEFINE CLASS MyOuter as Custom
>> InnerObject = NULL
>>
>> PROCEDURE Init
>> THIS.InnerObject = NEWOBJECT("MyInner")
>> ENDPROC
>>
>> DEFINE CLASS MyInner as Custom
>> ...
>> ...
>> ENDDEFINE
>> ENDDEFINE
>>
>> When I run this, I get the message "Class definition MyInner is not
>> found".
>> What am I doing wrong???
>>
>> Thanks!
>>
>> Regards,
>> Bami
>
>