Advertisement
Guest User

Premature call to a function

a guest
Aug 8th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;;;;;;;;; ... namespace stuff goes here
  2.  
  3. (def f (frame :title "Character Creator - The Feather System" :on-close :exit :size [1100 :by 500]))
  4. (defn display [content]
  5.      (config! f :content content)
  6.   content)
  7. (defn acquire [kw] (select (to-root f) kw))
  8.  
  9. ;;;;;;;;;  AFTER MANY DECLARATIONS...
  10.  
  11. (defn armor-res-util [armor-num]
  12.   (println (str "sample keyword: " (keyword (str "#armor-" armor-num "-res-0-kind")) "      sample acquire vector: " [(keyword (str "#armor-" armor-num "-res-0-kind"))]))
  13.   (str "Total Resistance Value: "
  14.        (+ (* (values-of-types (selection (acquire [(keyword (str "#armor-" armor-num "-res-0-kind"))]))) (selection (acquire [(keyword (str "#armor-" armor-num "-res-0-amount"))])))
  15.           (* (values-of-types (selection (acquire [(keyword (str "#armor-" armor-num "-res-1-kind"))]))) (selection (acquire [(keyword (str "#armor-" armor-num "-res-1-amount"))])))
  16.           (* (values-of-types (selection (acquire [(keyword (str "#armor-" armor-num "-res-2-kind"))]))) (selection (acquire [(keyword (str "#armor-" armor-num "-res-2-amount"))])))
  17. )))
  18.  
  19. ;;;;MUCH LATER...
  20.  
  21. (defn make-window []
  22. ;;;;;;;;;;;;;;;;;;;;;;;;   ...LOTS OF GUI STUFF GOES HERE
  23.  
  24. (combobox :id :armor-0-res-0-kind :visible? false :model valid-types
  25.           :listen [:selection (fn [ev] (swap! current-char assoc-in [:armor 0 :resistances 0 :amount-kind] (selection ev))
  26.                                 (config! (acquire [:#total-res-value]) :text (armor-res-util 0)))
  27.            ])
  28. (slider :id :armor-0-res-0-amount :visible? false :value 0 :min -3 :max 3
  29.           :listen [:selection (fn [ev] (swap! current-char assoc-in [:armor 0 :resistances 0 :amount] (selection ev))
  30.                                     (config! (acquire [:#armor-0-res-0-count]) :text (str " " (selection ev)))
  31.                                     (config! (acquire [:#total-res-value]) :text (armor-res-util 0)))
  32.            ])
  33. (label :id :armor-0-res-0-count :text " 0")
  34.            
  35. ;;;;;;;;;;;;;;;;;;;;;;;;   ...TWO MORE JUST LIKE WHAT IS ABOVE THIS, THEN WRAPPING UP GUI STUFF
  36.  
  37. (defn -main [& args]
  38.   (invoke-later
  39.     (display (make-window))
  40.     (-> f show!)))
  41.  
  42. ;; The problem seems to be that the function armor-res-util gets executed before all of the id's it needs
  43. ;; get declared.  It shouldn't be executing at all until one of the slider's or combobox's selection events gets called!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement