missing parenthesis error in guiserver application ...

Started by cormullion, September 26, 2010, 09:41:53 AM

Previous topic - Next topic

cormullion

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


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:


(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:


(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

'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:


(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:


(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:


(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

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

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

Cool. Thanks Lutz!