Cylis0509 Posted February 12, 2015 Share Posted February 12, 2015 (edited) .. or if you have express tools loaded, try something like this .. (SETQ reply (ACET-UI-MESSAGE "Choose dude " "Russells Dialog" (+ Acet:YESNOCANCEL Acet:ICONWARNING) ) ) ;; Yes = 6 ;; No = 7 ;; Cancel = 2 (IF (= reply 6) (PROGN (ALERT "Yep") ;; ;; More Yes Mojo ) ;; else (PROGN (ALERT "Nope") ;; ;; More no mojo ) ) How do I get this to "call/goto" another defun within the same lisp. When I try it, it tells me ; error: no function definition: (vl-load-com) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (SETQ reply1 (ACET-UI-MESSAGE (strcat "Some Text") "Some Header" 36)) (IF (= reply1 6) (c:mos2nsc)) (IF (= reply1 7) (c:runlater)) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:mos2nsc ( / ) (SETQ reply2 (ACET-UI-MESSAGE (strcat "Some Text") "Some Header" 20)) (IF (= reply2 6) (c:replyyes)) (IF (= reply2 7) (c:runlater)) ) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:replyyes ( / of_epk of_pt) (setvar "cmdecho" 0) (if (null of_dist) (setq of_distx 1.0)) (initget 6) (if (null (setq of_dist (getdist (strcat "\nPlease Enter the Offset Distance <>: ")))) (setq of_dist of_distx) ) (setq of_distx of_dist) (if (null of_elev) (setq of_elevx 0.0)) (if (null (setq of_elev (getreal (strcat "\nPlease Enter the Elevation Difference - For a Negative Use a '-' <>: ")))) (setq of_elev of_elevx) ) (setq of_elevx of_elev) (while (or (setq of_epk (entsel)) (eq 7 (getvar "errno"))) (if (and of_epk (member (cdr (assoc 100 (reverse (entget (car of_epk))))) '("AcDbPolyline" "AcDb2dPolyline")) (setq of_pt (getpoint "\nPlease Select the Side to offset: ")) ) (command "_.offset" of_dist of_epk of_pt "" "_.move" (entlast) "" (list 0.0 0.0 of_elev) "") ) ) (princ) ) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:runlater ( / ) (acet-ui-message "To run later, type 'MOS2NSC' anytime to begin to conversion process." "Some Header" 64) ) Edited February 13, 2015 by SLW210 1 Quote Link to comment Share on other sites More sharing options...
Cylis0509 Posted February 12, 2015 Author Share Posted February 12, 2015 (edited) Hi, I'm having trouble with a current LISP I'm working on. I found some code on this site for yes/no dialog/alert boxes. I am trying to modify it so each button will jump to a different section/different DEFUN within the same lisp. When I run it, it states that the functions do not existing. I have it set up to launch a yes/no box on load. Click yes to run now, click no to run later. When I click no I get: ; error: no function definition: C:RUNLATER. I hope someone can help me out. Thank you! (vl-load-com) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (SETQ reply1 (ACET-UI-MESSAGE (strcat "Some Text") "Some Header" 36)) (IF (= reply1 6) (c:mos2nsc)) (IF (= reply1 7) (c:runlater)) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:mos2nsc ( / ) (SETQ reply2 (ACET-UI-MESSAGE (strcat "Some Text") "Some Header" 20)) (IF (= reply2 6) (c:replyyes)) (IF (= reply2 7) (c:runlater)) ) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:replyyes ( / of_epk of_pt) (setvar "cmdecho" 0) (if (null of_dist) (setq of_distx 1.0)) (initget 6) (if (null (setq of_dist (getdist (strcat "\nPlease Enter the Offset Distance <>: ")))) (setq of_dist of_distx) ) (setq of_distx of_dist) (if (null of_elev) (setq of_elevx 0.0)) (if (null (setq of_elev (getreal (strcat "\nPlease Enter the Elevation Difference - For a Negative Use a '-' <>: ")))) (setq of_elev of_elevx) ) (setq of_elevx of_elev) (while (or (setq of_epk (entsel)) (eq 7 (getvar "errno"))) (if (and of_epk (member (cdr (assoc 100 (reverse (entget (car of_epk))))) '("AcDbPolyline" "AcDb2dPolyline")) (setq of_pt (getpoint "\nPlease Select the Side to offset: ")) ) (command "_.offset" of_dist of_epk of_pt "" "_.move" (entlast) "" (list 0.0 0.0 of_elev) "") ) ) (princ) ) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:runlater ( / ) (acet-ui-message "To run later, type 'MOS2NSC' anytime to begin to conversion process." "Some Header" 64) ) Edited February 12, 2015 by Cylis0509 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 12, 2015 Share Posted February 12, 2015 Modify you reply to include the CODE TAGS for your codes . You received that error message because the required function or routine wasn't loaded yet when the first part of your codes did , so if you try it again it should run normally. Replace the first part of your codes to the bottom and try again . Quote Link to comment Share on other sites More sharing options...
Cylis0509 Posted February 12, 2015 Author Share Posted February 12, 2015 Modify you reply to include the CODE TAGS for your codes . You received that error message because the required function or routine wasn't loaded yet when the first part of your codes did , so if you try it again it should run normally. Replace the first part of your codes to the bottom and try again . Thank you for the reply! I tried to use the "#" button but it didn't do anything. I was trying to figure out how to do the code boxes like you guys. I apologize for that. As for the code you are right. When I put the "opening" message at the end of my code it works like a dream. Thank you. My next question though is; because of my OCD I would really like the "opening" message at the beginning of my code. Is there a way to preload the other functions at the beginning? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 12, 2015 Share Posted February 12, 2015 As Tharwat has indicated, the following expressions are evaluated when loading the program: (SETQ reply1 (ACET-UI-MESSAGE (strcat "Some Text") "Some Header" 36)) (IF (= reply1 6) (c:mos2nsc)) (IF (= reply1 7) (c:runlater)) However, the functions that you are attempting to evaluate based on the user's response [ (c:mos2nsc) & (c:runlater) ] are not yet evaluated, as the defun expressions appear after the expressions that are being evaluated when loading. Quote Link to comment Share on other sites More sharing options...
Cylis0509 Posted February 12, 2015 Author Share Posted February 12, 2015 Thank you guys this is very helpful!! I really appreciate it. My next question though is; because of my OCD I would really like the "opening" message at the beginning of my code. Is there a way to preload/pre-evaluate the defun expressions at the beginning? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 12, 2015 Share Posted February 12, 2015 My next question though is; because of my OCD I would really like the "opening" message at the beginning of my code. Is there a way to preload/pre-evaluate the defun expressions at the beginning? (vl-load-com) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun onloadexpressions ( / reply1 ) (SETQ reply1 (ACET-UI-MESSAGE (strcat "Some Text") "Some Header" 36)) (cond ( (= 6 reply1) (c:mos2nsc)) ( (= 7 reply1) (c:runlater)) ) (princ) ) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:mos2nsc ( / reply2 ) (SETQ reply2 (ACET-UI-MESSAGE (strcat "Some Text") "Some Header" 20)) (cond ( (= 6 reply1) (c:replyyes)) ( (= 7 reply1) (c:runlater)) ) (princ) ) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:replyyes ( / of_dist of_elev of_epk of_pt ) (setvar "cmdecho" 0) (if (null of_distx) (setq of_distx 1.0)) (initget 6) (if (setq of_dist (getdist (strcat "\nPlease Enter the Offset Distance <" (rtos of_distx) ">: "))) (setq of_distx of_dist) ) (if (null of_elevx) (setq of_elevx 0.0)) (if (setq of_elev (getreal (strcat "\nPlease Enter the Elevation Difference - For a Negative Use a '-' <" (rtos of_elevx) ">: "))) (setq of_elevx of_elev) ) (while (or (setq of_epk (entsel)) (= 7 (getvar "errno"))) (if (and of_epk (member (cdr (assoc 100 (reverse (entget (car of_epk))))) '("AcDbPolyline" "AcDb2dPolyline")) (setq of_pt (getpoint "\nPlease Select the Side to offset: ")) ) (command "_.offset" of_distx of_epk "_non" of_pt "" "_.move" (entlast) "" "_non" (list 0.0 0.0 of_elevx) "") ) ) (princ) ) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:runlater ( / ) (acet-ui-message "To run later, type 'MOS2NSC' anytime to begin to conversion process." "Some Header" 64) (princ) ) (onloadexpressions) Quote Link to comment Share on other sites More sharing options...
Cylis0509 Posted February 12, 2015 Author Share Posted February 12, 2015 Lee Mac you are the man!! Thank you so much, that worked perfectly. I sent you an email on your website, you can disregard that now. Tharwat, thank you as well. I really appreciate your help. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 12, 2015 Share Posted February 12, 2015 Tharwat, thank you as well. I really appreciate your help. It is very kind of you to say that , I just gave you the direction and Lee did the whole things . I recommend you to modify your first post to avoid coming up of a moderator with a warning it is simple thing , read THIS Quote Link to comment Share on other sites More sharing options...
Cylis0509 Posted February 12, 2015 Author Share Posted February 12, 2015 Ok so at the risk of sounding like an idiot; too late; I cant get the "#" to do anything. I read the article you sent me Tharwat and nothing is happening when I try to edit the post. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 12, 2015 Share Posted February 12, 2015 I cant get the "#" to do anything. I read the article you sent me Tharwat and nothing is happening when I try to edit the post. After pressing the button Edit Post select the codes then press the button # to obtain them within cod tags . Quote Link to comment Share on other sites More sharing options...
Cylis0509 Posted February 12, 2015 Author Share Posted February 12, 2015 That's exactly what I did. It doesn't seem to work for me. I went to edit post, went to advanced, highlighted the section of code, clicked the "#" button, nothing happened, saved edit. Quote Link to comment Share on other sites More sharing options...
Cad64 Posted February 12, 2015 Share Posted February 12, 2015 It's a problem with Internet Explorer. Apparently it doesn't play well with vBulletin forums. Read the last post in this thread: http://www.cadtutor.net/forum/showthread.php?90496-Icons-not-working-in-replies and switch to the basic or standard editor. Then you should be able to fix your first post. Quote Link to comment Share on other sites More sharing options...
Cylis0509 Posted February 12, 2015 Author Share Posted February 12, 2015 Thank you Cad64, that did it. I set it to standard and its working now. I have fixed my original post. Quote Link to comment Share on other sites More sharing options...
wishbonesr Posted February 12, 2015 Share Posted February 12, 2015 How do I get this to "call/goto" another defun within the same lisp. When I try it, it tells me ; error: no function definition: You have to think of lisp as a script language (because it is), and in your code, you're calling a function/command before you have loaded in the environment. Move functions that are being called, above the calling function. For Example. I moved your functions around in the following order and it then works: c:runlater c:replyyes c:mos2nsc --lastly you would place the non-encapsulated code setq reply1...etc. (vl-load-com) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:runlater ( / ) (acet-ui-message "To run later, type 'MOS2NSC' anytime to begin to conversion process." "Some Header" 64) ) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:replyyes ( / of_epk of_pt) (setvar "cmdecho" 0) (if (null of_dist) (setq of_distx 1.0)) (initget 6) (if (null (setq of_dist (getdist (strcat "\nPlease Enter the Offset Distance <>: ")))) (setq of_dist of_distx) ) (setq of_distx of_dist) (if (null of_elev) (setq of_elevx 0.0)) (if (null (setq of_elev (getreal (strcat "\nPlease Enter the Elevation Difference - For a Negative Use a '-' <>: ")))) (setq of_elev of_elevx) ) (setq of_elevx of_elev) (while (or (setq of_epk (entsel)) (eq 7 (getvar "errno"))) (if (and of_epk (member (cdr (assoc 100 (reverse (entget (car of_epk))))) '("AcDbPolyline" "AcDb2dPolyline")) (setq of_pt (getpoint "\nPlease Select the Side to offset: ")) ) (command "_.offset" of_dist of_epk of_pt "" "_.move" (entlast) "" (list 0.0 0.0 of_elev) "") ) ) (princ) ) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (defun c:mos2nsc ( / ) (SETQ reply2 (ACET-UI-MESSAGE (strcat "Some Text") "Some Header" 20)) (IF (= reply2 6) (c:replyyes)) (IF (= reply2 7) (c:runlater)) ) ;-------------------------------------------------------------------------------------------------------------------------------------------------------------------- (SETQ reply1 (ACET-UI-MESSAGE (strcat "Some Text") "Some Header" 36)) (IF (= reply1 6) (c:mos2nsc)) (IF (= reply1 7) (c:runlater)) On a separate note: You are also defining all your functions as commands. Which makes sense for c:mos2nsc, but not for any other. Secondly, you have a few instances where your using setq on a var, but not assigning it anything. I'm wondering if the thought, is that this will clear the value (which it does not), or if you are using this method to return the current value of the var. If the first, then you would clear a var by setting it to nil, "", or 0. If the second, then you could return the value of a var by simply typing the name of the var, without parenthesis. Of course if you have purpose other than my limited insight, then please forgive me. Lastly, this really deserves it's own thread in order for it to get the attention it deserves and because the problem you faced isn't so much related to the original post. And to encapsulate your code in the code hashes Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 12, 2015 Share Posted February 12, 2015 Please read the Code Posting Guidelines and edit your post to include the Code in Code Tags. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 12, 2015 Share Posted February 12, 2015 You can also just manually type [.CODE] Your Code[/code]. No space between [C Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 12, 2015 Share Posted February 12, 2015 Lee Mac you are the man!! Thank you so much, that worked perfectly. I sent you an email on your website, you can disregard that now. You're welcome! Aside, regarding the code tags - as SLW210 has suggested, I find it easier to simply type the BBCode tags, i.e.: [highlight][noparse] [/noparse][/highlight] Your code here [highlight][noparse] [/noparse][/highlight] Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 12, 2015 Share Posted February 12, 2015 @Moderator, suggest moving posts #17 onwards to this thread. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 13, 2015 Share Posted February 13, 2015 Posts Merged. 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.