[Gambas-user] Events in Gambas non-graphic project

Benoit Minisini gambas at ...1...
Sat Apr 24 00:30:29 CEST 2004


On Saturday 24 April 2004 00:20, Trorrr [Héctor Fernández] wrote:
> Hello, i'm writing a console version of a server for a
> messaging protocol that is already written on Gambas
> with a graphical Form.  I need to program the console
> version to make a non-X system server.
> I create a new project and then i unmark gb.qt.  The
> init procedure is then STATIC PUBLIC SUB Main().  I
> mark gb.net component to allow networking but if i
> compile this simple code:
>
> PRIVATE Server AS ServerSocket
> PRIVATE Client AS Object[]
>
> STATIC PUBLIC SUB Main()
>   DIM cadena AS String
>
>   Client=NEW Object[]
>   Server=NEW ServerSocket AS "Server"
>   Server.Type=Net.Internet
> END
>
> it shows the message "Dynamic symbols cannot be used
> in static function" in the Client=NEW Object[] line
> when i compile.  Isn't possible to use events in
> command-line projects?  Thanks.
>

Because this code is a class implementation, isn't it ? 

As Main() is static, it can't access Server and Client. They were declared 
dynamic, i.e. they are class variables. Just add the static keyword to their 
declaration.

Another point: If you instanciate an object in a static function, then all 
event handlers must be static too.

Regards,

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




More information about the User mailing list