digitalmars.D.learn - Getting access to the variables of an imported class
- jicman (70/70) Dec 05 2009 Greetings!
- aalm (11/29) Dec 05 2009 I dont have DFL installed, but try this:
- aalm (14/28) Dec 05 2009 I dont have DFL installed, but try this:
- jicman (4/35) Dec 05 2009 thanks. That worked. Would you care to explain? :-) I know what auto ...
- Daniel Keep (7/27) Dec 05 2009 Sometimes, I think all compiler errors should be replaced with
- jicman (4/33) Dec 06 2009 Thanks. I got it and I just learned something new today. :-)
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é
Dec 05 2009
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 intI 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(); }
Dec 05 2009
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(); }
Dec 05 2009
aalm Wrote:jicman Wrote: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é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(); }
Dec 05 2009
jicman wrote:aalm Wrote:Sometimes, I think all compiler errors should be replaced with "Something went wrong." No one ever seems to *read* them. :|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�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'.
Dec 05 2009
Daniel Keep Wrote:jicman wrote:Or don't know how to read them :/... :-) But, I just learned... Next time I get it.aalm Wrote:Sometimes, I think all compiler errors should be replaced with "Something went wrong." No one ever seems to *read* them. :|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�Thanks. I got it and I just learned something new today. :-) jictestDFL.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'.
Dec 06 2009