DCL *enter* key...?

Discussion in 'AutoCAD' started by Scrutch, Jul 1, 2004.

  1. Scrutch

    Scrutch Guest

    Given the following snipets, can anyone explain how I
    can use the *enter* key to exit the dialog and run the
    routine.

    DCL:
    : edit_box {
    label = "Shell Length";
    mnemonic = "S";
    key = "sl";
    }
    : edit_box {
    label = "Diameter";
    mnemonic = "D";
    key = "od";
    }

    LISP:
    (action_tile "sl" "(setq len (distof
    (get_tile \"sl\") ) ) ")
    (action_tile "od" "(setq dia (distof
    (get_tile \"od\") ) ) ")

    WHAT I WANT TO DO:
    (if
    (and
    (> len 0.0)
    (> dia 0.0)
    )
    ;//ALLOW ENTER KEY TO BE USED...
    ;//{while inside Diameter edit box}
    )
    I have about six of these if/and statements to make and
    they will be getting longer and longer to verify that the
    user has entered data in the edit boxes. What's the best
    way to handle this if I have six different (> dia 0.0) guys
    to verify before allowing the *enter* key to exit the DCL?

    I have an ok_cancel that's in a Row at the bottom of the
    dialog box (have some other buttons on this row) and
    it won't allow the *allow_accept = true;* Gives me an
    error about being a child that is homeless...because of
    the Row thing. I've tried to put the *allow_accept = true;*
    in the Diameter definition in the DCL but then it allows
    the enter key to be used without having to enter any of
    the necessary data.

    Cheers,
    Scrutch
     
    Scrutch, Jul 1, 2004
    #1
  2. Scrutch

    ECCAD Guest

    ;; Hang in there until it's OK to exit..
    (setq wha_next 7)
    (while (/= 4 wha_next)
    (action_tile "assy_box" "(setq DEV_ID_STR $value)(check_id)(done_dialog 1)")
    (action_tile "accept" "(setq change_id 1)(check_id)(done_dialog 4)")
    (action_tile "cancel" "(setq Dia_Abort 1)(setq change_id 0)(done_dialog 4)")
    (setq wha_next (start_dialog))
    (cond
    ( (= wha_next 1)(new_dialog "get_devid" dcl_id)(check_id)(show_sample) )
    ( (= wha_next 4)(check_id) )
    ); end cond
    ); end while wha_next

    ;; See action for 'assy_box'..place your defun in there (check_id)..

    Bob
     
    ECCAD, Jul 1, 2004
    #2
  3. Scrutch

    Scrutch Guest

    Thanks Bob,
    I think...<g>

    Most of this just went about 32 1/4 inches over my head...
    I'll start digging on it and see if I can make sense of it all. I
    couldn't find anything on the *assy_box* but I'll keep looking.
     
    Scrutch, Jul 1, 2004
    #3
  4. Scrutch

    Rudy Tovar Guest

    Example:
    ======

    (defun C:MODIFY ( / dcl_id co)
    (setq dcl_id (load_dialog "modify.dcl"))
    (if (not (new_dialog "main0" dcl_id)) (exit))

    (action_tile "button0" "(setq co 1)(done_dialog)")
    (start_dialog)
    (unload_dialog dcl_id)
    (if (= co 1)
    (progn
    (do_this);enter your code here
    (or_do_that);enter more here, etc.
    )
    )
    (princ)
    )

    (defun do_this (/)
    ;etc.
    (princ)
    )
    (defun or_do_that (/)
    ;etc
    (princ)
    )
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Jul 1, 2004
    #4
  5. Scrutch

    ECCAD Guest

    No, you won't find 'assy_box', just is a tile name I have in the example..The code just illustrates how to stay in the dialog box, until you want to exit..I will explain a line at a time..

    ; set wha_next to any number, just for while loop ..
    (setq wha_next 7)
    ; While the 'wha_next' variable is NOT a 4..
    (while (/= 4 wha_next)
    ; For a given tile action..this case tile 'assy_box' ..
    ; Setq 'dev_id_str' (just a variable) to the value..and
    ; jump out and do a 'function' called "check_id" - defined somewhere in your code..and set done_dialog 1 sets the value of wha_next to a 1..still not a 4, so no exit yet
    (action_tile "assy_box" "(setq DEV_ID_STR $value)(check_id)(done_dialog 1)")
    ; if accept (enter key)..set the variable 'change_id' to a 1, and
    ; branch out to function 'check_id'. Then exit..with a 4
    (action_tile "accept" "(setq change_id 1)(check_id)(done_dialog 4)")
    ; if cancel, set var Dia_Abort to a 1, and set var change_id to a 0..
    ; and then exit with a 4
    (action_tile "cancel" "(setq Dia_Abort 1)(setq change_id 0)(done_dialog 4)")
    ; next line sets the variable 'wha_next' to whatever 'exit' value
    ; (done_dialog 4)..would set it to a 4...
    (setq wha_next (start_dialog))
    ;; On exit, check exit code number..and do whatever..
    (cond
    ( (= wha_next 1)(new_dialog "get_devid" dcl_id)(check_id)(show_sample) )
    ( (= wha_next 4)(check_id) )
    ); end cond
    ); end while wha_next

    I hope this helps you.
    Bob
     
    ECCAD, Jul 1, 2004
    #5
  6. Scrutch

    Scrutch Guest

    Thanks Bob and Rudy,

    Comments helped a bunch in the code you supplied Bob. I just didn't realize that I could make a name up like 'assy_box' if it hadn't been defuned or defined...?

    I'm assuming that the 'check_id' would be where I define the (< a 0.0) (>b 0.0) guys and have this loop get the required information from this guy...? Is there a clean and easy way for me to define this information when I have about six or more of these (> a 0.0) (> b 0.0) (> c 0.0)... guys? They would all have to be greater than 0.0 before I would consider them to be a green light.

    Many Thanks to You and Rudy for diving right in there...
    Cheers,
    Scrutch
     
    Scrutch, Jul 1, 2004
    #6
  7. Scrutch

    ECCAD Guest

    Yup,
    You got the picture..carry on..

    :)

    Bob
     
    ECCAD, Jul 1, 2004
    #7
  8. Scrutch

    ECCAD Guest

    About the 'easiest'..most readable..
    (if (and
    (> a 0.0)
    (> b 0.0)
    (> c 0.0)
    ...
    ); end and
    (setq flag 1)
    (setq flag 0)
    ); end if

    Bob
     
    ECCAD, Jul 1, 2004
    #8
  9. Scrutch

    Scrutch Guest

    Dang, that's simple enough... I was trying to make it much more difficult than that. <g>

    What and where would I use the flag values for...?
     
    Scrutch, Jul 1, 2004
    #9
  10. Scrutch

    Scrutch Guest

    Hang on a bit...I'm having a dumb spell right smack dab in the middle of a stupid attack...

    I can use the flag values to tell the routine to do the enter key thing if the value is 1 but if it's 0 then don't push the key...

    Duh...
     
    Scrutch, Jul 1, 2004
    #10
  11. Scrutch

    ECCAD Guest

    Yes, and also..
    (setq Flag 0)
    just before:
    (setq wha_next 7)

    Bob
     
    ECCAD, Jul 1, 2004
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.