Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Martti Halminen
Message 11 of 13 (49 Views)

Re: if or cond statements

01-20-2009 04:03 AM in reply to: *djohnson
djohnson wrote:
> im needing to put an if statement, or cond (not sure which one or both) in and have no idea how to
> make it work.
> i tried this
>
> (if ((< px1 qx1)(< py1 qy1)) sym1))


Others have already talked about IF and COND, I'd like to comment on two
beginner's mistakes your initial code is showing:

1. The parentheses must balance. Unless you are closing some larger
piece of program not shown here, you have one closing parenthesis too
much on each line.

2. Unlike many other programming languages, you may not add arbitrary
parentheses anywhere you like to combine clauses. You need to use some
special operators to connect stuff, for example AND, OR etc. PROGN is
also often useful, though meaningless in a test.

(if (and (< px qx1)(< py1 qy1)) sym1)

--
*djohnson
Message 12 of 13 (49 Views)

Re: if or cond statements

01-20-2009 07:54 AM in reply to: *djohnson
thanks Martti

I do seem to have trouble counting the parens, but I do know they need to equal.
Im still struggling with the special operators but can see how vital they are to getting things
accomplished in the routine.


--
Dave C. Johnson
*Martti Halminen
Message 13 of 13 (49 Views)

Re: if or cond statements

01-21-2009 01:03 AM in reply to: *djohnson
djohnson wrote:
> thanks Martti
>
> I do seem to have trouble counting the parens, but I do know they need to equal.
> Im still struggling with the special operators but can see how vital they are to getting things
> accomplished in the routine.

The trick with counting parens is getting the computer to do that for
you: find an editor that can show the matching parens and can indent the
code according to syntax. Professionals read Lisp code based on the
indentation, not the parens.

The best editor for Lisp work I know is GNU Emacs, but even VLIDE is
better than nothing.

--
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.