Form Naming Standards

Started by bsande1, February 13, 2009, 08:40:23 AM

Previous topic - Next topic

bsande1

I am new both to ODCL and LISP. My manager has asked me to replace aging VB code (written by a former employee) for our customization of AutoCAD 2008.

I saw ODCL Studio and think this would be perfect to meet my needs. I installed version 5.0.1.6, and started learning, however, I can't get past the HelloWorld tutorial.

If I follow exactly what is written in the tutorial, it works fine, but if I change it to follow the naming conventions used in our VB code (prefixes; frm for forms, txt for text boxes, lbl for labels and cmd for buttons), it doesn't run. I get OpenDCL Runtime Errors, Error: NIL value not allowed for both the SetCaption and GetText functions. If I close everything down, reopen it, I don't get the errors, but it also doesn't run. I get the form, but the Label is back to Label1, and typing in the text box and clicking OK does nothing.

To try and pin down why this is, I used the HelloWorld_Final.LSP from the tutorial files. If all I do is change Form1 to frmHello, it doesn't run. If I change it back, it does.

My question (finally), is there some standards with regards to naming conventions that have to be met for ODCL to run? If so, where do I find them? If not, why does this one change fail?

Thank You,

Will

owenwengerd

The form name is used to construct the lisp symbol names that hold handles to the form and form controls. If you change the form name in the project, then you also need to change the lisp symbols in the code.

To see what I mean, double click on one of your controls in OpenDCL Studio and click on one of the control's functions; it will display the correct lisp symbol name in the "Syntax" field. Now change the form name, then check the lisp syntax again. You will notice that the lisp symbol name changed.
Owen Wengerd (Outside The Box) / ManuSoft

BazzaCAD

Ya what Owen said.
Also, if you have any events already in your code, you'll have to update them too.
If you change the form name after an event has already been added, just uncheck the even & re-check it again, & it will use the new symbol now.

I think the main thing that is confusing you is you're thinking it works like VBA. In VBA if you click on a control & change it's name in the properties panel the code updates also.
With ODCL this is not the case. You'll have to change the ODCL file & the LSP file to match.
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

bsande1

Thank you both for your comments, however, I am changing the name both in ODCL and in the attached LISP program, and it doesn't run. Allow me to demonstrate.

Here is the original code from the tutorial's HELLOWORLD_FiNAL.lsp:


; the following command will ensure the
; appropriate OpenDCL ARX file is loaded.
(command "_OPENDCL")

(defun c:Hello ()
   ; call the method to load the HelloWorld.odcl file.
   (dcl_Project_Load "HelloWorld" T)
   ; call the method to show the Hello World dialog box example.
   (dcl_Form_Show HelloWorld_Form1)
   (princ)
)

; This fires just before the form is shown.
(defun c:HelloWorld_Form1_OnInitialize (/)
   (dcl_Control_SetCaption HelloWorld_Form1_Label1 "Type Something:") ; Change the labels Caption.
)

; This gets called when the OK button is clicked
(defun c:HelloWorld_Form1_TextButton1_OnClicked (/)
   (setq sText (dcl_Control_GetText HelloWorld_Form1_TextBox1)) ; Get the Text property from the Text Box.
   (dcl_messagebox (strcat "You typed: " sText)) ; Show a MessageBox with the user entered text.
   (dcl_Form_Close HelloWorld_Form1) ; Close the form.
   (princ)
)


If all I do is change the form name from Form1 to frmForm1 in both the ODCL and LISP files:


; the following command will ensure the
; appropriate OpenDCL ARX file is loaded.
(command "_OPENDCL")

(defun c:Hello ()
   ; call the method to load the HelloWorld.odcl file.
   (dcl_Project_Load "HelloWorld" T)
   ; call the method to show the Hello World dialog box example.
   (dcl_Form_Show HelloWorld_frmForm1)
   (princ)
)

; This fires just before the form is shown.
(defun c:HelloWorld_frmForm1_OnInitialize (/)
   (dcl_Control_SetCaption HelloWorld_frmForm1_Label1 "Type Something:") ; Change the labels Caption.
)

; This gets called when the OK button is clicked
(defun c:HelloWorld_frmForm1_TextButton1_OnClicked (/)
   (setq sText (dcl_Control_GetText HelloWorld_frmForm1_TextBox1)) ; Get the Text property from the Text Box.
   (dcl_messagebox (strcat "You typed: " sText)) ; Show a MessageBox with the user entered text.
   (dcl_Form_Close HelloWorld_frmForm1) ; Close the form.
   (princ)
)

It fails to run. I get the error as described, and after restarting ACAD, I get the form problems.


Can you duplicate this error? If not, can you give me some idea of what might be different on my machine?

Thank you,
Will

Fred Tomke

Hi, bsande1, would you be so kind to upload the changed odcl-file? Normally, I call a command from the tools menu of OpenDCL studio to update all the control's names an their variables AND after that I deactivate and activate all the events to make sure that all event's names will be updated, too. And saving the project. And reloading in AutoCAD (!!!!!!!). And then updating the lisp source code. And reloading the lisp code. Only after these steps you can be sure that the new form name will be correctly addressed anywhere!

So send me your project file that we can tell you which part you have to change.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

bsande1

Quote from: Fred Tomke on February 16, 2009, 08:58:43 AM
Hi, bsande1, would you be so kind to upload the changed odcl-file? Normally, I call a command from the tools menu of OpenDCL studio to update all the control's names an their variables AND after that I deactivate and activate all the events to make sure that all event's names will be updated, too. And saving the project. And reloading in AutoCAD (!!!!!!!). And then updating the lisp source code. And reloading the lisp code. Only after these steps you can be sure that the new form name will be correctly addressed anywhere!

So send me your project file that we can tell you which part you have to change.

Fred

Here you go.

Thank you for your help.

Will

owenwengerd

It sounds like you are on the right track, but apparently missing some step along the way. Without seeing your .odcl file it's difficult to say where you went wrong. Did you also change the control names? Your modified code only changed the form name. Did you check the correct syntax displayed in the Control Browser? Those are tools that you can use to diagnose the problem on your own.
Owen Wengerd (Outside The Box) / ManuSoft

owenwengerd

Your files work fine for me. I'll bet that you have multiple versions of the HelloWorld.odcl file, and your call to (dcl_Project_Load) is loading the wrong one.
Owen Wengerd (Outside The Box) / ManuSoft

Fred Tomke

Hello Owen, is it still so that I can load a odcl file using complete path and file name if I want to load a project which is not in one of the support pathes of AutoCAD?

Like:

(dcl_project_load "C:\\Programm Files\\MyApp\\MyApp.odcl")

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

Yes, Fred, the complete path may be specified.
Owen Wengerd (Outside The Box) / ManuSoft

BazzaCAD

bsande1, I opened your attached .ODCL file & your event names are still out of date.
See attached Vid.
Owen how did you get this to work...? :)
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

owenwengerd

I used the code he attached; it looks like you used the original HellowWorld.lsp.
Owen Wengerd (Outside The Box) / ManuSoft