Listener output

Barry Denton basse42 at yahoo.com
Sat Apr 19 13:52:43 PDT 2008


Jarrett Billingsley Wrote:

> "Barry Denton" <basse42 at yahoo.com> wrote in message 
> news:fubgb0$22go$1 at digitalmars.com...
> >I have a Listener added to a button as so :-
> >
> > button.addListener(DWT.Selection, new class Listener {
> >        void handleEvent(Event event) {
> >            itemWords [5] = "item has changed " ;//~ 
> > System.currentTimeMillis();
> >            minitable.clear(5);  }  });
> >
> > When pressed the button outputs this:-
> >
> > Event {missing or misplaced '}'}Event {type=13 Button {Change item} 
> > time=1679601378 data={null} x=0 y=0 width=0 height=0 detail=0}
> > .
> > Now all is as it should be except for the  {missing or misplaced '}'}
> 
> Tango's formatting uses a pair of curly braces like "{}".  Your output is 
> supposed to go "{Event {type=13....", but Tango sees the opening '{', tries 
> to parse it as a format specifier, and fails, leaving you with an error 
> message embedded in the output.
> 
> The question I have is: where is this output being generated?  This code 
> doesn't seem to generate it.
> 
> I ask because it's a simple fix: instead of doing something like 
> "Stdout.formatln(x.toString())", just use "Stdout.formatln("{}", x)", that 
> is, escape the string by making it a parameter to be formatted. 
> 
> 
Thanks but this did not work .Did I mess it up?
 button.addListener(DWT.Selection, new class Listener {
        void handleEvent(Event event) {
            itemWords [5] = ("item has changed " ~ clock.stringof~"  "~ cast(char)clock);
            Stdout.formatln("{}""{}" ,event.mangleof, event.stringof).newline;
            Stdout.formatln("{}""{}" ,clock.mangleof, clock.stringof).newline;
            Stdout.print(itemWords).newline;
            minitable.clear(5); 



More information about the Digitalmars-d-learn mailing list