In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Pass a Parmater into a Modal form ??

Xailer professional forum in English
Responder
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

Pass a Parmater into a Modal form ??

Mensaje por ChrisGillard »

Hi,
I think I should know how to do this but I dont ...
When showing a Form from a button, I would like to pass in a parameter or
maybe several ??
In the form to be shown I have my code looks like this ... I have added
PROPERTY cMode
CLASS InvoiceForm FROM TForm
PROPERTY cMode INIT "" ----------- This is added by me
COMPONENT oGroupBox1
COMPONENT oGroupBox2
COMPONENT oLineBrowse
METHOD CreateForm()
METHOD FormInitialize( oSender )
ENDCLASS
My Calling code looks like this .....
METHOD NewBtnClick( oSender ) CLASS TMainForm
local oForm := InvoiceForm():New()
oForm:cMode := "ADD" ------------- but I dont think this is working ??
oForm:ShowModal()
RETURN Nil
I can put my cMode in the calling form & get the InvoiceForm to pick up from
the calling form ... but that seems poor practice.
So problem is "how to pass one or more parameters to a modal form called
from a button".
How does anyone else do this ??
Regards
Chris Gillard
Rene Flores
Mensajes: 620
Registrado: Jue Mar 23, 2006 2:39 am

Pass a Parmater into a Modal form ??

Mensaje por Rene Flores »

Chris:
>
> CLASS InvoiceForm FROM TForm
>
> PROPERTY cMode INIT "" ----------- This is added by me
>
> COMPONENT oGroupBox1
> COMPONENT oGroupBox2
> COMPONENT oLineBrowse
>
> METHOD CreateForm()
> METHOD FormInitialize( oSender )
>
> ENDCLASS
This is ok, no problem with it.
> METHOD NewBtnClick( oSender ) CLASS TMainForm
> local oForm := InvoiceForm():New()
> oForm:cMode := "ADD" ------------- but I dont think this is working ??
> oForm:ShowModal()
> RETURN Nil
This is the problem, you are not affecting the object you want, but
affecting some other object stored in oFrom, the oForm is a local
variable which disappears when the InvocieForm() is activated.
This is the correct way to do it:
METHOD NewBtnClick( oSender ) CLASS TMainForm
WITH OBJECT InvocieForm()
:cMode := "ADD"
:New(SELF):Showmodal()
END
RETURN
Let's see step by step:
1) The WITH OBJECT statment allows you to work with a "metaclass", a
metaclass is kind of a "pre-created" class, is not a call to a
function, is a call to the class itself.
2) You added you own data in the class defintion, very good, but you
cannot modified it once you called the constructor method (NEW()), you
have to change the value BEFORE calling the constructor method, because
once the constructor method is called, you cannot change the value of
your data unless you use some event of the class. That's why the asing
of :cMode is done before call the constructor method.
3) Once assigned your own data, you can call the constructor and show
methods.
This is a sample to pass two parameters to a class:
WITH OBJECT XlsProg()
:cNomArch := ALLTRIM(::oArchivo:Value)
:lSaldos := ::oCheckBox1:lChecked
:New(self):ShowModal()
END
And the class looks like this:
CLASS XlsProg FROM TForm
DATA cNomArch
DATA lSaldos
....
....
....
ENDCLASS
Regards
Rene Flores
http://www.ciber-tec.com
>
> I can put my cMode in the calling form & get the InvoiceForm to pick up from
> the calling form ... but that seems poor practice.
>
> So problem is "how to pass one or more parameters to a modal form called
> from a button".
>
> How does anyone else do this ??
>
> Regards
>
> Chris Gillard
>
>
Rene Flores
Mensajes: 620
Registrado: Jue Mar 23, 2006 2:39 am

Pass a Parmater into a Modal form ??

Mensaje por Rene Flores »

Chris:
>
> CLASS InvoiceForm FROM TForm
>
> PROPERTY cMode INIT "" ----------- This is added by me
>
> COMPONENT oGroupBox1
> COMPONENT oGroupBox2
> COMPONENT oLineBrowse
>
> METHOD CreateForm()
> METHOD FormInitialize( oSender )
>
> ENDCLASS
This is ok, no problem with it.
> METHOD NewBtnClick( oSender ) CLASS TMainForm
> local oForm := InvoiceForm():New()
> oForm:cMode := "ADD" ------------- but I dont think this is working ??
> oForm:ShowModal()
> RETURN Nil
This is the problem, you are not affecting the object you want, but
affecting some other object stored in oFrom, the oForm is a local
variable which disappears when the InvocieForm() is activated.
This is the correct way to do it:
METHOD NewBtnClick( oSender ) CLASS TMainForm
WITH OBJECT InvocieForm()
:cMode := "ADD"
:New(SELF):Showmodal()
END
RETURN
Let's see step by step:
1) The WITH OBJECT statment allows you to work with a "metaclass", a
metaclass is kind of a "pre-created" class, is not a call to a
function, is a call to the class itself.
2) You added you own data in the class defintion, very good, but you
cannot modified it once you called the constructor method (NEW()), you
have to change the value BEFORE calling the constructor method, because
once the constructor method is called, you cannot change the value of
your data unless you use some event of the class. That's why the asing
of :cMode is done before call the constructor method.
3) Once assigned your own data, you can call the constructor and show
methods.
This is a sample to pass two parameters to a class:
WITH OBJECT XlsProg()
:cNomArch := ALLTRIM(::oArchivo:Value)
:lSaldos := ::oCheckBox1:lChecked
:New(self):ShowModal()
END
And the class looks like this:
CLASS XlsProg FROM TForm
DATA cNomArch
DATA lSaldos
....
....
....
ENDCLASS
Regards
Rene Flores
http://www.ciber-tec.com
>
> I can put my cMode in the calling form & get the InvoiceForm to pick up from
> the calling form ... but that seems poor practice.
>
> So problem is "how to pass one or more parameters to a modal form called
> from a button".
>
> How does anyone else do this ??
>
> Regards
>
> Chris Gillard
>
>
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

Pass a Parmater into a Modal form ??

Mensaje por ChrisGillard »

Rene,
Your solution works 100%.
The InvocieForm() 'Metaclass' idea is one I will have to take some time to
research & hopefully understand .. at the moment I will just do it & be
happy that it works.
This has 'unstuck' some work I am doing trying to learn Xailer.
Xailer allows me to do a mixture of IDE & code based programming ... which
is how I like things.
Xailer is a truly great product & I hope it continues to grow.
I should also thank you for your Xailer 'blog' ... it has already helped me
in learning Xailer.
Regards
Chris Gillard
"Rene Flores" <"rflores[nospam]"@ciber-tec.com> wrote in message
news:4773e5b7$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
> Chris:
>>
>> CLASS InvoiceForm FROM TForm
>>
>> PROPERTY cMode INIT "" ----------- This is added by me
>>
>> COMPONENT oGroupBox1
>> COMPONENT oGroupBox2
>> COMPONENT oLineBrowse
>>
>> METHOD CreateForm()
>> METHOD FormInitialize( oSender )
>>
>> ENDCLASS
>
> This is ok, no problem with it.
>
>> METHOD NewBtnClick( oSender ) CLASS TMainForm
>> local oForm := InvoiceForm():New()
>> oForm:cMode := "ADD" ------------- but I dont think this is working
>> ??
>> oForm:ShowModal()
>> RETURN Nil
>
> This is the problem, you are not affecting the object you want, but
> affecting some other object stored in oFrom, the oForm is a local variable
> which disappears when the InvocieForm() is activated.
>
> This is the correct way to do it:
>
> METHOD NewBtnClick( oSender ) CLASS TMainForm
>
> WITH OBJECT InvocieForm()
> :cMode := "ADD"
> :New(SELF):Showmodal()
> END
> RETURN
>
> Let's see step by step:
>
> 1) The WITH OBJECT statment allows you to work with a "metaclass", a
> metaclass is kind of a "pre-created" class, is not a call to a function,
> is a call to the class itself.
>
> 2) You added you own data in the class defintion, very good, but you
> cannot modified it once you called the constructor method (NEW()), you
> have to change the value BEFORE calling the constructor method, because
> once the constructor method is called, you cannot change the value of your
> data unless you use some event of the class. That's why the asing of
> :cMode is done before call the constructor method.
>
> 3) Once assigned your own data, you can call the constructor and show
> methods.
>
> This is a sample to pass two parameters to a class:
>
> WITH OBJECT XlsProg()
> :cNomArch := ALLTRIM(::oArchivo:Value)
> :lSaldos := ::oCheckBox1:lChecked
> :New(self):ShowModal()
> END
>
> And the class looks like this:
>
> CLASS XlsProg FROM TForm
>
> DATA cNomArch
> DATA lSaldos
> ...
> ...
> ...
> ENDCLASS
>
> Regards
>
> Rene Flores
> http://www.ciber-tec.com
>
>
>
>>
>> I can put my cMode in the calling form & get the InvoiceForm to pick up
>> from the calling form ... but that seems poor practice.
>>
>> So problem is "how to pass one or more parameters to a modal form called
>> from a button".
>>
>> How does anyone else do this ??
>>
>> Regards
>>
>> Chris Gillard
>>
ChrisGillard
Mensajes: 384
Registrado: Mar May 01, 2007 5:49 pm

Pass a Parmater into a Modal form ??

Mensaje por ChrisGillard »

Rene,
Your solution works 100%.
The InvocieForm() 'Metaclass' idea is one I will have to take some time to
research & hopefully understand .. at the moment I will just do it & be
happy that it works.
This has 'unstuck' some work I am doing trying to learn Xailer.
Xailer allows me to do a mixture of IDE & code based programming ... which
is how I like things.
Xailer is a truly great product & I hope it continues to grow.
I should also thank you for your Xailer 'blog' ... it has already helped me
in learning Xailer.
Regards
Chris Gillard
"Rene Flores" <"rflores[nospam]"@ciber-tec.com> wrote in message
news:4773e5b7$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
> Chris:
>>
>> CLASS InvoiceForm FROM TForm
>>
>> PROPERTY cMode INIT "" ----------- This is added by me
>>
>> COMPONENT oGroupBox1
>> COMPONENT oGroupBox2
>> COMPONENT oLineBrowse
>>
>> METHOD CreateForm()
>> METHOD FormInitialize( oSender )
>>
>> ENDCLASS
>
> This is ok, no problem with it.
>
>> METHOD NewBtnClick( oSender ) CLASS TMainForm
>> local oForm := InvoiceForm():New()
>> oForm:cMode := "ADD" ------------- but I dont think this is working
>> ??
>> oForm:ShowModal()
>> RETURN Nil
>
> This is the problem, you are not affecting the object you want, but
> affecting some other object stored in oFrom, the oForm is a local variable
> which disappears when the InvocieForm() is activated.
>
> This is the correct way to do it:
>
> METHOD NewBtnClick( oSender ) CLASS TMainForm
>
> WITH OBJECT InvocieForm()
> :cMode := "ADD"
> :New(SELF):Showmodal()
> END
> RETURN
>
> Let's see step by step:
>
> 1) The WITH OBJECT statment allows you to work with a "metaclass", a
> metaclass is kind of a "pre-created" class, is not a call to a function,
> is a call to the class itself.
>
> 2) You added you own data in the class defintion, very good, but you
> cannot modified it once you called the constructor method (NEW()), you
> have to change the value BEFORE calling the constructor method, because
> once the constructor method is called, you cannot change the value of your
> data unless you use some event of the class. That's why the asing of
> :cMode is done before call the constructor method.
>
> 3) Once assigned your own data, you can call the constructor and show
> methods.
>
> This is a sample to pass two parameters to a class:
>
> WITH OBJECT XlsProg()
> :cNomArch := ALLTRIM(::oArchivo:Value)
> :lSaldos := ::oCheckBox1:lChecked
> :New(self):ShowModal()
> END
>
> And the class looks like this:
>
> CLASS XlsProg FROM TForm
>
> DATA cNomArch
> DATA lSaldos
> ...
> ...
> ...
> ENDCLASS
>
> Regards
>
> Rene Flores
> http://www.ciber-tec.com
>
>
>
>>
>> I can put my cMode in the calling form & get the InvoiceForm to pick up
>> from the calling form ... but that seems poor practice.
>>
>> So problem is "how to pass one or more parameters to a modal form called
>> from a button".
>>
>> How does anyone else do this ??
>>
>> Regards
>>
>> Chris Gillard
>>
Responder