Suppressing event handlers from command history

Started by Moshe-A, September 29, 2020, 03:56:11 AM

Previous topic - Next topic

Moshe-A

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




(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

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

#2
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

roy_043

Quote from: Moshe-A on September 29, 2020, 12:04:30 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:
(defun c:awf ( / c:event/handler1 c:event/handler2 c:event/handler3) ...)

Moshe-A

did that but the event handlers were suppressed from the command line.

roy_043

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

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

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.