Visual LISP compiler drops function symbol that was called from an ACTION_TILE action string

Visual LISP compiler drops function symbol that was called from an ACTION_TILE action string

hawstom
Advocate Advocate
694 Views
10 Replies
Message 1 of 11

Visual LISP compiler drops function symbol that was called from an ACTION_TILE action string

hawstom
Advocate
Advocate

The Autodesk Help article "About Compiler Optimizing Conditions (Visual LISP IDE)" says:


"The compiler does not drop the symbol for a function definition if the ... function was called from an ACTION_TILE action string."

 

But the compiler drops the function HCNM_EB:SAVE_EDIT_BOX that is called in the following code at line 6047 of the devtgh/cnm.lsp file at https://github.com/hawstom/cnm:

  (FOREACH
     ATTRIBUTE HCNM_EB:ATTRIBUTE_LIST
    (SET_TILE (STRCAT "Edit" (CAR ATTRIBUTE)) (CADR ATTRIBUTE))
    (ACTION_TILE
      (STRCAT "Edit" (CAR ATTRIBUTE))
      (STRCAT
        "(HCNM_EB:SAVE_EDIT_BOX \""
        (CAR ATTRIBUTE)
        "\" $value)"
      )
    )
  )

 

Can anybody shed light on this behavior including any general discussion about Visual LISP compiler Build Options (standard vs. optimize, link mode, localize variables, safe optimize)?

0 Likes
695 Views
10 Replies
Replies (10)
Message 2 of 11

scot-65
Advisor
Advisor

Your STRCAT shall be inside the double quote.

 

(action_tile "Tile_name" "(strcat (any \"action\" associated))")

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 3 of 11

hawstom
Advocate
Advocate

@scot-65, your reply implies that the action_tile function is unable to be implemented in loops (lambda, foreach, while, etc.). Do you know this to be true? You are saying that the following is either unsupported generally or unsupported by the compiler optimizer?

 

 

(mapcar
  '(lambda (tile / key val action-expression)
    (setq
      key (strcat "Edit" (car tile))
      val (cadr tile)
      action-expression (strcat 
        "(myapp-save-edit-box \"" 
        key 
        "\" $value"
      )
    )
    (set_tile key val)
    (action_tile key action-expression)
  )
  '(("KeyPart1" "Val1")("KeyPart2" "Val2")("KeyPart3" "Val3"))
)
    

 

0 Likes
Message 4 of 11

Sea-Haven
Mentor
Mentor

"action_tile function is unable to be implemented in loops"

 

Yes it can say you have buttons Rb1-Rb10 you can loop through making the key a (strcat "Rb" (rtos x 2 0)) and say output similar d1-d10.

 

Its been a while since I wrote this. Makes a list of the edit boxes. "Key1-Key?

(setq x 0)
  (setq y 0)
  (setq v_lst '())
  (repeat num
    (setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0)))
    (setq key_lst (cons keynum key_lst))
    (set_tile keynum (nth (setq x (+ x 4)) dcllst)) ;sets values from list
  )
  (mode_tile "key1" 2)
  (action_tile "accept" "(mapcar '(lambda (x) (setq v_lst (cons (get_tile x) v_lst))) key_lst)(done_dialog)")

 

Message 5 of 11

hawstom
Advocate
Advocate

Yes. You invoked set_tile within a loop. I notice you happened not to invoke action_tile within a loop. But I have a hard time believing that is not similarly valid. And I have to ask if @scot-65 just needs to double-check and edit their answer. They may have hastily thought they were seeing a programming error that is not there in either of my code snippets. Since the code runs fine when not optimized, my guess is that something is preventing the optimizer from seeing the function call in the action_tile callback string. Here's a crazy guess:

-Function name too long? I can test for that, I guess.

Any other guesses?

0 Likes
Message 6 of 11

komondormrex
Mentor
Mentor

use other compiling modes?

Message 7 of 11

Sea-Haven
Mentor
Mentor

Last line the mapcar is Action_tile response gets all values as a list. Press ok then runs.

0 Likes
Message 8 of 11

hawstom
Advocate
Advocate

Yes. This is my current workaround. I turned off optimization.

0 Likes
Message 9 of 11

hawstom
Advocate
Advocate

Yes. You are doing something different than I am doing. I am doing multiple action_tile declarations using the mapcar lambda.

0 Likes
Message 10 of 11

komondormrex
Mentor
Mentor

in case you have not, have you tried command line compiler with ls* modes?

command line compiler

0 Likes
Message 11 of 11

hawstom
Advocate
Advocate

No. Tell me more.

0 Likes