missing parenthesis error in guiserver application ...

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE
Locked
cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

missing parenthesis error in guiserver application ...

Post by cormullion »

I'm pondering this error in a little script of mine that stops the guiserver with this error:

Code: Select all

 newLISP-GS v.1.36 on Mac OS X
 listening on 47011
 accepted connection from 0.0.0.0
 connecting to 0.0.0.0:47012
 retrying to connect
server connected 

ERR: missing parenthesis : "...rea-event \"MAIN:data-input-area\" 53 "
called from user defined function gs:listen
server shutdown
The thing that's puzzling me is that - of course- the gs:listen function isn't in my code but in guiserver.lsp. The code for it is:

Code: Select all

(define (listen flag)
	(while (net-receive in event 1000000000 "\n")
		(eval-string event))
	(println "server shut down")
	(if (not flag) (exit))
)
which I don't really understand...

I can't work out how a missing parenthesis error appears during execution, rather than at the start.

I think the error is coming from this:

Code: Select all

(gs:get-text 'data-input-area)
but it happens infrequently - usually if I type too fast in the text pane.

Clues/debugging tips would be most appreciated... :)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: missing parenthesis error in guiserver application ...

Post by Lutz »

'gs:listen' and also 'gs:check-event', both listen for messages coming from Guiserver. These messages contain newLISP source code which gets evaluated from the newLISP program, which loaded the module guiserver.lsp. In most cases this code contains calls to event handlers, but sometimes it also does assignments.

When you use:

Code: Select all

(gs:get-text 'theTextWidget 'theHandler)
Then the function 'theHandler will be called by 'gs:listen' as a result of an 'eval-string' executed on the message coming back. If you use 'gs:get-text' without the event handler:

Code: Select all

(gs:get-text 'theTextWidget)
then the 'gs:get-text' function will block using 'gs:check-event' until a message is coming back containing an assignment statement, assigning text to the 'gs:text' variable. The following is the code for 'gs:get-text'
in guiserver.lsp. Look at the last statement:

Code: Select all

(define (get-text id action)
    (if action
        (net-send out (string "get-text " id " " action "\n"))
        (begin
            (set 'gs:text nil)
            (net-send out (string "get-text " id "\n"))
            (while (not gs:text) (check-event 10000))
            gs:text)
    )
)
'gs:check-event' contains network listening code similar to 'gs:listen', but 'gs:listen' never returns from its loop, while 'gs:check-event' receives and evaluates only one communication.

If you experience performance problems, perhaps changing you code, to use the event handler form of 'gs:get-text', will improve the situation.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: missing parenthesis error in guiserver application ...

Post by cormullion »

Thanks Lutz - I've changed to using an event handler. It seems to work much more reliably now! :)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: missing parenthesis error in guiserver application ...

Post by Lutz »

I believe the problem you observed was due to an interaction of 'gs:listen' and 'gs:check-event', because both used the same global 'event' variable. This is fixed in version 10.2.16. Your pervious code, which caused the problem, should now work.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: missing parenthesis error in guiserver application ...

Post by cormullion »

Cool. Thanks Lutz!

Locked