[Gambas-user] Joystick interface class

Benoit Minisini gambas at ...1...
Mon Mar 7 15:48:19 CET 2005


On Monday 07 March 2005 15:41, Jean-Francois Perreault wrote:
> hey that worked !!!
> why ?
>
> I even tried exactly
> cJoystick1 = NEW CJoystick(FMain,"/dev/js0") AS cJoystick1
> earlier
>
> why the double quotes ?
>
> ... oh wait , now I remember that when I tried
> cJoystick1 = NEW CJoystick(FMain,"/dev/js0") AS cJoystick1
> the reason that didn't work was because it said
>
> Type mismatch: wanted string, got Cjoystick instead
> in fact that was just
> cJoystick1 = NEW CJoystick("/dev/js0") AS cJoystick1
> because that was before I tried passing the parent class
> so I tought it meant it wanted as string for the constructor
> sDevice parameter and that this gave that error because something
> else was wrong
>
> (I'm too used to having to reinterpret misleading error
> message but congratulations that error message was dead on :) )
>
>
> but still I don't get it , why does it want a string of the name of the
> class instance ?
>

Maybe the documentation is not clear ? What comes after 'AS' in an 
instanciation is the *event name* of the new object. You should use a string, 
but if you put a variable, then the contents of the variable will be used as 
event name. You were unlucky, as you used a object variable whose value is 
NULL, and so was translated into a void string.

Maybe I should force the use of a string constant after the AS...

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list