Monday, October 1, 2012

Programming - How Is It Done?


Programming in AutoLISP is easy. You find a lot of functions in AutoLISP that can be used for performing a lot of tasks. But. There is a complication. Before you start with AutoLISP, you must do some thinking. Even when working with another language. Think first.
You must ask yourself. What is the AutoLISP program supposed to do? Or what is done with the AutoLISP program? If you have an answer to one of these questions, then writing the program is easy. And writing the program is done very quickly. Let me give you an example. Here is an AutoLISP program. It is an AutoLISP program that is used to find a second line.
(defun c:fndol () (start) (drlns) (setq l1 (selln) l2 (fndol l1) ) (redrw l1 l2) (endpr) )
Do you see? There is no real AutoLISP in the program. You see only functions in the program. These are the functions:
1. (start) 
2. (drlns) 
3. (selln) 
4. (fndol) 
5. (redrw) 
6. (endpr)

I will not give an explanation of all the functions. I will not tell how they work. I will do it later. In a new post. But do you see? In the main part of the AutoLISP program you only have functions. Each function performs a task. This is how it is. When we know what needs to be done by the AutoLISP program, then we can start with programming. We can write the program. And trust me. That is not too complicated if you know all the functions and if you can look them up. But that is the trick of any good computer program. Write a function for every actions that is undertaken by the program. As you can see in the listing of the AutoLISP program.
The program works with functions that perform the tasks. Nothing in the main program. That is so good about functions. When programming in AutoLISP, you can test the functions right away. You can see how they work. If you are programming in Visual Basic. Also use functions. Testing them. You can. But first you have to compile the functions. Functions have another advantage. Suppose you are working with a program, any program, and you want to make changes to it. You can find what function is to be changed. And only make the changes to that function. There is no need to search in the program. If you are programming as has been explained here. The programming is much easier. And changes to the program are no big deal. Next I'm going to talk about the AutoLISP program of this post. I will give an explanation of the program. I will tell how it works.

No comments:

Post a Comment