Author Topic: What "DEFUN" is active?  (Read 263 times)

0 Members and 1 Guest are viewing this topic.

snownut2

  • Swamp Rat
  • Posts: 947
  • Bricscad 20 Ultimate
What "DEFUN" is active?
« on: November 30, 2019, 08:13:31 AM »
Is there anyway of collecting what "DEFUN" is active, say for creating a help or info type of library?

Grrr1337

  • Swamp Rat
  • Posts: 710
Re: What "DEFUN" is active?
« Reply #1 on: November 30, 2019, 08:26:24 AM »
Code - Auto/Visual Lisp: [Select]
  1. (foreach x (vl-remove-if-not '(lambda (x)(wcmatch x "C:*")) (atoms-family 1)) (print x))
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)

snownut2

  • Swamp Rat
  • Posts: 947
  • Bricscad 20 Ultimate
Re: What "DEFUN" is active?
« Reply #2 on: November 30, 2019, 12:52:41 PM »
Ok, after some experimenting with the atoms-family function, it seems it will not work form my purpose.

However if I could determine the name of the currently active DCL that would also work.

MP

  • Seagull
  • Posts: 17488
Re: What "DEFUN" is active?
« Reply #3 on: November 30, 2019, 12:55:51 PM »
What are you ultimately trying to achieve?
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

snownut2

  • Swamp Rat
  • Posts: 947
  • Bricscad 20 Ultimate
Re: What "DEFUN" is active?
« Reply #4 on: November 30, 2019, 01:18:19 PM »
I am trying to locate all of the help data in one lsp file, however I have created a single function to write the end (prefix if you will) of all my DCL's in that same lsp, not the ones that call the individual  dialogs.  There is also a function to insert a program ICON/AVATAR image button that host the "avatar" and "help" action_tiles, I am however trying to come up with a scheme to recognize where the "action_tiles" are being called from, to be able to individualize the "avatar" and "help"action_ tiles.

File "A" has 2-functions, one to create the DCL prefixes, and another one to load the "image_tile" and "action_tiles" for "avatar" and "help" buttons.

All other files (20+) contain individual dialog functions, most contain multiple dialogs.

I would like to be able to recognize where the "avatar" and "help" calls are coming from without the need to update all of the load_dialog locations.

I know this may sound a bit odd, but it has eliminated quite a few lines of code, and will allow me to edit all "help" text in one file.

Here is what my prefix "box" look like;

Code - Auto/Visual Lisp: [Select]
  1.  (defun dcl-sig ( typ / txt txt1)
  2.     (setq
  3.       txt
  4.         (cond
  5.           ((= typ 1)"\n        ok_cancel_help_errtile;" )
  6.           ((= typ 2)"\n        ok_cancel;")
  7.           ((= typ 3)"\n        ok_cancel_err;")        
  8.           ((= typ 4)"\n        ok_only;")          
  9.           ((= typ 5)"\n        ok_cancel_help;")        
  10.           ((= typ 6)"\n        ok_cancel_help_info;")    
  11.           ((= typ 7)"\n        cancel_button;")
  12.           ((= typ 8)"\n        cancel_button;\n        errtile;")
  13.           ((= typ 9)
  14.             (strcat
  15.               "\n        : row { "
  16.               "\n          : spacer { width = 1.5 ; } "
  17.               "\n          : button { label = \"Accept\"          ; key = \"accept\"; width =  8; fixed_width = true; }"
  18.               "\n          : button { label = \"Edit Design Data\"; key = \"resize\"; width =  9; fixed_width = true; }"
  19.               "\n          : button { label = \"Cancel\"          ; key = \"cancel\"; width =  8; fixed_width = true; is_cancel = true; }"
  20.               "\n          : spacer { width = 1.5 ; } "            
  21.               "\n        }"
  22.               "\n        : errtile { width= 50; alignment = centered; }"            
  23.             )
  24.           )
  25.         )
  26.       txt1
  27.         (strcat
  28.             "\n    : boxed_row {  "
  29.             "\n      : column {  "
  30.             txt
  31.             "\n       : text { label = \""(getenv "SA_App_Name")"\"; alignment = centered;}"        
  32.             "\n      }"
  33.             "\n      : column { width = 8.5 ; fixed_width = true;"        
  34.             "\n        : image_button { key = \"avatar\" ; width = 3.8; color = -15; }"
  35.             "\n      }"
  36.             "\n    }"
  37.         )
  38.     )
  39.     txt1
  40.   );defun (setq txte(dcl-sig 1))
  41.  






MP

  • Seagull
  • Posts: 17488
Re: What "DEFUN" is active?
« Reply #5 on: November 30, 2019, 01:31:27 PM »
<Simplistic but> Since (it appears) it concerns code you've penned 100% couldn't you just maintain / update a global var rather than going thru calisthenics? 
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

snownut2

  • Swamp Rat
  • Posts: 947
  • Bricscad 20 Ultimate
Re: What "DEFUN" is active?
« Reply #6 on: November 30, 2019, 01:40:56 PM »
I could do that, was hoping to not have to though, save having to go through and set active DCL name as a global in all the required files and locations.

I figured there's got to be a way to identify the name of the active dialog programmatically in one place rather then set it as a variable in dozens of places.

MP

  • Seagull
  • Posts: 17488
Re: What "DEFUN" is active?
« Reply #7 on: November 30, 2019, 01:49:53 PM »
You might be able to do something based on the careful use of a lisp reactor, i.e. (vlr-lisp-reactor data callbacks).
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17488
Re: What "DEFUN" is active?
« Reply #8 on: November 30, 2019, 04:02:53 PM »
Are the various dialogs initiated by separate c: type defuns or within one c: defun?
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17488
Re: What "DEFUN" is active?
« Reply #9 on: November 30, 2019, 04:11:53 PM »
(defun dcl-sig ( typ caller ) ... )

?
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

snownut2

  • Swamp Rat
  • Posts: 947
  • Bricscad 20 Ultimate
Re: What "DEFUN" is active?
« Reply #10 on: November 30, 2019, 05:48:31 PM »
MP thanks for the guidance, I just completed doing this....

Code - Auto/Visual Lisp: [Select]
  1. (if (not(new_dialog (setq $DCL-N$ "custname") dcl_idcn "" '(-1 -1)))
  2.               (progn
  3.                 (alert "\nUnable to load dialog.")
  4.                 (exit)
  5.               )
  6.             );end if
  7.  

Creating a global variable $DCL-N$ that I've added to the 75+ dialogs I have.

MP

  • Seagull
  • Posts: 17488
Re: What "DEFUN" is active?
« Reply #11 on: December 01, 2019, 02:58:26 PM »
You’re most welcome - glad you found a solution that works for you - cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox