Author Topic: If "edit_box" if nil , press "ok" ,can't quit  (Read 1770 times)

0 Members and 1 Guest are viewing this topic.

andy_lee

  • Newt
  • Posts: 147
If "edit_box" if nil , press "ok" ,can't quit
« on: July 16, 2015, 01:12:54 PM »
Dear all

I want
if the 'edit_box " is nil (no input any string)
press "ok" button , can't quit, press"cancel" button  can quit.

Code: [Select]
  (setq dcl_file (load_dialog fname) dd 3)
  (while
  (or (not (= nom nil)) (= dd 3))
  (new_dialog "mydcl" dcl_file)
  (action_tile "eb1" "(setq nom $value)")
  (action_tile "ok" "(setq nom (get_tile \"eb1\")) (done_dialog 1)")
  (action_tile "cancel" "(done_dialog 0)")
  (mode_tile "eb1" 2)
  (setq dd (start_dialog))
  );;_end_while
  (unload_dialog dcl_file)
  (vl-file-delete fname)
   (cond
((= dd 1)(test1))
((= dd 0)(test2))
(t)
  )

But ,use above code. I Enter string to edit_box  or keep nil , press "ok" or "cancel" ,can't quit ,  All operations can't quit 

I changed   (or (not (= nom nil)) (= dd 3))  ==to=>  (or  (= nom nil) (= dd 3))    , if edit_box nil , still can quit .

Depressed .....
andy.
Best regards.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: If "edit_box" if nil , press "ok" ,can't quit
« Reply #1 on: July 16, 2015, 01:21:09 PM »
No need for while

Code - Auto/Visual Lisp: [Select]
  1. (setq dcl (load_dialog fname))
  2. (new_dialog  "mydcl" dcl)
  3. (action_tile "eb1"    "(setq nom $value)")
  4. (action_tile "accept" "(if (and nom (/= "" nom)) (done_dialog 1))")
  5. (if (= 1 (start_dialog))
  6.     (test1)
  7.     (test2)
  8. )

andy_lee

  • Newt
  • Posts: 147
Re: If "edit_box" if nil , press "ok" ,can't quit
« Reply #2 on: July 16, 2015, 08:45:33 PM »
No need for while

Code - Auto/Visual Lisp: [Select]
  1. (setq dcl (load_dialog fname))
  2. (new_dialog  "mydcl" dcl)
  3. (action_tile "eb1"    "(setq nom $value)")
  4. (action_tile "accept" "(if (and nom (/= "" nom)) (done_dialog 1))")
  5. (if (= 1 (start_dialog))
  6.     (test1)
  7.     (test2)
  8. )

Thanks a lot , Lee,  It's concise. But
interrupt at : (action_tile "accept" "(if (and nom (/= "" nom)) (done_dialog 1))")

error Too many parameters .....

Maybe like this :
Code - Auto/Visual Lisp: [Select]
  1. (action_tile "accept"  "(if (and nom (/= \"\" nom))(done_dialog 1))")
  2.  
« Last Edit: July 16, 2015, 10:56:37 PM by emk2012 »
andy.
Best regards.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: If "edit_box" if nil , press "ok" ,can't quit
« Reply #3 on: July 17, 2015, 04:22:53 AM »
No need for while

Code - Auto/Visual Lisp: [Select]
  1. (setq dcl (load_dialog fname))
  2. (new_dialog  "mydcl" dcl)
  3. (action_tile "eb1"    "(setq nom $value)")
  4. (action_tile "accept" "(if (and nom (/= "" nom)) (done_dialog 1))")
  5. (if (= 1 (start_dialog))
  6.     (test1)
  7.     (test2)
  8. )

Thanks a lot , Lee,  It's concise. But
interrupt at : (action_tile "accept" "(if (and nom (/= "" nom)) (done_dialog 1))")

error Too many parameters .....

Maybe like this :
Code - Auto/Visual Lisp: [Select]
  1. (action_tile "accept"  "(if (and nom (/= \"\" nom))(done_dialog 1))")
  2.  

Good catch - I hadn't tested my code.  :-)