I have used set in some programs.
Here is a tricky one.
This function is a generalized error trap. It can "wrap" a function and catch an error if one occurs and will return a nil when an error has occurred.
Like (vla-item colLayers "TEST") should return a the layer object corresponding to the "TEST" layer.
If there isn't a "TEST" layer it will crash.
so
(errortrap (quote (vla-item colLayers "TEST"))) would not crash and just return a nil. It would return the layer object if successfull.
The trick to using the set function is that when you use the vl-catch-all-apply you need to supply a list of arguments to apply the function to.
In this example, the argument that is passed is the result!
In order to do this you need the SET function!
Set is cool.
By the way it was nice to meet you face to face at AU Mark!
Peter Jamtgaard
; Standardized Error Trap
(defun ErrorTrap (symFunction / objError result)
(if (vl-catch-all-error-p
(setq objError (vl-catch-all-apply
'(lambda (X)(set X (eval symFunction)))
(list 'result))))
(progn
(if DEBUG
(progn
(princ "\n")
(princ (vl-catch-all-error-message objError))
(princ "\nWhile evaluating the expression: ")
(princ symfunction)
(princ "\n")
)
)
nil
)
(if result result 'T)
)
)