OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: ScottBolton on December 04, 2015, 01:42:51 PM

Title: CurrentSelection
Post by: ScottBolton on December 04, 2015, 01:42:51 PM
Can't get CurrentSelection, or CurSel, to work:

Code (autolisp) Select
(dcl_Project_Load "D:/opendcl/frames" T)
(dcl-Control-SetCaption frames/Form1/Proceed "ggg")
(dcl-Control-SetCurrentSelection frames/Form1/MAIN-OptionList1 2)
(dcl-Control-GetCurrentSelection frames/Form1/MAIN-OptionList1)
(dcl-Control-SetWidth frames/Form1 330)
(dcl_Form_Show frames/Form1)


Lines 1, 5 and 6 work fine, but 2-4 don't. Am I missing something? The OptionList has the DblClicked and SelChanged events checked.
Title: Re: CurrentSelection
Post by: Fred Tomke on December 04, 2015, 01:47:24 PM
Hi, I'm irritated: did you really write these lines in one go? Then it won't work.
Please have a look at the concept of events. It's not like native DCL!

You will find an example here (http://www.opendcl.com/forum/index.php?topic=1080.0).

Regards, Fred
Title: Re: CurrentSelection
Post by: ScottBolton on December 04, 2015, 01:59:46 PM
Fred, thanks for the speedy, if irritated, reply.

I'm not sure where I'm to look in your example. I have separate c: functions for all the events (#OnClicked, #OnSelChanged, #OnDblClicked) but I thought that I would set form data between the (dcl_Project_Load and (dcl_Form_Show - as lines 1,5,6 work fine. How can I set the second item of an OptionList to be current? (The CurrentSelection is not always going to be 2, it will be variable.)

S
Title: Re: CurrentSelection
Post by: ScottBolton on December 04, 2015, 02:13:22 PM
Ok, so everything between Load and Show should be in an OnInitialize, with the Event checked for the Form.

Code (autolisp) Select
(defun c:frames/Form1#OnInitialize (/)
(dcl-Control-SetCurrentSelection frames/Form1/MAIN-OptionList1 (atoi *FRAMES_sizeA*))
(dcl-Control-SetCurrentSelection frames/Form1/MAIN-OptionList2 (atoi *FRAMES_sheetlength*))
(dcl-Control-SetCurrentSelection frames/Form1/MAIN-OptionList3 (atoi *FRAMES_viewport*))
(dcl-Control-SetCurrentSelection frames/Form1/MAIN-OptionList4 (atoi *FRAMES_titleblock*))
(dcl-Control-SetWidth frames/Form1 330)
)

(dcl_Project_Load "D:/opendcl/frames" T)
(dcl_Form_Show frames/Form1)


A slow learning curve for me.

Thanks for the (vague) pointer.

S
Title: Re: CurrentSelection
Post by: Fred Tomke on December 04, 2015, 03:21:02 PM
Hi, I recommend you to start with the tutorial and the sample files coming with OpenDCL installation.
Regards, Fred