Archiman86 Posted March 26, 2010 Share Posted March 26, 2010 I am trying to remove a specific dictionary from a bunch of files. The client we work with has issues in their document management system when this exists in the files. I am trying to get this to work so that it prints whether it did not already exist, or if it was deleted. Right now I keep getting an error that says: error: bad function: Here is what I have so far: (defun c:GCI()(setq newdictlist (dictsearch (namedobjdict) "GcImageDef_Dict")) (If (= nil newdictlist) (princ "\nGcImageDef_Dict does not exist.") ((dictremove (namedobjdict) "GcImageDef_Dict") (princ"\nThe GcImageDef_Dict has been removed.")) ) (princ) ) Thanks in advance for any help! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 26, 2010 Share Posted March 26, 2010 I can't test it, but maybe something like this? (defun c:GCI (/ newdictlist) (cond ( (setq newdictlist (dictsearch (namedobjdict) "GcImageDef_Dict")) (dictremove (namedobjdict) "GcImageDef_Dict") (princ "\nThe GcImageDef_Dict has been removed.")) ( (princ "\nGcImageDef_Dict does not exist."))) (princ)) Quote Link to comment Share on other sites More sharing options...
Archiman86 Posted March 26, 2010 Author Share Posted March 26, 2010 Lee, Thanks! Thats works. By chance, can you explain why it would return that error for me. In theory, to my knowledge that should work. I mean, my version DID work, it jsut put that error after printing "...has been removed." Thanks again! -Dan Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 26, 2010 Share Posted March 26, 2010 It was this line: ((dictremove (namedobjdict) "GcImageDef_Dict") (princ"\nThe GcImageDef_Dict has been removed.")) Which would be interpreted as: (<entity_name> "\nThe GcImageDef_Dict has been removed.") I.e. as if the was a function, (which it isn't, of course). To wrap two expressions in the THEN statement of the IF function, you need to use a wrapper like PROGN: (defun c:GCI (/ newdictlist) (setq newdictlist (dictsearch (namedobjdict) "GcImageDef_Dict")) (If (= nil newdictlist) (princ "\nGcImageDef_Dict does not exist.") (progn (dictremove (namedobjdict) "GcImageDef_Dict") (princ"\nThe GcImageDef_Dict has been removed.") ) ; progn ) ; IF (princ)) Quote Link to comment Share on other sites More sharing options...
JohnM Posted March 26, 2010 Share Posted March 26, 2010 i think the issue is your IF statement (= nil newdictlist) should be (= newdictlist nil) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.