get-text
Posted: Fri Aug 24, 2007 7:40 am
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:
What I wanted to do was to update the replace strings whenever one of the fields changed...
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)