Infinit loop

Simen Kjaeraas simen.kjaras at gmail.com
Sun May 11 05:05:15 PDT 2008


On Sun, 11 May 2008 06:46:13 +0200, wongtd <wongtd at smm.com> wrote:

> see this here
>
> module Box; import dwt.DWT; import dwt.widgets.Composite; import  
> dwt.widgets.Control; import dwt.widgets.Text; import dwt.widgets.Shell;  
> import dwt.widgets.Display; import tango.io.Stdout; class Box {      
> private Control[char[]] controls; // Use associative array     this  
> (Composite parent ,int style ) {     auto box = new  
> Composite(parent,DWT.SINGLE);     box.setSize(700,40);     auto No = new  
> Text(box,DWT.LEFT);     No.setBounds(1,15,10,15);      
> No.setText("");            auto Date = new Text(box,DWT.LEFT);      
> Date.setBounds( 21, 15, 60, 15);     Date.setText("");            auto  
> Content   = new Text(box,DWT.LEFT);     Content.setBounds( 90, 15,70,  
> 15);     Content.setText("");     box.setVisible = true;      
> controls["No"] = No;     controls["Date"] = Date;      
> controls["Content"] = Content;           
> box.setTabList(controls.values);   }   void setText(char[] name, char[]  
> text)   {       controls[name].setText(text);    } } void main () {    
> Display display = new Display ();   Shell shell = new Shell (display);    
> shell.setText("Boxes");      Box mybox1 = new Box(shell,DWT.SINGLE);    
> mybox1.setText("No","wire");   Box mybox2 = new Box(shell,DWT.SINGLE);    
> mybox2.setText("Content","Fishingline");   shell.pack();    
> shell.open();           while (!shell.isDisposed ()) {     if  
> (!display.readAndDispatch ()) display.sleep ();   }   display.dispose  
> (); }  
> /*----------------------------------------------------------------------------  
> Box.d(44): Error: no property 'setText' for type  
> 'dwt.widgets.Control.Control' Box.d(44): Error: function expected before  
> (), not 1 of type int */
>
> I play with and put in
>
> }
>
>   void setText(char[] text)
> {
>   setText(text);//dont understand why this does not cause infinite loop?
> }
>
>   void setText(char[] name, char[]text)
>   {
> //   name.setText(text);
>   }
> }
>
> with layout in shell above compiles and runs giving 9 text boxes with  
> right text.
>
> Question   When setText(name,text ) is called Why does setText(text) not  
> cause infinit loop?
> It calls itself seems so
> I tried to put in 'override' but would not compile


*wall of text crits for real.inf*

Someone might be more positive to helping you if the code were somewhat  
formatted. I'd recommend adding the occasional line break.

-- Simen


More information about the Digitalmars-d-learn mailing list