missing parenthesis error in guiserver application ...

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE

missing parenthesis error in guiserver application ...

Postby cormullion » Sun Sep 26, 2010 4:41 pm

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... :)
cormullion
 
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W

Re: missing parenthesis error in guiserver application ...

Postby Lutz » Mon Sep 27, 2010 11:57 am

'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.
Lutz
 
Posts: 5258
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: missing parenthesis error in guiserver application ...

Postby cormullion » Mon Sep 27, 2010 5:06 pm

Thanks Lutz - I've changed to using an event handler. It seems to work much more reliably now! :)
cormullion
 
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W

Re: missing parenthesis error in guiserver application ...

Postby Lutz » Fri Oct 01, 2010 1:37 pm

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.
Lutz
 
Posts: 5258
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: missing parenthesis error in guiserver application ...

Postby cormullion » Fri Oct 01, 2010 6:40 pm

Cool. Thanks Lutz!
cormullion
 
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W


Return to newLISP Graphics & Sound

Who is online

Users browsing this forum: No registered users and 1 guest

cron