PDA

View Full Version : Dialog box should disappear after five input attempts


Adesu
2006-11-29, 07:32 AM
Hi Moderator and others,
I have a code,if user put a name in dialog box,and until 5 times it wrong,the dialog box could disappeared in drawing area,but fact my code still got trouble to do it,maybe over there,anyone have time to correction my code,where location am I did wrong,I very apreaciated for your help,thanks.
Here lisp file

; lnm is stand for Login Name Manager
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 29 November 2006
; Program no.: 0476/11/2006
; Edit by :
; ***** UNDER CONSTRUCTION *****

(defun c:lnm (/ ans cnt)
(setq dcl_id (load_dialog "Login Name Manager.dcl"))
(if
(not (new_dialog "lnm" dcl_id))
(exit)
) ; if
(set_tile "eb" "Abc")
(mode_tile "eb" 2)
(action_tile "eb" "(setq nam (get_tile \"eb\"))")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)(exit)")
(setq ans (start_dialog))
(if
nam
(progn
(if (= nam "")(c:lnm))
(if
(or (= nam "Adesu")(= nam "adesu"))
(progn
(alert (strcat "\nYou are right !!!"
"\n"
"\nMy name is "
"\n"
"\n" nam))
(exit)
) ; progn
) ; if
(setq cnt 0)
(while
(and (< cnt 5)(not (eq nam "Adesu"))(not (eq nam "adesu")))
(setq lst (append lst (list nam)))
(setq len (length lst))
(if
(= len 5)
(command "_quit")
) ; if
(setq cnt (1+ cnt))
(c:lnm)
) ; while
) ; progn
) ; if
(princ)
) ; defun

Here dcl file

// lnm is for Login Name Manager
lnm : dialog {label = "LOGIN NAME MANAGER";
: column {label = "Enter your name here";
: edit_box {key = "eb";}}
ok_cancel;}

madcadder
2006-11-29, 02:28 PM
Sorry I can not provide more at this time, but I did notice a couple things just looking.
I will have more time later this morning.

I don't think you call call LNM from inside LNM.

Separate out what you are trying to do into groups.

make a DEFUN just to use the dialog box
make a DEFUN to save the information from the dialog box
Use the main DEFUN, listed last, to call the previous two and run the IF.

Adesu
2006-11-30, 07:16 AM
Hi,
I just got it how to quit autocad,if user wrong input her name until 5 times,here that code after I revised

; lnm is stand for Login Name Manager
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 29 November 2006
; Program no.: 0476/11/2006
; Edit by : Adesu 30/11/2006 1). alls

(defun c:lnm (/ cnt len lst_str rtn str)
(setq str (dos_getstring "LOGIN NAME MANAGER" "Enter your name here"))
(if
(or (= str "Adesu")(= str "adesu"))
(progn
(alert (strcat "\nYou are right !!!"
"\n"
"\nMy name is "
"\n"
"\n" str))
(exit)
) ; progn
) ; if
(setq cnt 1)
(setq rtn 10)
(repeat
rtn
(if
(and (not (eq str "Adesu"))(not (eq str "adesu")))
(progn
(setq lst_str
(append lst_str
(list (dos_getstring "LOGIN NAME MANAGER" "Enter your name here"))))
(setq len (length lst_str))
(if
(= len 4)
(command "_quit")
) ; if
(setq cnt (1+ cnt))
) ; progn
) ; if
) ; repeat
(princ)
) ; defun


Hi Moderator and others,
I have a code,if user put a name in dialog box,and until 5 times it wrong,the dialog box could disappeared in drawing area,but fact my code still got trouble to do it,maybe over there,anyone have time to correction my code,where location am I did wrong,I very apreaciated for your help,thanks.
Here lisp file

; lnm is stand for Login Name Manager
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 29 November 2006
; Program no.: 0476/11/2006
; Edit by :
; ***** UNDER CONSTRUCTION *****

(defun c:lnm (/ ans cnt)
(setq dcl_id (load_dialog "Login Name Manager.dcl"))
(if
(not (new_dialog "lnm" dcl_id))
(exit)
) ; if
(set_tile "eb" "Abc")
(mode_tile "eb" 2)
(action_tile "eb" "(setq nam (get_tile \"eb\"))")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)(exit)")
(setq ans (start_dialog))
(if
nam
(progn
(if (= nam "")(c:lnm))
(if
(or (= nam "Adesu")(= nam "adesu"))
(progn
(alert (strcat "\nYou are right !!!"
"\n"
"\nMy name is "
"\n"
"\n" nam))
(exit)
) ; progn
) ; if
(setq cnt 0)
(while
(and (< cnt 5)(not (eq nam "Adesu"))(not (eq nam "adesu")))
(setq lst (append lst (list nam)))
(setq len (length lst))
(if
(= len 5)
(command "_quit")
) ; if
(setq cnt (1+ cnt))
(c:lnm)
) ; while
) ; progn
) ; if
(princ)
) ; defun

Here dcl file

// lnm is for Login Name Manager
lnm : dialog {label = "LOGIN NAME MANAGER";
: column {label = "Enter your name here";
: edit_box {key = "eb";}}
ok_cancel;}