getkword fraction to real

Discussion in 'AutoCAD' started by johnhatfield, Jul 22, 2004.

  1. johnhatfield

    johnhatfield Guest

    Hello,

    I am trying to use the getkword function to allow a user to enter a string such as 3/8 7/16 1/2 and then depending on which one is chosen, set a "real" variable equal to the following:

    3/8 = 10.0
    7/16 = 20.0
    1/2 = 30.0

    I believe a "cond" statement is the way to go, but I am not sure how to use the 'str function correctly or if this is the correct way to do it. I have some basic code that I got from another post, but I am stuck as to how to get the rest accomplished.

    Thanks in advance for your assistance.

    John Hatfield

    (defun SIZE (/)
    (cond ((= SZ1 nil) (setq SZ1 12)))
    (initget "38 716 12")
    (setq SZ2 (getkword (strcat "\nEnter The Size [38/716/12] <" (rtos SZ1) ">: "))
    SZ1 (cond (SZ2 (atof SZ2)) (SZ1)))
    );end SIZE defun
     
    johnhatfield, Jul 22, 2004
    #1
  2. johnhatfield

    Jim Claypool Guest

    (initget "3/8 7/16 1/2")
    (setq sz (getkword "[3/8 7/16 1/2]: "))
    (setq sz
    (cond
    ((= sz "3/8") 10.0)
    ((= sz "7/16") 20.0)
    ((= sz "1/2") 30.0)
    )
    )

    such as 3/8 7/16 1/2 and then depending on which one is chosen, set a "real"
    variable equal to the following:
    use the 'str function correctly or if this is the correct way to do it. I
    have some basic code that I got from another post, but I am stuck as to how
    to get the rest accomplished.
     
    Jim Claypool, Jul 22, 2004
    #2
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.