Command versus Function definition for routines

Started by JBerns, June 05, 2019, 07:32:43 AM

Previous topic - Next topic

JBerns

Community,

I am a new user to OpenDCL, but a 30-year developer of AutoLISP code.

I noticed that when creating events for forms, boxes, buttons etc., the routines are defined as Command functions. For example:
(defun c:Sample_01/Form1#OnInitialize (/) ...
(defun c:Sample_01/Form1/Label1#OnClicked (/) ...
(defun c:Sample_01/Form1/TextButton1#OnClicked (/) ...


Is it necessary to define these routines as Command (C:) functions? Users who prefer to type commands will see a lot of extra commands, which may be confusing.
See attached image.

I would have expected supporting routines to be defined as functions. In other words, without the "C:". This would be less confusing for typed commands.

I would welcome an explanation as to why all the routines are defined as Commands instead of mostly as Functions.


Kind regards,

Jerry


JBerns

Localizing the supporting functions (OnClick, OnReturnPressed, etc.) inside the main function worked great!

I have used this nesting method before for functions, but never command functions. I should have thought of that solution myself.  ::)

Thanks for the assistance.


Regards,
Jerry

roy_043

Your experience then differs from dan113's in the linked topic. Are the functions still 'hidden' in AutoCAD after calling the parent function?