Author Topic: Suppressing event handlers from command history  (Read 335 times)

Moshe-A

  • Member
  • *
  • Posts: 14
Suppressing event handlers from command history
« on: September 29, 2020, 03:56:11 AM »
Guys Hi,

in order to suppress the event handlers from popping in command history i thought this:
say i have awf.lsp. the (c:awf) function will only load it self and the main function to control the dialog box
wrapped in (apply '(lambda () ....) '())  - see the example
at the end set to nil all the event handlers

does this make sense?
(consider the load time of standard lisp file is less than a second)

Moshe


Code: [Select]

(vl-load-com)

(defun c:awf ()
 (prompt "\nLoading awf.lsp...")
 (load "awf")
)


; execute at load time
; control the dialog box
(apply
 '(lambda (/ whatnext)
   (command "OPENDCL")
   (dcl_Project_Load "awf")
   
   (setq whatnext 10)
   
   (while (> whatnext 2)
    (dcl_Form_Show "awf/Form1")
   )
   
   ; remove handlers
   (foreach func (list 'c:event/handler1 'c:event/handler2 'c:event/handler3)
    (set func nil)
   )

   (princ)
  ); lambda
 '()
); apply


(defun c:event/handler1 ()
 ; func code
 ; ...
)

(defun c:event/handler2 ()
 ; func code
 ; ...
)

(defun c:event/handler3 ()
 ; func code
 ; ...
)


roy_043

  • Sr. Member
  • ****
  • Posts: 377
Re: Suppressing event handlers from command history
« Reply #1 on: September 29, 2020, 09:14:57 AM »
AFAIKT, your suggestion would only work for a modal form, and does not offer any advantage over putting everything, including event handlers, in a single named function.

Note that you do not have to use:
(apply '(lambda ...) '())
This will also work:
((lambda ...))

Moshe-A

  • Member
  • *
  • Posts: 14
Re: Suppressing event handlers from command history
« Reply #2 on: September 29, 2020, 12:04:30 PM »
Roy hi,

a. yes i'm talking on modal form.
b. if all event handlers will be defined as local, they would be suppressed at command history but they also be hidden to command line - what i am missing here?

thank you
Moshe
« Last Edit: September 30, 2020, 04:47:53 AM by Moshe-A »

roy_043

  • Sr. Member
  • ****
  • Posts: 377
Re: Suppressing event handlers from command history
« Reply #3 on: September 29, 2020, 11:37:58 PM »
b. if all event handlers will be defined as local..
Assuming this is indeed what you want, why don't you use this structure:
Code: [Select]
(defun c:awf ( / c:event/handler1 c:event/handler2 c:event/handler3) ...)

Moshe-A

  • Member
  • *
  • Posts: 14
Re: Suppressing event handlers from command history
« Reply #4 on: September 30, 2020, 12:01:37 AM »
did that but the event handlers were suppressed from the command line.

roy_043

  • Sr. Member
  • ****
  • Posts: 377
Re: Suppressing event handlers from command history
« Reply #5 on: September 30, 2020, 11:29:21 AM »
You need to explain what you mean by that. Were the event handlers not executed, or were they not included in the command history?

Here is an example of what I mean:
https://opendcl.com/forum/index.php?topic=1946.msg9549#msg9549

Moshe-A

  • Member
  • *
  • Posts: 14
Re: Suppressing event handlers from command history
« Reply #6 on: September 30, 2020, 11:42:31 AM »
OK re-checked and the result is:
all event handler functions declare as local, the event handler functions exists in command history (which i do not like)
but OPENDCL still can call them but i can not key-in them in the command line and i curious to know how this is done?

thanks
Moshe



roy_043

  • Sr. Member
  • ****
  • Posts: 377
Re: Suppressing event handlers from command history
« Reply #7 on: October 01, 2020, 11:22:00 AM »
If the event handlers are nested and localized in a parent function they do not exist outside the scope of that function. And in BricsCAD event handlers then do not leave a trace in the command history. I seem to remember that AutoCAD behaves differently here. You'll have to search the forum for more info.

Of course this approach can only work for modal forms.