Page 1 of 1


Posted: Fri Aug 24, 2007 7:40 am
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: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 '())
    ((= text nil)
    ((= id "MAIN:regex-input")
        (set 'rgx (base64-dec text)))
    ((= id "MAIN:string-input")
        (set 'strng (base64-dec text)))
    (replace rgx strng 
        (push (string {$1 } ($ 1)) results -1)
      opt) 'error)
  (gs:set-text 'output (string results)))

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

What I wanted to do was to update the replace strings whenever one of the fields changed...