ReturnAsTab

Started by aslani · 2009-03-02 18:07 UTC · 11 replies · SMF topic #614

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.
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.
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.
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.

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
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.
author=Fred Tomke link=topic=614.msg2795#msg2795 date=1236104542 wrote:
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.
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
Can you attach your .odcl file so we can have a look?
author=Fred Tomke link=topic=614.msg2800#msg2800 date=1236110723 wrote:
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.

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


Sure.
Attachments
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)
)
author=owenwengerd link=topic=614.msg2851#msg2851 date=1236221277 wrote:
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. :)