Jonathan Handojo Posted March 11, 2020 Share Posted March 11, 2020 If you don't include anything after the if statement, your LISP will end there. What do you mean? Quote Link to comment Share on other sites More sharing options...
Sheep Posted March 11, 2020 Author Share Posted March 11, 2020 I don't know how to put it in words. Let say i'm done with the first routine and i want an option to stop there OR continue to second routine. If i pick NO it will ends the whole LISP without making the second routine but if i pick YES it will continue to second routine. I tried with some dummy code: (defun First_Routine () (initget 1 "Yes No") (if (eq (getkword "\nProceed to Proposed? [Yes/No]: ") "Yes") Second_Routine)) ) (defun Second_Routine() (alert "\nI'm in Defun B ") ) But if i pick NO, it just like going in LOOP ( i don't know if thats the right term). Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted March 11, 2020 Share Posted March 11, 2020 Ah, your function is in a while loop... makes sense. Then... (defun First_Routine nil (while (progn ; your code (initget 1 "Yes No") (if (eq (getkword "\nProceed to Second_Routine? [Yes/No]: ") "Yes") (progn (Second_Routine) T) ) ) ) ) (defun Second_Routine nil (alert "\nI'm in Routine B") ) 1 Quote Link to comment Share on other sites More sharing options...
Sheep Posted March 13, 2020 Author Share Posted March 13, 2020 On 3/11/2020 at 1:33 PM, Jonathan Handojo said: Ah, your function is in a while loop... makes sense. Then... Tried making a new (defun) and inserted these code: (defun Opt () (initget "Yes No") (setq kw (getkword "Proceed to next routine? [Yes/No] <Yes>: ")) (cond ((or (not kw) (= "Yes" kw)) (acTitikPertama)) ((= "No" kw) (alert "This is defun Opt")) ) (princ) ) ;;============================================================== (defun acTitikPertama () (alert " I'm in acTitikPertama!") ) When i choose NO, it stil jump to (defun acTitikPertama). Not like my previous code in a WHILE, this is totally in defferent defun. It did not END the LISP. Is it because acTitikPertama is in my main run (defun c:KK() ? I don't think thats the problem because sometimes the LISP need to run acTitikPertama. (defun c:KK () (Opt) (acTitikPertama) ;<----- Exist here! (NewDitk) (princ) ) Can somebody help me...anybody please. This driving me nuts. Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted March 13, 2020 Share Posted March 13, 2020 17 minutes ago, Sheep said: Tried making a new (defun) and inserted these code: When i choose NO, it stil jump to (defun acTitikPertama). because it was evaluated after (opt) (defun c:KK () (Opt) ;;;;;(acTitikPertama) ;<----- try skip this (NewDitk) (princ) ) Quote Link to comment Share on other sites More sharing options...
Sheep Posted March 13, 2020 Author Share Posted March 13, 2020 2 minutes ago, hanhphuc said: because it was evaluated after (opt) (defun c:KK () (Opt) ;;;;;(acTitikPertama) ;<----- try skip this (NewDitk) (princ) ) Thank you for your reply @hanhphuc. But will acTitikPertama still run even without making in the list? I do apologize for these question. Even the simplest thing like Defun and global, i still trying to understand...... Quote Link to comment Share on other sites More sharing options...
Sheep Posted March 13, 2020 Author Share Posted March 13, 2020 @hanhphuc, it works! Thanks a million. Can you please explain, any other condition when should i avoid calling a defun in the main list? BTW, the c:KK, what is the right term for it? Main programme? Main defun list? Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted March 13, 2020 Share Posted March 13, 2020 53 minutes ago, Sheep said: Thank you for your reply @hanhphuc. But will acTitikPertama still run even without making in the list? I do apologize for these question. Even the simplest thing like Defun and global, i still trying to understand...... ; list? not quite. maybe you mean acTitikPertama inside ( ? ), the first symbol within brackets (symbol ... ) evaluated as function so it'll be executed. example: (ver) (acTitikPertama) (c:KK) (itoa 123) ; with argument 33 minutes ago, Sheep said: @hanhphuc, it works! Thanks a million. Can you please explain, any other condition when should i avoid calling a defun in the main list? just skip it Quote BTW, the c:KK, what is the right term for it? Main programme? Main defun list? whatever you name it main program, as long as you invoke SINGLE command like c:KK, then you get the job done. which sub routines maybe used MANY times during c:KK executing. (defun c:KK ( / sub1 sub2 sub3 )(defun sub1 ...) (defun sub2 ...) (defun sub3 ...) ; execution) 1 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.