Author Topic: weird radio button bug? or my wrong coding?  (Read 1724 times)

0 Members and 1 Guest are viewing this topic.

hanhphuc

  • Newt
  • Posts: 64
weird radio button bug? or my wrong coding?
« on: July 30, 2014, 07:45:03 AM »
dear guys,
i'm helping some one to complete the routine with dialog,
there 4 radio bottons, here are some get_tile results: 0 & 1 to present action_tile
example:
------------
1 0
1 0
debug: (1 0 1 0) , ok

0 1
0 1
debug: (0 1 0 1) , ok

but,
1 0
0 1
becomes (0 1 1 0), should be (1 0 0 1)

0 1
1 0
becomes (1 0 0 1), should be (0 1 1 0)
why?

i use 2 variables: *pos* *key*, 4 button radio1, radio2, radioA, radioB
example: (action_tile "$radio" "(setq *pos* $value)"),
ie: *pos* for radio1 & radio2 , whereas *key* for  radioA, radioB

thanks guys. advise & comments are appreciated :)
Code: [Select]
;the slide can be downloaded here
http://www.cadtutor.net/forum/showthread.php?87818-A-lisp-need-some-modify./page2


  (if (null *fb_user*)
    (setq *fb_user* (mapcar 'itoa '(1 0 1 0)))
    ) ;_ end of if
(defun c:test (/ radio dcl_id path dcl)
  (setq radio '("radio1" "radio2" "radioA" "radioB" )
path  (getenv "temp")
)
 
  ('((f lst /)
     (setq f (open f "w"))
     (mapcar ''(($) (write-line $ f)) lst)
     (close f)
     (setq f nil)
     )
    (setq dcl (strcat path "\\tmp.dcl"))
    '("icon_fbox_img : image {"
      "        color                   = 0;"
      "        width                   = 40;"
      "        aspect_ratio            = 0.75;"
      "        allow_accept            = true;"
      "        fixed_height            = true;"
      "        fixed_width             = true;"
      "}"
      ""
      ""
      "fbox: dialog {"
      "\tlabel=\"Fillet Box settings\";"
      "        key = \"dcl_title\";"
      ""
      ": paragraph{"
      "        : text_part{"
      "\tlabel =\"Choose options \";"
      "\t//alignment = centered;"
      "}"
      "  }      "
      "        :column {"
      "                :row { "
      "                    :column {"
     
      "                      :icon_fbox_img {key = \"SH-CENTRE\";}"
      "                    }"
      "                    :column {             "
     
      "                      :icon_fbox_img {key = \"SH-EDGE\";}"
      "                    }"
      "                 }"
      "}"
      " :column{fixed_width=true;//alignment=centered;"
      " :boxed_radio_row{label=\"Draw method\";"
      "\t:radio_button{label=\"Pick centre                                         \";key=\"radioA\";}//value=\"0\";"
      "        :radio_button{label=\"Pick side                                       \";key=\"radioB\";}//value=\"1\""
      "}"
      "}"
      "           :column {"
      "                 :row { "
      "                    :column {"
     
      "                      :icon_fbox_img {key = \"SH-P2P\";}"
      "                    } "
      "                    :column {"
     
      "                      :icon_fbox_img {key = \"SH-C2C\";}"
      "                    }"
      "                 } "
      "        }"
      "        "
      "        spacer_1;"
      " :column{fixed_width=true;//alignment=centered;"
      " :boxed_radio_row{label=\"Mode\";"
      "           :radio_button{label=\"A:Edge to Edge                                 \";key=\"radio1\";}//value=\"0\""
      "           :radio_button{label=\"B:Radii to radii                               \";key=\"radio2\";}//value=\"1\";"
      "           }"
      "}"
      "        :column{fixed_width=true;alignment=centered;"
      "        : paragraph{"
      "        : text_part{"
      "\tlabel =\"Fillet box : hanhphuc 2014\";"
      "\talignment = centered;"
      "}"
      "  }      "
      "        :row {"
      " \t  spacer_0;"
      "           ok_cancel;"
      "        }"
      "}"
      "}"
      )
    )

  (setq dcl_id (load_dialog dcl))
  (new_dialog "fbox" dcl_id)
  (mapcar ''((a)
     ('((i sld)
(setq x (dimx_tile i))
(setq y (dimy_tile i))
(start_image i)
(fill_image 0 0 x y -2)
(slide_image 0 0 x y sld)
(end_image)
)
      a
      (strcat path "\\" a)
      )
     )
  sld
  ) ;_ end of mapcar
 
(if
   *fb_user*
    (mapcar 'set_tile
    radio
    (setq *fb_user* (apply 'append
   (list
(if (= *pos* "Centre")
   '("1" "0")
   '("0" "1")
   ) ;_ end of if

(if (= *key* "A")
   '("1" "0")
   '("0" "1")
   ) ;_ end of if
) ;_ end of list
   ) ;_ end of apply
  ) ;_ end of setq
    ) ;_ end of mapcar
    ) ;_ end of if
 
 (setq       
       *fb_user*
(mapcar ''((k a b) (action_tile k (strcat "(setq " a " \"" b "\" )")))
radio
'("*pos*" "*pos*" "*key*" "*key*")
'("Centre" "Edge" "A" "B")
) ;_ end of mapcar
       ) ;_ end of setq

 
  (action_tile "accept" "(setq *fb_user* (mapcar 'get_tile radio))
  (alert (strcat
   \"\nmethod: \"*pos* \"\nmode: \" *key* \"\n\"(vl-princ-to-string *fb_user*)))(done_dialog)")

  (start_dialog)
 
  (unload_dialog dcl_id)
  (princ)
  ) ;_ end of defun

;note: no *error* handler & lambda not optimized, just for debug
« Last Edit: July 30, 2014, 09:14:06 AM by hanhphuc »
( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: weird radio button bug? or my wrong coding?
« Reply #1 on: July 30, 2014, 08:50:17 AM »
In your 'radio' variable the order is:
Code: [Select]
(setq radio '("radio1" "radio2" "radioA" "radioB")In your dcl the order is:
"radioA", "radioB",  "radio1" and "radio2".


hanhphuc

  • Newt
  • Posts: 64
Re: weird radio button bug? or my wrong coding?
« Reply #2 on: July 30, 2014, 09:16:36 AM »
In your 'radio' variable the order is:
Code: [Select]
(setq radio '("radio1" "radio2" "radioA" "radioB")In your dcl the order is:
"radioA", "radioB",  "radio1" and "radio2".

Thanks for input, i'll check :-)
( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

hanhphuc

  • Newt
  • Posts: 64
Re: weird radio button bug? or my wrong coding?
« Reply #3 on: July 30, 2014, 09:40:13 AM »
Dear ROY_043 again! :kewl:
i wanna THANK YOU..... very much ! :-) 
i very appreciate you spotted the bug !!!
i thought my code was right, but forgot to check the dialog  :embarrassed:
i'll be carefull next time the with variables

have a nice day ^_^
Thank you!!
( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: weird radio button bug? or my wrong coding?
« Reply #4 on: July 30, 2014, 09:43:09 AM »
You should consider simplifying your code.

What may help is the fact that you can control radio_buttons as a cluster (row/column):

DCL:
Code: [Select]
: boxed_radio_row {
  key = "drawMethod";
  label = "Draw method";
  : radio_button {
    key = "Centre";
    label = "Pick centre";
  }
  : radio_button {
    key = "Edge";
    label = "Pick side";
  }
}

LSP:
Code: [Select]
(set_tile "drawMethod" "Edge")Will select the correct radio_button.
Code: [Select]
(get_tile "drawMethod")Will return "Centre", "Edge" or nil (if the radio_buttons all have the value "0").

hanhphuc

  • Newt
  • Posts: 64
Re: weird radio button bug? or my wrong coding?
« Reply #5 on: July 30, 2014, 10:09:22 AM »
You should consider simplifying your code.

What may help is the fact that you can control radio_buttons as a cluster (row/column):

DCL:
Code: [Select]
: boxed_radio_row {
  key = "drawMethod";
  label = "Draw method";
  : radio_button {
    key = "Centre";
    label = "Pick centre";
  }
  : radio_button {
    key = "Edge";
    label = "Pick side";
  }
}

LSP:
Code: [Select]
(set_tile "drawMethod" "Edge")Will select the correct radio_button.
Code: [Select]
(get_tile "drawMethod")Will return "Centre", "Edge" or nil (if the radio_buttons all have the value "0").

Thanks Roy for the great great tips! 
i got fish today!! :)
( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments