end of teather reached

Discussion in 'AutoCAD' started by spencer1971, Jul 9, 2004.

  1. spencer1971

    spencer1971 Guest

    Ive tried and tried to get this right but siomething in the (progn area is causing a malformed list error.. Tell me i'm stupid if you must but could someone please let me know where im going wrong..

    Many thanks

    Spence

    (defun MyError (strErr)
    (setvar "clayer" clay)
    )
    (defun c:251txt ( / SP EP)
    (if jus1(setq jus1 jus1)
    (setq jus1 "TL")
    )
    (if (< 25MTEXTHT 1)
    (setq 25MTEXTHT (getvar "dimscale"))
    )
    (setq *ERROR* MyError)
    (setq Clay (getvar "clayer"))
    (command "-layer" "m" "025TXT" "")
    (command "-layer" "c" "YELLOW" "" "")
    (PRINC (strcat "\njustification <"JUS1">: "))
    (PRINC (strcat "\ndetail scale <"(rtos 25MTEXTHT)">: "))
    (setq SP "Settings")
    (while (= SP "Settings")
    (initget 1 "Settings")
    (setq SP (getpoint "\nSpecify first corner or enter <S> to change settings "))
    (if (= SP "Settings")
    ;---------------------------------------------------------------------------------------------------
    (PROGN
    (setq 25MTEXTHT (cond
    ((getreal (strcat "\ndetail scale <" (rtos 25MTEXTHT) ">: ")))
    (25MTEXTHT)
    );end setq
    );end cond
    (setq TH (* 25MTEXTHT 2.5))
    (setq jus1 (cond
    (initget 1 "TL TC TR ML MC MR BL BC BR")
    ((getKWORD (strcat "\njustification [ TL/TC/TR/ML/MC/MR/BL/BC/BR ] <" (rtos jus1) ">")))
    (jus1)
    );end setq
    );end cond

    );end progn
    );end if
    ;---------------------------------------------------------------------------------------------------
    (setq EP (getcorner SP "\nSpecify opposite corner: "))
    (command ".MTEXT" SP "H" TH "J" JUS1 EP)
    (setvar "clayer" clay)
    (princ)
    )
     
    spencer1971, Jul 9, 2004
    #1
  2. spencer1971

    rapidcad Guest

    Hi Spencer,
    I hate when this happens - all you need is a closing parenthesis ) at the end..

    Have a nice day (I do things like that to..)
     
    rapidcad, Jul 9, 2004
    #2
  3. possibly no closing ) for the while block?

    peter
     
    petersciganek, Jul 9, 2004
    #3
  4. spencer1971

    spencer1971 Guest

    It still doesn't work, The second setting option to set the justification doesn't appear, Do I need to use the (cond command twice as it is at the moment ? or should i combine the two setting options JUS1 and 25mtextht?
     
    spencer1971, Jul 9, 2004
    #4
  5. spencer1971

    Doug Barr Guest

    I'd say it's your second (cond ...
    It goes straight into the (initget , has no opening paren for the first
    condition.

    causing a malformed list error.. Tell me i'm stupid if you must but could
    someone please let me know where im going wrong..
     
    Doug Barr, Jul 9, 2004
    #5
  6. spencer1971

    spencer1971 Guest

    This is my working version but I am trying to get it to allow a return on the seccond setting option (JUS1) to keep the existing setting...



    (defun MyError (strErr)
    (setvar "clayer" clay)
    )
    (defun c:25txt ( / SP EP)
    (if jus1(setq jus1 jus1)
    (setq jus1 "TL")
    )
    (if (< 25MTEXTHT 1)
    (setq 25MTEXTHT (getvar "dimscale"))
    )
    (setq *ERROR* MyError)
    (setq Clay (getvar "clayer"))
    (command "-layer" "m" "025TXT" "")
    (command "-layer" "c" "YELLOW" "" "")
    (PRINC (strcat "\njustification <"JUS1">: "))
    (PRINC (strcat "\ndetail scale <" (rtos 25MTEXTHT) ">: "))
    (setq SP "Settings")
    (while (= SP "Settings")
    (initget 1 "Settings")
    (setq SP (getpoint "\nSpecify first corner or enter <S> to change settings "))
    (if (= SP "Settings")
    (PROGN
    (setq 25MTEXTHT (cond
    ((getreal (strcat "\ndetail scale <" (rtos 25MTEXTHT) ">: ")))
    (25MTEXTHT)
    ))
    (initget 1 "TL TC TR ML MC MR BL BC BR")
    (setq JUS1 (getKWORD "\njustification [ TL/TC/TR/ML/MC/MR/BL/BC/BR ]"))
    )
    (setq TH (* 25MTEXTHT 2.5))
    )
    )
    (setq EP (getcorner SP "\nSpecify opposite corner: "))
    (command ".MTEXT" SP "H" TH "J" JUS1 EP)
    (setvar "clayer" clay)
    (princ)
    )
     
    spencer1971, Jul 9, 2004
    #6
  7. spencer1971

    Doug Broad Guest

    Spencer,
    Use vlide and the CTRL+] and CTRL+[ to parse
    your code and find the opening and closing parentheses.

    The reason you can't find a solution is perhaps that
    there are several mistakes. Your cond functions are
    not well formed. Typically cond expressions take
    the form:

    (cond ( test result) (test result)...)

    In some cases you are forgetting to enclose the steps
    in in parentheses.

    Your closing comments are deceiving you
    also.

    Hope that helps.


    you must but could someone please let me know where im going wrong..
     
    Doug Broad, Jul 9, 2004
    #7
  8. Doug,

    Take a closer look at the cond statement... I think you will find that it
    works as it should. Spencer is using a cond within the (setq) to set the
    variable either to user input or to the default.

    --
    R. Robert Bell


    Spencer,
    Use vlide and the CTRL+] and CTRL+[ to parse
    your code and find the opening and closing parentheses.

    The reason you can't find a solution is perhaps that
    there are several mistakes. Your cond functions are
    not well formed. Typically cond expressions take
    the form:

    (cond ( test result) (test result)...)
     
    R. Robert Bell, Jul 9, 2004
    #8
  9. spencer1971

    spencer1971 Guest

    Doug,

    Do you know of a good tutorial on using vlide, I have managed up to now without but I am trying more complicated thins and using the checker would make life much easier.
     
    spencer1971, Jul 9, 2004
    #9
  10. spencer1971

    Doug Broad Guest

    Hi Robert,
    Look at his second cond statement:

    [excerpt]
    (setq jus1 (cond
    (initget 1 "TL TC TR ML MC MR BL BC BR")
    ((getKWORD (strcat "\njustification [ TL/TC/TR/ML/MC/MR/BL/BC/BR ] <" (rtos jus1) ">")))
    (jus1)
    );end setq
    );end cond

    [\excerpt]

    At the very least, it should be
    (setq jus1
    (cond
    ((progn
    (initget 1 ...)
    (getkword (....))))
    (jus1)))

    That is, if he is trying to default the value to the previous state of jus1.

    or he could do it with

    (initget 1 ...)
    (setq jus1 (cond ((getkword....)))(jus1)))

    but with the initget occuring as the first condition pair
    it executes as (<test=initget> <return="TL....">)
     
    Doug Broad, Jul 9, 2004
    #10
  11. spencer1971

    Doug Barr Guest

    Hmmm...
    I wasn't aware that progn was required within a cond.
    Is it???
     
    Doug Barr, Jul 9, 2004
    #11
  12. spencer1971

    Doug Broad Guest

    Robert helped me recognize some of the capabilities of VLIDE
    several years ago. Go to VLIDE -> F1 -> Contents tab ->
    Using the Visual LISP Environment->Using the Text Editor ->
    Using Keyboard Shortcuts in the Text Editor....

    The help files cover it pretty well.

    Regards,
    Doug


    the checker would make life much easier.
     
    Doug Broad, Jul 9, 2004
    #12
  13. spencer1971

    Doug Broad Guest

    If the test for that (test result) pair requires several steps,
    in this case (initget...) and (getkword).. then the (progn
    can be used to group them and progn's value is the last
    value in its enclosed statements.

    It could also have been done as

    (setq jus1
    (cond
    ((initget 1 ...)) ;;will fail and drop through since initget always returns nil.
    ((getKWORD (strcat "\njustification [ TL/TC/TR/ML/MC/MR/BL/BC/BR ] <" (rtos jus1) ">")))
    ;;the above statement will always return a non nil value since the initget won't let the drafter
    ;;enter a null answer. It makes me wonder what jus1 is: Here it becomes a string. Where was it a real?
    (jus1)) ;;will never be executed.
    )




     
    Doug Broad, Jul 9, 2004
    #13
  14. spencer1971

    David Kozina Guest

    Doug Broad, PMFJI, see below...

    returns nil.

    Please correct me if I'm wrong, but...

    I am of the current understanding/thinking that this sort of a forced 'fail
    and drop through' method/trick, although it works is actually a 'coding
    horror' that does little more than obscure the program's intent/logic. Even
    worse is that I've done plenty of this sort of thing in the past :-@

    I personally hate (progn...), and try to avoid it wherever I can, but I
    think your original usage (as a cond test) is still more preferrable than
    this.

    Curious as to how others feel about that method...

    Best regards,
    David Kozina
     
    David Kozina, Jul 9, 2004
    #14
  15. Oops. I missed that mistake. I was looking at his prior cond.

    --
    R. Robert Bell


    Hi Robert,
    Look at his second cond statement:

    [excerpt]
    (setq jus1 (cond
    (initget 1 "TL TC TR ML MC MR BL BC BR")
    ((getKWORD (strcat "\njustification [ TL/TC/TR/ML/MC/MR/BL/BC/BR ] <" (rtos
    jus1) ">")))
    (jus1)
    );end setq
    );end cond

    [\excerpt]

    At the very least, it should be
    (setq jus1
    (cond
    ((progn
    (initget 1 ...)
    (getkword (....))))
    (jus1)))

    That is, if he is trying to default the value to the previous state of jus1.

    or he could do it with

    (initget 1 ...)
    (setq jus1 (cond ((getkword....)))(jus1)))

    but with the initget occuring as the first condition pair
    it executes as (<test=initget> <return="TL....">)
     
    R. Robert Bell, Jul 9, 2004
    #15
  16. BTW, I find it easier to double-click on the parens to find the match.

    --
    R. Robert Bell


    Robert helped me recognize some of the capabilities of VLIDE
    several years ago. Go to VLIDE -> F1 -> Contents tab ->
    Using the Visual LISP Environment->Using the Text Editor ->
    Using Keyboard Shortcuts in the Text Editor....

    The help files cover it pretty well.

    Regards,
    Doug


    without but I am trying more complicated thins and using
    the checker would make life much easier.
     
    R. Robert Bell, Jul 9, 2004
    #16
  17. spencer1971

    Doug Broad Guest

    David,
    Good points. I wasn't advocating the drop through
    technique,necessarily. Just showing it as an alternative.
    Either will work fine. From a code maintenance point
    of view, comments are gold if the drop through technique
    is used. Otherwise, it can be hard to read, especially if
    the return value (T or nil) is not related clearly to a test.
    With comments that explain the intent, the drop
    through can work fine and can simplify some things.

    In this case, it would have worked (better?) if he had
    used (initget "...") without the 1 bit code.

    Regards,
    Doug
     
    Doug Broad, Jul 9, 2004
    #17
  18. spencer1971

    Doug Broad Guest

    <sigh_of_relief.wav> I've missed so many things in the
    last week that I welcome the double check from you. ;-)
     
    Doug Broad, Jul 9, 2004
    #18
  19. Thanks for that tip Robert.

    W. Kirk Crawford
    Rochester Hills, Michigan
     
    W. Kirk Crawford, Jul 10, 2004
    #19
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.