OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: aslani on March 02, 2009, 10:07:32 AM

Title: ReturnAsTab
Post by: aslani on March 02, 2009, 10:07:32 AM
Hi,

I have searched for this in this forum and took the advice but it seems that I'm missing something because the following line gives me the error.

(dcl_Control_SetReturnAsTab varDwgNo T)

=======================================================
OpenDCL Runtime Error
An OpenDCL function argument processing exception has occured!

Error: NIL value not allowed
Function: dcl_Control_SetReturnAsTab
Argument: 0
=======================================================

Anybody know what seems to be the problem?

Without the command, my dialog box works great but I'm trying to prevent the Enter Key from closing the dialog box.

I'm using OpenDCL Studio 5.0.1.6

Thanks in advance.
Title: Re: ReturnAsTab
Post by: aslani on March 02, 2009, 10:31:10 AM
I'm sorry I have found my fault. ReturnAsTab is in properties, and not a method.

The helpfile gives that impression that I can set it in Lisp, but only to get the errors I've shown.
Title: Re: ReturnAsTab
Post by: owenwengerd on March 02, 2009, 11:00:40 AM
That error means varDwgNo is NIL when you make the call. You're probably calling that function either before the dialog is created, or after is has closed.
Title: Re: ReturnAsTab
Post by: aslani on March 03, 2009, 09:00:37 AM
I did noticed that the position of code is important, which makes sense because you can't really manipulate something that doesn't exist yet. But I have placed that line of code after loading the .odcl and showing the form as follows;

  ; Load oDCL Project
  (dcl_Project_Load "AAEoDCL.odcl" T)
  ; Display oDCL Form
  (dcl_Form_Show oDCL_frmAAE)
  ; force tab
  (dcl_Control_SetReturnAsTab varDwgNo T)

But you're right, I do get the error after I close the form and yes, it didn't force Return to Tab.

Any advice on what I did wrong?

Thanks.

Title: Re: ReturnAsTab
Post by: Fred Tomke on March 03, 2009, 10:22:22 AM
Hello

that will only work in modeless forms. In modal forms your code stops at (dcl_form_show ...) (until the form closes).
If you want to setup a control during runtime do it while OnInitializing



(defun c:myprogram ()

(defun c:proj_form_OnInitialize ()
  (dcl_Control_SetReturnAsTab varDwgNo T)
);  c:proj_form_OnInitialize

(dcl_form_show proj_form)

); myprogram



Fred
Title: Re: ReturnAsTab
Post by: owenwengerd on March 03, 2009, 10:37:49 AM
As Fred says, you should put your code in an OnInitialize event handler. (dcl_Form_Show) does not return until you close your modal dialog; therefore the code that follows does not execute until the dialog is closed.
Title: Re: ReturnAsTab
Post by: aslani on March 03, 2009, 11:48:03 AM
Quote from: Fred Tomke on March 03, 2009, 10:22:22 AM
Hello

that will only work in modeless forms. In modal forms your code stops at (dcl_form_show ...) (until the form closes).
If you want to setup a control during runtime do it while OnInitializing



(defun c:myprogram ()

(defun c:proj_form_OnInitialize ()
  (dcl_Control_SetReturnAsTab varDwgNo T)
);  c:proj_form_OnInitialize

(dcl_form_show proj_form)

); myprogram



Fred

I did that, same error.  :-[

Not sure why, but it only works when I enabled ReturnAsTab using the OpenDCL Studio.
Title: Re: ReturnAsTab
Post by: Fred Tomke on March 03, 2009, 12:05:23 PM
Please tell us what AutoCAD is given to you in the alert when you use this code

(defun c:myprogram ()
  (vl-load-com)

  (defun c:proj_form_OnInitialize ()
    (dcl_Control_SetReturnAsTab varDwgNo T)
    (dcl_message_box (strcat "Value of varDwgNo: " (vl-prin1-to-string varDwgNo)) "Control" 2 4)
  );  c:proj_form_OnInitialize

  (dcl_form_show proj_form)

); myprogram


Fred
Title: Re: ReturnAsTab
Post by: owenwengerd on March 03, 2009, 12:36:48 PM
Can you attach your .odcl file so we can have a look?
Title: Re: ReturnAsTab
Post by: aslani on March 04, 2009, 06:04:05 PM
Quote from: Fred Tomke on March 03, 2009, 12:05:23 PM
Please tell us what AutoCAD is given to you in the alert when you use this code

(defun c:myprogram ()
  (vl-load-com)

  (defun c:proj_form_OnInitialize ()
    (dcl_Control_SetReturnAsTab varDwgNo T)
    (dcl_message_box (strcat "Value of varDwgNo: " (vl-prin1-to-string varDwgNo)) "Control" 2 4)
  );  c:proj_form_OnInitialize

  (dcl_form_show proj_form)

); myprogram


Fred

dcl_message_box gives me an error, so I changed that to dcl_MessageBox to see the value of varDwgNo, which is NIL.

QuoteCan you attach your .odcl file so we can have a look?

Sure.
Title: Re: ReturnAsTab
Post by: owenwengerd on March 04, 2009, 06:47:57 PM
In your .odcl file there is no control using the VarName varDwgNo. Did you mean diaDwgNo instead? Also, the event handler for the dialog's OnInitialize event is named c:oDCL_frmAAE_OnInitialize. The following code works for me witht he .odcl file that you attached:
(defun c:test ()
  (defun c:oDCL_frmAAE_OnInitialize ()
    (dcl_Control_SetReturnAsTab diaDwgNo T)
  )
  (dcl_form_show oDCL_frmAAE)
)
Title: Re: ReturnAsTab
Post by: aslani on March 05, 2009, 09:54:46 AM
Quote from: owenwengerd on March 04, 2009, 06:47:57 PM
In your .odcl file there is no control using the VarName varDwgNo. Did you mean diaDwgNo instead? Also, the event handler for the dialog's OnInitialize event is named c:oDCL_frmAAE_OnInitialize. The following code works for me witht he .odcl file that you attached:
(defun c:test ()
  (defun c:oDCL_frmAAE_OnInitialize ()
    (dcl_Control_SetReturnAsTab diaDwgNo T)
  )
  (dcl_form_show oDCL_frmAAE)
)


Ah! that's it!

I was calling the variable name I use in my Lisp to store the value instead of the control's variable name. >.<'

Thank you, that works. :)