TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Krushert on April 10, 2006, 09:38:15 PM

Title: Why is this action_tile crashing??
Post by: Krushert on April 10, 2006, 09:38:15 PM
Need a little help in debugging this.

Why is this action_tile crashing??  It creates the WBlock file in the correct location.  And that is where it stops, right at the end of Action tile “rb1” line.  I took out line of code for “rb2” and it is still crashing at “rb1” line. Animate and Stop @ break confirmed the same thing.

Code: [Select]
    (unload_dialog dcl_id) ;unload

  (princ)



  ;; Main Application ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(today)
(StrPath)

(vl-mkdir NewPath)

(setvar "expert" 4)
(action_tile "rb1" "(command " Wblock " NewFile " * ")")
;New version 2004 file with date Prefix
(action_tile "rb2" "(command " saveas " " 2000 " OldFile)")
  ;New version 2000 file with date Prefix
 
(command "saveas" "2004" OldFile) ;Saves back to the Orginal File.
(setvar "expert" 0)
(setq *error* old_error)
(princ)
);;End of Routine


When I check it with the editor’s check, I get this warning.
Code: [Select]
[CHECKING TEXT Tedstest.LSP loading...]
.
; warning: too many arguments: (ACTION_TILE "rb1" "(command " WBLOCK ... )
; Check done.


Question so I can understand this.  Is the “action_tile” function nothing more that a fancy “IF” function?
Title: Re: Why is this action_tile crashing??
Post by: Keith™ on April 10, 2006, 09:57:58 PM
you cannot use "command" as the action of any action_tile. If you wish to use COMMAND as the result of any button the user may press, I would suggest that what you do is:

Remove COMMAND from the function call in the action_tile
Set a variable (call it whatever you like)
dismiss the dialog box
execute COMMAND based on the value of the variable you set ...

It could be done as such:
Code: [Select]
;New version 2004 file with date Prefix
(action_tile "rb1" "(setq which_action 1)")
;New version 2000 file with date Prefix
(action_tile "rb2" "(setq which_action 2)")
;Saves back to the Orginal File.
;;; extraneous code here

(done_dialog);how you achieve it is entirely up to you
(setvar "expert" 4)
(cond
 ((= which_action 1)(vl-cmdf " Wblock " NewFile " * "))
 ((= which_action 2)(vl-cmdf " saveas " " 2000 " OldFile))
)
(vl-cmdf "saveas" "2004" OldFile)
(setvar "expert" 0)
Title: Re: Why is this action_tile crashing??
Post by: Krushert on April 11, 2006, 09:23:05 AM
Thanks Keith.

Thanks for showing me about the “vl-cmdf” function.  Last night I look it up Vlisp help and can understand how that function came about.

I basically pasted in your suggested code, tweaked a few minor bugs that popped up and it works great.  One of the bugs that came across is listed below.  I got it to work but don’t understand why it is needed.  I had to add the “Line 1” code (not really line 1 in the routine) so that Lines 2 & 4 could work.  Why do I need to preset the variable “which_action” to one when Line 2 sets the variable “which_action” to 1 again?
Why?  I am just asking so I can understand.
 


Code: [Select]
Line 1 =  (setq which_action 1)
Line 2 =  (action_tile "rb1" "(setq which_action 1)")
Line 3 = ;New version 2004 file with date Prefix
Line 4 =  (action_tile "rb2" "(setq which_action 2)")
Line 5 = ;New version 2000 file with date Prefix

Thanks again
Ted
Oh by the way; my IT guy thanks you too.
Title: Re: Why is this action_tile crashing??
Post by: Keith™ on April 11, 2006, 09:30:22 AM
It shouldn't ... but as long as it works ...
Title: Re: Why is this action_tile crashing??
Post by: GDF on April 11, 2006, 11:21:47 AM
Keith

change:
(action_tile "rb1" "(command " Wblock " NewFile " * ")")
to:
(action_tile "rb1" "(command \"Wblock\" NewFile \"*\")")

Gary
Title: Re: Why is this action_tile crashing??
Post by: Keith™ on April 11, 2006, 11:31:10 AM
Keith

change:
(action_tile "rb1" "(command " Wblock " NewFile " * ")")
to:
(action_tile "rb1" "(command \"Wblock\" NewFile \"*\")")

Gary

Nope ....
Quote from: AutoLISP Reference in AutoCAD help file
NOTE You cannot call the AutoLISP command function from the action_tile function.
Title: Re: Why is this action_tile crashing??
Post by: GDF on April 11, 2006, 11:56:51 AM
Keith

change:
(action_tile "rb1" "(command " Wblock " NewFile " * ")")
to:
(action_tile "rb1" "(command \"Wblock\" NewFile \"*\")")

Gary


Nope ....
Quote from: AutoLISP Reference in AutoCAD help file
NOTE You cannot call the AutoLISP command function from the action_tile function.



You can call me bonehead. Of course you are correct. I was only refering to the \" and should have
spotted the command in the action tile.

I'm going across the street for some more coffee, now...

Gary