Author Topic: Command versus Function definition for routines  (Read 158 times)

JBerns

  • Member
  • *
  • Posts: 3
Command versus Function definition for routines
« on: June 05, 2019, 07:32:43 AM »
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:
Code: [Select]
(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

roy_043

  • Sr. Member
  • ****
  • Posts: 361

JBerns

  • Member
  • *
  • Posts: 3
Re: Command versus Function definition for routines
« Reply #2 on: June 13, 2019, 06:31:47 AM »
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

  • Sr. Member
  • ****
  • Posts: 361
Re: Command versus Function definition for routines
« Reply #3 on: June 13, 2019, 06:46:29 AM »
Your experience then differs from dan113's in the linked topic. Are the functions still 'hidden' in AutoCAD after calling the parent function?