TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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.
(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.
[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?
-
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:
;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)
-
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.
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.
-
It shouldn't ... but as long as it works ...
-
Keith
change:
(action_tile "rb1" "(command " Wblock " NewFile " * ")")
to:
(action_tile "rb1" "(command \"Wblock\" NewFile \"*\")")
Gary
-
Keith
change:
(action_tile "rb1" "(command " Wblock " NewFile " * ")")
to:
(action_tile "rb1" "(command \"Wblock\" NewFile \"*\")")
Gary
Nope ....
NOTE You cannot call the AutoLISP command function from the action_tile function.
-
Keith
change:
(action_tile "rb1" "(command " Wblock " NewFile " * ")")
to:
(action_tile "rb1" "(command \"Wblock\" NewFile \"*\")")
Gary
Nope ....
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