Help with a INITGET

Help with a INITGET

msarqui
Collaborator Collaborator
562 Views
3 Replies
Message 1 of 4

Help with a INITGET

msarqui
Collaborator
Collaborator

Hi guys, 

 

Could someone help me please?

I trying to make a INITGET to return to the previous page, but it is not working...

 

(defun InitYesNo ( / return yesno)
(setq return (getvar "ctab"))
;;;...my routine will change the layout page here...
(initget "Yes No")
(setq yesno (cond ((getkword (strcat "\n  **  Would you like to return to <"return"> page? [Yes/No] <Yes>: **")) ( "Yes" ))))
(cond
	((eq yesno "Yes")
		(setvar "ctab" return)
	)
	((eq yesno "No")
		(exit)
		)
);cond
)


Thanks.

Marcelo

0 Likes
Accepted solutions (1)
563 Views
3 Replies
Replies (3)
Message 2 of 4

paullimapa
Mentor
Mentor

Try this:

 

(defun InitYesNo ( / return yesno)
(setq return (getvar "ctab"))
;;;...my routine will change the layout page here...
(initget "Yes No")
(setq yesno (getkword (strcat "\n  **  Would you like to return to <"return"> page? [Yes/No] <Yes>: **")))
(if(not yesno)(setq yesno"Yes"))
(cond
    ((eq yesno "Yes")
        (setvar "ctab" return)
    )
    ((eq yesno "No")
        (exit)
        )
);cond
)

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

@msarqui wrote:

Hi guys, 

 

Could someone help me please?

I trying to make a INITGET to return to the previous page, but it is not working...


You have wrong parentheses inside of cond... Your (getkwork) is the test and if this is nil (means hit ENTER) then it goes for another test (there is none in your code) and your "Yes" result is missed. So the solutions is to have "Yes" as another test function.

 

(defun InitYesNo ( / return yesno)
  (setq return (getvar "ctab"))
  ;;;...my routine will change the layout page here...
  (initget "Yes No")
  (setq yesno (cond ((getkword (strcat "\n  **  Would you like to return to <"return"> page? [Yes/No] <Yes>: **")))
		    ("Yes")));)
  (cond
    ((eq yesno "Yes")
     (setvar "ctab" return)
     )
    ((eq yesno "No")
     (exit)
     )
    );cond
)

 

But you can simplify it a lot using test for "No"

 

(defun InitYesNo ( / return)
  (setq return (getvar "ctab"))
  ;;;...my routine will change the layout page here...
  (initget "Yes No")
  (if (= "No" (getkword (strcat "\n  **  Would you like to return to <"return"> page? [Yes/No] <Yes>: ")))
    (exit)
    (setvar "ctab" return)
  ) ;if
)  

 

0 Likes
Message 4 of 4

msarqui
Collaborator
Collaborator

Thanks guys

And thanks BeekeeCZ for the explanation. It was realy helpful. Smiley Wink

0 Likes