[plt-scheme] GUI

From: Avi (n4alpaca at gmail.com)
Date: Tue Jan 5 19:28:22 EST 2010

I have a program which (perhaps I should add that I began scheme 2
months ago) gives me the following error:

reference to an identifier before its definition: choose-prog <----
This is a definition

I know how to fix this error, but when I move my GUI file above this
definition, it will give me another error that tells me  that I can
not use a program before I define it. A runs B, but B takes data from
A so B must come after A, but A also must go after B because of the
manner in which the scheme compiler works. Please help me resolve. If
I did not do a good enough job explaining, try it for yourself with
this code (this is the code i'm having trouble with).


(define a-text-choices
     (make-message "Please pick what you want to do."))
(define options
  (list "Compound""Moles(experimental)"))
(define choices
  (make-choice options)
(define b-text-field
     (make-text "Please input number of elements"))



(define choose-prog
  (cond
    [(symbol=? 2 (text-contents b-text-field)) Molecule2]
    [(symbol=? 3 (text-contents b-text-field)) Molecule3]
    [(symbol=? 4 (text-contents b-text-field)) Molecule4]))

(define Element-Window
   (create-window
        (list (list b-text-field)(list (make-button "Go" choose-prog
(lambda(e)(hide-window Element-Window)))))))

(define choose
  (cond
    [(symbol=? 0 (choice-index choices))Element-Window]))

(create-window
        (list(list a-text-choices)(list choices)(make-button "OK"
choose)))



Posted on the users mailing list.