Thread overview |
---|
December 06, 2009 Getting access to the variables of an imported class | ||||
---|---|---|---|---|
| ||||
Greetings! I have this program, import dfl.all; import myform2; void main() { Form d = new MyForm(); d.text = "Hello..."; //d.Name.text = "name"; d.show(); } that compiles fine. Here is myform2 code: /* Generated by Entice Designer Entice Designer written by Christopher E. Miller www.dprogramming.com/entice.php */ import dfl.all; class MyForm: dfl.form.Form { // Do not modify or move this block of variables. //~Entice Designer variables begin here. dfl.textbox.TextBox Name; //~Entice Designer variables end here. this() { initializeMyForm(); //@ Other MyForm initialization code here. } private void initializeMyForm() { // Do not manually modify this function. //~Entice Designer 0.8.6pre4 code begins here. //~DFL Form text = "My Form"; clientSize = dfl.all.Size(292, 273); //~DFL dfl.textbox.TextBox=Name Name = new dfl.textbox.TextBox(); Name.name = "Name"; Name.bounds = dfl.all.Rect(24, 8, 176, 24); Name.parent = this; //~Entice Designer 0.8.6pre4 code ends here. } } However, when I "uncomment" the this line, //d.Name.text = "name";, import dfl.all; import myform2; void main() { Form d = new MyForm(); d.text = "Hello..."; d.Name.text = "name"; d.show(); } the compiler complains with, 19:46:19.65>build -I..;c:\D\dmd\import -version=gui -version=Phobos testDFL.d testDFL.d(8): Error: no property 'Name' for type 'dfl.form.Form' testDFL.d(8): Error: no property 'text' for type 'int' testDFL.d(8): Error: constant 1.text is not an lvalue testDFL.d(8): Error: cannot implicitly convert expression ("name") of type char[4u] to int I know this is not the DFL forum, but maybe this is a D trick that I am missing somewhere. Any help would be greatly appreciated. thanks, josé |
December 06, 2009 Re: Getting access to the variables of an imported class | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | On Sun, 06 Dec 2009 05:52:05 +0200, jicman <cabrera_@_wrc.xerox.com> wrote:
> However, when I "uncomment" the this line, //d.Name.text = "name";,
>
> import dfl.all;
> import myform2;
>
> void main()
> {
> Form d = new MyForm();
> d.text = "Hello...";
> d.Name.text = "name";
> d.show();
> }
>
> the compiler complains with,
>
> 19:46:19.65>build -I..;c:\D\dmd\import -version=gui -version=Phobos testDFL.d
> testDFL.d(8): Error: no property 'Name' for type 'dfl.form.Form'
> testDFL.d(8): Error: no property 'text' for type 'int'
> testDFL.d(8): Error: constant 1.text is not an lvalue
> testDFL.d(8): Error: cannot implicitly convert expression ("name") of type char[4u] to int
I dont have DFL installed, but try this:
import dfl.all;
import myform2;
void main()
{
auto d = new MyForm();
d.text = "Hello...";
d.Name.text = "name";
d.show();
}
|
December 06, 2009 Re: Getting access to the variables of an imported class | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | jicman Wrote:
>
> However, when I "uncomment" the this line, //d.Name.text = "name";,
>
> import dfl.all;
> import myform2;
>
> void main()
> {
> Form d = new MyForm();
> d.text = "Hello...";
> d.Name.text = "name";
> d.show();
> }
>
I dont have DFL installed, but try this:
import dfl.all;
import myform2;
void main()
{
//Form d = new MyForm();
//MyForm d = new MyForm();
auto d = new MyForm();
d.text = "Hello...";
d.Name.text = "name";
d.show();
}
|
December 06, 2009 Re: Getting access to the variables of an imported class | ||||
---|---|---|---|---|
| ||||
Posted in reply to aalm | aalm Wrote:
> jicman Wrote:
>
> >
> > However, when I "uncomment" the this line, //d.Name.text = "name";,
> >
> > import dfl.all;
> > import myform2;
> >
> > void main()
> > {
> > Form d = new MyForm();
> > d.text = "Hello...";
> > d.Name.text = "name";
> > d.show();
> > }
> >
>
> I dont have DFL installed, but try this:
>
> import dfl.all;
> import myform2;
>
> void main()
> {
> //Form d = new MyForm();
> //MyForm d = new MyForm();
> auto d = new MyForm();
> d.text = "Hello...";
> d.Name.text = "name";
> d.show();
> }
thanks. That worked. Would you care to explain? :-) I know what auto does, but I thought that a Form was a form and a Class was a class. Does auto here would suffice for all other kinds of variables?
Thanks for the help.
josé
|
December 06, 2009 Re: Getting access to the variables of an imported class | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | jicman wrote: > aalm Wrote: >> import dfl.all; >> import myform2; >> >> void main() >> { >> //Form d = new MyForm(); >> //MyForm d = new MyForm(); >> auto d = new MyForm(); >> d.text = "Hello..."; >> d.Name.text = "name"; >> d.show(); >> } > > thanks. That worked. Would you care to explain? :-) I know what auto does, but I thought that a Form was a form and a Class was a class. Does auto here would suffice for all other kinds of variables? > > Thanks for the help. > > jos� Sometimes, I think all compiler errors should be replaced with "Something went wrong." No one ever seems to *read* them. :| > testDFL.d(8): Error: no property 'Name' for type 'dfl.form.Form' You were trying to access a 'Name' property for an object of type 'Form'. But 'Form's do not have a 'Name' property. Objects of type 'MyForm' do, but you've explicitly told the compiler that 'd' is of type 'Form' not 'MyForm'. |
December 06, 2009 Re: Getting access to the variables of an imported class | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Keep | Daniel Keep Wrote: > jicman wrote: > > aalm Wrote: > >> import dfl.all; > >> import myform2; > >> > >> void main() > >> { > >> //Form d = new MyForm(); > >> //MyForm d = new MyForm(); > >> auto d = new MyForm(); > >> d.text = "Hello..."; > >> d.Name.text = "name"; > >> d.show(); > >> } > > > > thanks. That worked. Would you care to explain? :-) I know what auto does, but I thought that a Form was a form and a Class was a class. Does auto here would suffice for all other kinds of variables? > > > > Thanks for the help. > > > > jos� > > Sometimes, I think all compiler errors should be replaced with "Something went wrong." No one ever seems to *read* them. :| Or don't know how to read them :/... :-) But, I just learned... Next time I get it. > > testDFL.d(8): Error: no property 'Name' for type 'dfl.form.Form' > > You were trying to access a 'Name' property for an object of type 'Form'. But 'Form's do not have a 'Name' property. Objects of type 'MyForm' do, but you've explicitly told the compiler that 'd' is of type 'Form' not 'MyForm'. Thanks. I got it and I just learned something new today. :-) jic |
Copyright © 1999-2021 by the D Language Foundation