Sheep Posted March 7, 2020 Author Posted March 7, 2020 19 minutes ago, hanhphuc said: Wow, never knew that. Thanks, new info for me. (foreach x '( a b c d e ) (set x nil) ) Quote
Sheep Posted March 8, 2020 Author Posted March 8, 2020 Quote (Defun a () .....some code ) Getkword Yes/No (Defun b () ...more codes ) Maybe this question a bit off topic but i cant figure out how to make it. "A" is done and i want and option to continue to "B" or just stop at "A" (and ends the lisp). 1. How do i do that? 2. Should i reset the vars to nil using (foreach x '(c d e) set nil at defun A or B or both? Quote
Jonathan Handojo Posted March 8, 2020 Posted March 8, 2020 (edited) 5 minutes ago, Sheep said: Maybe this question a bit off topic but i cant figure out how to make it. "A" is done and i want and option to continue to "B" or just stop at "A" (and ends the lisp). 1. How do i do that? 2. Should i reset the vars to nil using (foreach x '(c d e) set nil at defun A or B or both? (Defun a nil Some code (initget 1 "Yes No") (if (eq (getkword "\nProceed to B? [Yes/No]: ") "Yes") (b)) ) Edited March 8, 2020 by Jonathan Handojo 1 Quote
Sheep Posted March 8, 2020 Author Posted March 8, 2020 5 minutes ago, Jonathan Handojo said: (Defun a nil Some code (initget 1 "Yes No") (if (eq (getkword "\nProceed to B? [Yes/No]: ") "Yes") (b)) ) Thanks for your reply. I assume i should set (defun b nil) right? Quote
Jonathan Handojo Posted March 8, 2020 Posted March 8, 2020 6 minutes ago, Sheep said: Thanks for your reply. I assume i should set (defun b nil) right? Whatever variables you have inside your function b, put those variables to the right of the slash. If you don't have any variables to set, then it's fine to do (defun b nil) For example: (Defun addtwo (a b / c) (setq c (+ a b))) (Defun testadd nil (addtwo 4 8)) Since addtwo has a variable c, you should localize that variable. But testadd doesn't have any variables, so there's nothing to localize. However, if you localize like (Defun testadd ( / addtwo) (addtwo 4 8)) The function will fail because there are no functions localized within testadd 1 Quote
Sheep Posted March 8, 2020 Author Posted March 8, 2020 @Jonathan Handojo, thank you for clearing things up. Quote
Sheep Posted March 9, 2020 Author Posted March 9, 2020 (edited) After localized ALL the setq i got: Quote ; error: bad argument type: numberp: nil I assume that from localizing ALL the setq's. How to get at that line? Tried inspect but it returns CALLBACK ENTRY (which i have no idea). In Vlide i have set Break ON Error. Edited March 9, 2020 by Sheep Quote
Jonathan Handojo Posted March 9, 2020 Posted March 9, 2020 26 minutes ago, Sheep said: After localized ALL the setq i got: I assume that from localizing ALL the setq's. How to get at that line? Tried inspect but it returns CALLBACK ENTRY (which i have no idea). In Vlide i have set Break ON Error. That error indicates that a number is expected as an argument but nil is supplied instead. You'll have to revise your code at where the 'nil' comes from... Or post your code here so we all can help you out. Thanks, Jonathan Handojo Quote
Sheep Posted March 9, 2020 Author Posted March 9, 2020 2 minutes ago, Jonathan Handojo said: Or post your code here so we all can help you out. Thanks, Jonathan Handojo @Jonathan Handojo, due to the company policies, i can't paste the code to public. If you don't mind, i'll paste it the in private chat. Quote
Jonathan Handojo Posted March 9, 2020 Posted March 9, 2020 2 minutes ago, Sheep said: @Jonathan Handojo, due to the company policies, i can't paste the code to public. If you don't mind, i'll paste it the in private chat. Ok, as long as it works out. Quote
Sheep Posted March 9, 2020 Author Posted March 9, 2020 6 minutes ago, Jonathan Handojo said: Ok, as long as it works out. This forum didnt allow me to send private message. Quote
Jonathan Handojo Posted March 9, 2020 Posted March 9, 2020 I suppose you can post the code for a moment until I download it, then edit and remove the code. Quote
Sheep Posted March 9, 2020 Author Posted March 9, 2020 (edited) None 2 minutes of open window. 7 minutes ago, Jonathan Handojo said: I suppose you can post the code for a moment until I download it, then edit and remove the code. Edited March 9, 2020 by Sheep Code remove due to company policies. Quote
Sheep Posted March 9, 2020 Author Posted March 9, 2020 3 minutes ago, Jonathan Handojo said: Done... Please dont paste the whole code when you'are done. My company got several people in this forum so i hope im not in trouble for breaking the rules. Quote
Jonathan Handojo Posted March 9, 2020 Posted March 9, 2020 I recommend you put all your sub functions under the main function. Because you did something like: (defun A (a / b) (setq b (* a 5) ) (defun C nil (+ b 9) ) Since you localised b inside function A, no value is set to the variable b outside that function, therefore C will return the error you encountered. I'd rather you do: (defun A (a / b C d) (defun C (e) (+ e 9) ) (setq b (* a 5) d (C b) ) ) P.S. I'm from Indonesia too Thanks, Jonathan Handojo Quote
Sheep Posted March 9, 2020 Author Posted March 9, 2020 (edited) 22 minutes ago, Jonathan Handojo said: I recommend you put all your sub functions under the main function. Because you did something like: (defun A (a / b) (setq b (* a 5) ) (defun C nil (+ b 9) ) Since you localised b inside function A, no value is set to the variable b outside that function, therefore C will return the error you encountered. I'd rather you do: (defun A (a / b C d) (defun C (e) (+ e 9) ) (setq b (* a 5) d (C b) ) ) P.S. I'm from Indonesia too Thanks, Jonathan Handojo Thank you for your time. I'll try it out once i can figure out which is which. No, im not Indonesian im Malaysian. Close tho, neighbour. Edited March 9, 2020 by Sheep 1 Quote
Jonathan Handojo Posted March 9, 2020 Posted March 9, 2020 One thing worth noting is that you can also localize your functions too that lies inside a function, hence why I localized C above. 1 Quote
Sheep Posted March 9, 2020 Author Posted March 9, 2020 Just now, Jonathan Handojo said: One thing worth noting is that you can also localize your functions too that lies inside a function, hence why I localized C above. My brain hurts. 10 minutes break. Quote
Sheep Posted March 11, 2020 Author Posted March 11, 2020 On 3/8/2020 at 8:39 AM, Jonathan Handojo said: (Defun a nil Some code (initget 1 "Yes No") (if (eq (getkword "\nProceed to B? [Yes/No]: ") "Yes") (b)) ) @Jonathan Handojo, i tried above code but if select No, it does not end the LISP. But, if i select Yes, it will goto (defun Proposed) without any problem. (defun Existing () ...code (initget 1 "Yes No") (if (eq (getkword "\nProceed to Proposed? [Yes/No]: ") "Yes") (Proposed)) ) (defun Proposed () ..code ) Quote
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.