Author Topic: Option List Problem  (Read 3407 times)

Iulian

  • Member
  • *
  • Posts: 43
Option List Problem
« on: October 17, 2009, 08:14:23 AM »
Hi. I have a problem with the Option List tool. Like in the picture below (attached), when I click the first Option List button, I want to appear in the picture box below, "Picture 1". When I click the second Option List button, I want to appear "Picture 2" in the picture box below, and so on with the last Option List button. For this I used the procedure dcl_OptionList_GetCurSel for obtaining the current value of OptionButton1, and than, with IF function I made the connection between the current value and the corespondent picture. With TextButton1 I would like to see in a messagebox this value, assigned to OptList1CSel  . What I can do?
Thanks.

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 3101
    • Outside The Box
Re: Option List Problem
« Reply #1 on: October 17, 2009, 08:50:21 AM »
If you want to use the value of OptList1CSel in another function, then you need to make it a global variable by removing it from the local variable list of your c:aaa function. The GetCurSel method returns -1 if no options are selected, or the zero based index of the currently selected item, so your use of it is correct.

BazzaCAD

  • OpenDCL Webmaster
  • Administrator
  • Hero Member
  • *****
  • Posts: 855
  • Cylons will kill you
    • OpenDCL
Re: Option List Problem
« Reply #2 on: October 17, 2009, 09:17:50 AM »
Hi Iulian,
Good start, but you have a few issue.
1. Like Owen said use a global variable (but you wont need it per below).
2. Your C:aaa function will never get called. C:zzz will show the form & it will take focus, you'd have to run the aaa command at the command line, but can't because you have a modal dialog.
3. Be sure to use the "Evants" tab next to the "Properties" Tab

Here's an alternative solution for you:

Code: (autolisp) [Select]
(command "opendcl")
(defun C:zzz ()
  (dcl_project_load "example")
  (dcl_form_show example_form1)
  (princ)
)

(defun c:example_Form1_OptionList1_OnSelChanged (ItemIndexOrCount Value /)
   (cond
     ((= ItemIndexOrCount 0)
       (dcl_Control_SetPicture example_Form1_PictureBox1 100)
     )
     ((= ItemIndexOrCount 1)
       (dcl_Control_SetPicture example_Form1_PictureBox1 101)
     )
     ((= ItemIndexOrCount 2)
       (dcl_Control_SetPicture example_Form1_PictureBox1 102)
     )
   )
  (princ)
)

(defun c:example_Form1_GraphicButton1_OnClicked ( / OptList1CSel )
  (setq OptList1CSel (dcl_OptionList_GetCurSel example_Form1_OptionList1))
  (dcl_MessageBox (strcat "OptList1CSel value: " (itoa OptList1CSel)))
  (princ)
)


Hope this helps,
Barry
« Last Edit: October 17, 2009, 09:20:47 AM by BazzaCAD »
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Iulian

  • Member
  • *
  • Posts: 43
Re: Option List Problem
« Reply #3 on: October 18, 2009, 10:20:03 AM »
Thank you very much for the code below and your information. Now it works.