get-text

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

get-text

Post by cormullion »

Is there an easier way to get the text of a field without using a callback function? While I'm processing the contents of one field I need to get the contents of another, and I'm calling the handlers too often:

Code: Select all

(gs:init) 
(gs:frame 'Regex 200 200 400 300 "Regex")
(gs:panel 'MainPanel)
(gs:set-grid-layout 'MainPanel 3 2)

(gs:text-field 'string-input 'textfield-handler  1)
(gs:text-field 'regex-input 'textfield-handler  1)
(gs:text-field 'output 'gs:no-action 1)

(gs:add-to 'MainPanel 'string-input 'regex-input 'output )
(gs:add-to 'Regex 'MainPanel)
(gs:set-visible 'Regex true)

(define (textfield-handler id text)
	(gs:get-text id 'gettextcallback-handler))

(define (gettextcallback-handler id text) 
  (set 'results '())
  (cond
    ((= text nil)
        (gs:no-action))
    ((= id "MAIN:regex-input")
        (set 'rgx (base64-dec text)))
    ((= id "MAIN:string-input")
        (set 'strng (base64-dec text)))
  )
  (catch 
    (replace rgx strng 
        (push (string {$1 } ($ 1)) results -1)
      opt) 'error)
  (gs:set-text 'output (string results)))

(set 'opt 0 'strng " " 'rgx " ")  

(gs:listen)
What I wanted to do was to update the replace strings whenever one of the fields changed...

Post Reply