DCL and Fractions

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

  1. Scrutch

    Scrutch Guest

    Hi,

    Would someone be kind enough to write the Lisp and DCL code to process a fraction or a real number, depending on what the user entered. I have an edit box in the DCL and can get it to work with a real number but haven't found the right combination to make it work if a fraction is entered.
    Works with 0.375
    Doesn't work with 3/8

    Thanks for any and all help with this,
    Scrutch
     
    Scrutch, Jun 1, 2004
    #1
  2. Try distof

    (distof "3-3/8") returns 3.375
     
    Allen Johnson, Jun 1, 2004
    #2
  3. Scrutch

    BillZ Guest

    You need a double backslash for \ and an escape character for ".

    (set_tile "frac" "1-3\\4\"")

    will work fir 1-3/4"

    Bill
     
    BillZ, Jun 1, 2004
    #3
  4. Scrutch

    Rudy Tovar Guest

    It depends on the units.

    And also dimzin.

    You can for the value to remain in any given value.

    But the best way is to combine the Lprec and Lunits, and dimzin.

    You'll find that if the right combination is not used that it doesn't matter
    if you use
    'distof'.
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi




    fraction or a real number, depending on what the user entered. I have an
    edit box in the DCL and can get it to work with a real number but haven't
    found the right combination to make it work if a fraction is entered.
     
    Rudy Tovar, Jun 1, 2004
    #4
  5. Huh?
     
    Allen Johnson, Jun 1, 2004
    #5
  6. Scrutch

    Scrutch Guest

    Ok... Thanks for the ideas but I still haven't got it to work.
    Here's a test file of what I'm trying to get. Entering a real number (1.375) returns the correct value but if I enter a fraction (3/8 OR 1-3/8) I can't get it to work. I have no problems converting fractions in lisp but I'm missing something when I try to use the DCL...

    Scrutch
     
    Scrutch, Jun 1, 2004
    #6
  7. (action_tile "input" "(print (setq output (distof (get_tile
    \"input\") ) ))")
     
    Allen Johnson, Jun 1, 2004
    #7
  8. Scrutch

    Scrutch Guest

    Allen,

    I thought I tried the exact same thing you show but must have typed the disof wrong or something. This works... Looks like there are several different ways to do this though...<g>

    Thanks Allen,
    Scrutch
    PnS... Lookie at my distof above and I think that's probably what I tried before... Duh!
     
    Scrutch, Jun 1, 2004
    #8
  9. Scrutch

    Rudy Tovar Guest

    No offense intended, but personally, I'd write it different.

    (setup_default_values)

    (set_tile "input" default_val)

    (action_tile "input" "(validate_value)")

    (defun validate_value (/)
    (setq val (distof $value))
    (do_what_ever...)
    (princ)
    )

    (defun setup_default_values (/)
    (Open "defauts.txt" "r")
    (do_what_ever)
    (vl-registry-read "HKEY_LOCAL_MACHINE\\SOFTWARE\etc." def_val1)
    (do_what_ever)
    ;etc.etc.etc.
    (princ)
    )

    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Jun 1, 2004
    #9
  10. Personally I'D write it something like:

    (action_tile "input" "(validate_value $value)")

    and

    (defun validate_value ( val )
    (setq val (distof val))
    (do_what_ever...)
    (princ)
    )
     
    Allen Johnson, Jun 1, 2004
    #10
  11. Scrutch

    Rudy Tovar Guest

    The sorter the better, but you may want to setup individual edit_boxes and
    define given to_do's also in one [Enter].

    (action_tile "edit1" "(validate_values)")

    (defun validate_values (/)
    (do_what_ever)
    (set_tile "edit1" "(validated_value_or_return_value)")
    (mode_tile "whatever" 1/0)
    (set_tile "slider" "etc.")
    (Alert "That_value_not_allowed_I'd_personally_add_it_to_the_validate_val")
    (etc.etc.etc.....the..combinations...are..endless)
    (princ)
    )
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Jun 1, 2004
    #11
  12. Scrutch

    Rudy Tovar Guest

    excuse my typo.....oooppsss....

     
    Rudy Tovar, Jun 1, 2004
    #12
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.