combo box and text box

Started by csgoh, April 24, 2009, 07:29:30 AM

Previous topic - Next topic

csgoh

Combo box not populated and pre set to selected item
text box not displaying any default text.
Code (autolisp) Select

(defun c:w1 (/
               c:W1_cmdW1_Cancel_OnClicked
               c:W1_cmdW1_OnInitialize
               c:W1_cmdW1_OK_OnClicked
               c:W1_cmdW1_SKALA_OnEditChanged
               c:W1_cmdW1_cbLayer_OnSelChanged
              )
;---------------------start subroutines------------------------------

(defun c:W1_cmdW1_OnInitialize ( /)
; the last skala default
    (dcl_Control_SetText W1_cmdW1_SKALA
       (itoa (cdr (assoc "SKALA" wg:constant-list))))
;populate the combo box
    (dcl_ComboBox_AddList W1_cmdW1_cbLayer AllLayers-List)
; set the last default layer
    (dcl_ComboBox_SetCurSel W1_cmdW1_cbLayer
     (vl-position  (cdr (assoc "BRGDIST-LAYER" wg:constant-list))
                    AllLayers-List)
    )
; the last textht default
    (dcl_Control_SetText W1_cmdW1_tbTextHeight
       (itoa (cdr (assoc "TEXTHT" wg:constant-list))))
)

(defun c:W1_cmdW1_SKALA_OnEditChanged (sText /)
(princ)
)

(defun c:W1_cmdW1_OK_OnClicked ( /)
;; update wg:constant-list
  (COND
   ((<= (atoi (dcl_control_gettext W1_cmdW1_skala)) 0)
    (dcl_MessageBox "SCALE > 0")    
   );SCALE < 0

   ((< (atoi (dcl_control_gettext W1_cmdW1_tbTextHeight)) 1)
    (dcl_MessageBox "TEXTHT >= 1")    
   );TEXTHT < 1

   (T
    (setq wg:constant-list
       (subst (cons "SKALA" (ATOI (dcl_control_gettext W1_cmdW1_skala)))
              (assoc "SKALA" wg:constant-list)
              wg:constant-list
       )
    )
    (setq wg:constant-list
      (subst (cons "TEXTHT" (ATOI (dcl_control_gettext W1_cmdW1_tbTextHeight)))
             (assoc "TEXTHT" wg:constant-list)
             wg:constant-list
       )
    )
;     (setq wg:constant-list
;        (subst (cons "BRGDIST-LAYER" (dcl_control_gettext W1_cmdW1_cbLayer))
;               (assoc "BRGDIST-LAYER" wg:constant-list)
;               wg:constant-list
;        )
;     )
;     (setq currentlayer (dcl_control_gettext W1_cmdW1_cbLayer))
    (dcl_Form_Close W1_cmdW1)
   );t
  );COND
)

(defun c:W1_cmdW1_Cancel_OnClicked ( /)
    (dcl_Form_Close W1_cmdW1)
)
(defun c:W1_cmdW1_cbLayer_OnSelChanged (nSelection sSelText /)
    (setq wg:constant-list
       (subst (cons "BRGDIST-LAYER" sSelText)
              (assoc "BRGDIST-LAYER" wg:constant-list)
              wg:constant-list
       )
    )
)

(defun c:W1_cmdW1_tbTextHeight_OnEditChanged (sText /)
(princ)
)

;---------------------end subroutines------------------------------
 (vl-load-com)
; all the layers
 (setq AllLayers-List (WG:GetAllLayers GB:ActivedocumentObj
                        '(("WG-BGDIST" 3 "CONTINUOUS")
                          ("WG-LOTARE" 4 "CONTINUOUS")
                          ("WG-GRIDTXT" 6 "CONTINUOUS")
                          ("WG-TRAVLN" 11 "CONTINUOUS")
                          ("WG-TABLE" 7 "CONTINUOUS")
                          ("WG-TABNO" 7 "CONTINUOUS")
                          ("WG-BDLABEL" 3 "CONTINUOUS")
                         )
                      )
 )

; all textstyles
 (setq AllTextStyles-List (WG:GetAllTextStyles GB:ActivedocumentObj))

 (or LoadRunTime (load "_OpenDclUtils.lsp") (exit))
 (LoadRunTime)
 (dcl_project_load "W1.odcl" T)
 (dcl_FORM_SHOW W1_cmdW1)
;; The Event handlers manage the form here.  
 (PRINC)
(PRINT "WG:CONSTANT-LIST ")(PRINT WG:CONSTANT-LIST)
)


Where have i gone wrong?
Help is much appreciated.

csgoh


csgoh

found the problem. the initialize button was not checked.