Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Working with COND statement - "error: malformed list on input"

  1. #11
    I could stop if I wanted to pbejse's Avatar
    Join Date
    2010-10
    Posts
    414

    Default Re: Working with COND statement - "error: malformed list on input"

    Quote Originally Posted by stusic View Post
    I love how there's so many ways to accomplish a task - I just wish I knew the best ones These snippets are much smoother than the cumbersome, brute-force kind of coding I've got.
    You guys are the best.
    Thank you for your kind words Phillip

    [off topic]

    Neet to remember , there is no single best way to write a code, theres always a better way" some will argue that point, but IMO some codes are better than others depending on the conditions and overall usage.
    Having said that, If you are going to make a career of programming (or like some of us just for the fun of it), choose the one that you understand the most, and in time you yourself will come to realize how silly the code was and say "what was i thinking!"

    [off topic]

    Cheers and keep on coding.

  2. #12
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    N32° 32' 19.08", W-84° 52' 59.03"
    Posts
    1,305

    Default Re: Working with COND statement - "error: malformed list on input"

    Quote Originally Posted by pbejse View Post
    Thank you for your kind words Phillip

    [off topic]

    Neet to remember , there is no single best way to write a code, theres always a better way" some will argue that point, but IMO some codes are better than others depending on the conditions and overall usage.
    Having said that, If you are going to make a career of programming (or like some of us just for the fun of it), choose the one that you understand the most, and in time you yourself will come to realize how silly the code was and say "what was i thinking!"

    [off topic]

    Cheers and keep on coding.
    That's very motivating. I'm not a good programmer at all (never was), but I'm in a position that I need to do what I can, frequently tasked with solving problems that require programming that's over my head. Often, the help I get from volunteers here and elsewhere really open my eyes to how the code is put together. Even though much of the time my problem gets solved with help, I find I can reuse and repurpose that code for other functions. It's when I run into something that I haven't done before that I really get stuck - especially working with dynamic blocks; I just can't seem to wrap my head around getting into and manipulating the properties of them. I've referenced (and still do) Afralisp, which seems to be the best "from scratch" learning site I've seen, but it's hard to make it stick. It's when I'm actually accomplishing something that I really learn.

    I appreciate everyone's help so much. Without people like you, Renderman, Lee Mac, Cabbie, (and so many others), I'd still be stuck at square one. I wish I could buy you all lunch and a beer. If you're ever in Georgia, give me a shout

    Now to figure out how to iterate through a list...

    Thanks again,

    -p
    Phillip Bradshaw
    Lead Pixel Pusher, Lucid Design Studio
    CAD Administrator, Heatcraft RPD

    A doctor can bury his mistakes but an architect can only advise his clients to plant vines. - Frank Lloyd Wright

  3. #13
    Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    2,494

    Default Re: Working with COND statement - "error: malformed list on input"

    Quote Originally Posted by stusic View Post
    I just can't seem to wrap my head around getting into and manipulating the properties of them. I've referenced (and still do) Afralisp, which seems to be the best "from scratch" learning site I've seen, but it's hard to make it stick. It's when I'm actually accomplishing something that I really learn.
    Afra LISP is great; I've also learned much from completing 200+ Autodesk University courses, members here at this and other forums, but mostly from attempting to code an initiative and personally digging through the developer documentation, trial and error, etc..

    ... Admittedly, the latter would have taken me much, much longer without the kindness of many, many others who took the time to help point me in the right direction. That is why I try to give back where I can; helping others solidifies my knowledge, and exposes me to others' ideas in a way that only a venue such as these forums permits, in my limited experience.

    Making the jump from AutoLISP syntax to that of Visual LISP, or other application level languages, such as C#/VB.NET, etc., you must understand Object Oriented Programming (OOP) Concepts. OOP is the key to better understanding the Objects which makeup the entities, interfaces, and applications that we use every day, both in, and out of CAD.

    I think you'll find that your aptitude for programming will rapidly increase as you progress with some minimal, fundamental concepts.

    Quote Originally Posted by stusic View Post
    I appreciate everyone's help so much. Without people like you, Renderman, Lee Mac, Cabbie, (and so many others), I'd still be stuck at square one. I wish I could buy you all lunch and a beer. If you're ever in Georgia, give me a shout
    We're happy to help.

    You are very kind to even mention me, as I am still very much a student of programming myself... I jokingly, yet honestly say that I didn't even know what a 'Defun' was 2-3 years ago. I have much to learn about Visual LISP, let alone attempting to teach myself to develop in .NET languages.

    Quote Originally Posted by stusic View Post
    Now to figure out how to iterate through a list...
    ... Why, just use FOREACH, silly. LoL
    "Potential has a shelf life." - Margaret Atwood

  4. #14
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    N32° 32' 19.08", W-84° 52' 59.03"
    Posts
    1,305

    Default Re: Working with COND statement - "error: malformed list on input"

    Quote Originally Posted by RenderMan View Post
    ... Why, just use FOREACH, silly. LoL
    That's why you were included.
    Phillip Bradshaw
    Lead Pixel Pusher, Lucid Design Studio
    CAD Administrator, Heatcraft RPD

    A doctor can bury his mistakes but an architect can only advise his clients to plant vines. - Frank Lloyd Wright

  5. #15
    Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    2,494

    Default Re: Working with COND statement - "error: malformed list on input"

    Quote Originally Posted by stusic View Post
    That's why you were included.
    *Tips hat*
    "Potential has a shelf life." - Margaret Atwood

  6. #16
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    N32° 32' 19.08", W-84° 52' 59.03"
    Posts
    1,305

    Default Re: Working with COND statement - "error: malformed list on input"

    Quote Originally Posted by pbejse View Post
    you could write it this way
    Code:
    (if (setq fld4     
    	     (cond
    	       ((= a 10) (substr fld2 9))
    	       ((= a 11) (substr fld2 9))
    	       ((= a 12) (substr fld2 11))
    	       ((= a 13) (substr fld2 11 )))) fld4
            	(print "Drawing Number Format Unrecognized")
           )
    I was trying to do this, but it just ain't working. Get "Drawing Number Format Unrecognized" ; error: bad argument type: consp nil

    Code:
    (setq dn (getvar "dwgname"))
    
    (if (setq fld4     
    	     (cond
    	       ((= a 10) (substr dn 9))
    	       ((= a 11) (substr dn 9))
    	       ((= a 12) (substr dn 11))
    	       ((= a 13) (substr dn 11 )))) fld4
            	(print "Drawing Number Format Unrecognized")
           )
    Any ideas? I looked over and over at the syntax, but it seems fine to me...

    Thank you
    Phillip Bradshaw
    Lead Pixel Pusher, Lucid Design Studio
    CAD Administrator, Heatcraft RPD

    A doctor can bury his mistakes but an architect can only advise his clients to plant vines. - Frank Lloyd Wright

  7. #17
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    N32° 32' 19.08", W-84° 52' 59.03"
    Posts
    1,305

    Default Re: Working with COND statement - "error: malformed list on input"

    Modified it after I posted, but still get an error.

    "error: bad argument type: stringp 17"

    Code:
    (setq dn (strlen (getvar "dwgname")))
    
    (if (setq fld4     
    	     (cond
    	       ((= dn 14) (substr dn 9))
    	       ((= dn 15) (substr dn 9))
    	       ((= dn 16) (substr dn 11))
    	       ((= dn 17) (substr dn 11)))) fld4
            	(print "Drawing Number Format Unrecognized")
           )
    Do I need to specify that I'm looking for the strlen in the cond statement? If I don't, wouldn't it be looking for whether the actual string is "17"?
    Nevermind, the variable dn IS 17...
    Phillip Bradshaw
    Lead Pixel Pusher, Lucid Design Studio
    CAD Administrator, Heatcraft RPD

    A doctor can bury his mistakes but an architect can only advise his clients to plant vines. - Frank Lloyd Wright

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 16
    Last Post: 2011-03-01, 02:25 PM
  2. error: malformed string on input
    By Bear31831 in forum AutoCAD General
    Replies: 2
    Last Post: 2010-01-26, 01:57 PM
  3. Replies: 5
    Last Post: 2009-04-17, 10:10 AM
  4. Replies: 8
    Last Post: 2007-04-04, 12:39 PM
  5. Please explain how LISP function "cond" works
    By ccowgill in forum AutoLISP
    Replies: 11
    Last Post: 2006-11-18, 07:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •