OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: DanielJ on December 05, 2012, 07:01:38 AM

Title: simple getpoint metod
Post by: DanielJ on December 05, 2012, 07:01:38 AM
Hi, can anyone  tell why simple command doesnt work, i mean i cannot normally close form and show it back
routine is simple - on button click
this code closes form, gets point but doesnt show form1 again

(defun c:Programy_Form1_TextButton3_OnClicked (/)
(dcl_Form_Close Programy_Form1)
(setq pkt (getpoint))
(dcl_Form_Show Programy_Form1) 
)
I'm beginner, so dont yell at me
Title: Re: simple getpoint metod
Post by: BazzaCAD on December 05, 2012, 07:27:15 AM
No yelling here:

http://www.opendcl.com/forum/index.php?topic=1080.0
Title: Re: simple getpoint metod
Post by: DanielJ on December 05, 2012, 08:02:38 AM
yes i saw it, but i don't really get it
code in link is in main lisp routine and i want to pick point on event "click button"
Title: Re: simple getpoint metod
Post by: BazzaCAD on December 05, 2012, 10:02:17 AM
See the second post in that link & see the "Selection" example on the advanced tab of the MasterDemo.
Title: Re: simple getpoint metod
Post by: owenwengerd on December 05, 2012, 01:33:23 PM
Quote from: DanielJ on December 05, 2012, 07:01:38 AM
this code closes form, gets point but doesnt show form1 again

The call to (dcl_Form_Close) closes the form itself, but the form's code is still running until the callback function returns. Instead of calling (dcl_Form_Show) for the second dialog from within the callback, you have to call it after the initial (dcl_Form_Show) returns. The samples demonstrate how to do that by returning a dialog result via (dcl_Form_Close) that you can then use in your main function to determine that the second dialog should be shown after the first is closed.
Title: Re: simple getpoint metod
Post by: DanielJ on December 06, 2012, 02:46:44 AM
ok guys,
I apologize, i was so hurry yesterday that i didnt notice that opendcl has samples in main folder

i still have one small problem in code
(command "OPENDCL")
(dcl_Project_Load "Programy" T)
(dcl_Form_Show Programy_Form1)
(defun drukuj () (setq pkt (getpoint))
(setq doContinue T)
)
(defun c:Programy_Form1_TextButton3_OnClicked (/)
        (dcl_form_close Programy_Form1 3)
)
    (setq doContinue T)
    (while doContinue
        (setq doContinue nil)
        (setq intResult (dcl_form_show Programy_Form1))
        (cond
            ((= intResult 1) (setq doContinue nil))
            ((= intResult 2) (setq doContinue nil))
            ((= intResult 3) (drukuj))
        ); cond
    )

code works as I want but after second click on TextButton3, i mean after load lsp and clicking textbutton3 it closes form and opens it again, till next click works fine (after click first ask to pick point and after that opens form again)

what is wrong with that code?
Title: Re: simple getpoint metod
Post by: owenwengerd on December 06, 2012, 10:39:59 AM
You are showing the form before the needed functions are defined. Move the call to (dcl_Form_Show) to a point after the functions are defined, then it should work.
Title: Re: simple getpoint metod
Post by: DanielJ on December 10, 2012, 02:13:58 AM
you're right
works fine now
thanks