www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Getting access to the variables of an imported class

reply jicman <cabrera_ _wrc.xerox.com> writes:
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
next sibling parent aalm <a a.a> writes:
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(); }
Dec 05 2009
prev sibling parent reply aalm <a a.a> writes:
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
parent reply jicman <cabrera_ _wrc.xerox.com> writes:
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Ú
Dec 05 2009
parent reply Daniel Keep <daniel.keep.lists gmail.com> writes:
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'.
Dec 05 2009
parent jicman <cabrera_ _wrc.xerox.com> writes:
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
Dec 06 2009