From the course: Learning AutoLISP & Visual LISP

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Function: while

Function: while

- [Instructor] One of the benefits of automation and writing code is that we're able to complete redundant and monotonous tasks quite easily. We do this by using functions that will loop through different activities until they're done, in some way. We're going to start with a function that loops through while a specific condition equals true. The function while. So let's go ahead and create this function. We're going to say while this variable object sel equals nil, continue to run or loop through everything that's inside the while list. What we'll put in the while list, prompting the user to select an object and if the user chooses not to, presses enter, objsel is set to nil, and they're going to be prompted again so let's go ahead and see how this works. If I just run this, the user can press enter, it returns nil, everything is fine, but if we look at this entire package together, we can inspect more than one line, so we're going to load the selection, the user presses enter, and…

Contents