Jump to content

Recommended Posts

Posted

If you don't include anything after the if statement, your LISP will end there. What do you mean?

Posted

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).

0.PNG

Posted

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")
  )

 

  • Thanks 1
Posted
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.

Posted
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)
  )

 

 

Posted
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......

Posted

@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?

Posted
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)

 

  • Thanks 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...