Import, include autolisp source code into another autolisp code

Import, include autolisp source code into another autolisp code

scadcam
Contributor Contributor
522 Views
4 Replies
Message 1 of 5

Import, include autolisp source code into another autolisp code

scadcam
Contributor
Contributor

Hi,

I have several utilities that share code.

I´d like to have file c.lsp with common functions to be imported into say files a.lsp and b.lsp.

How can you do it?

 

Regards

 

 

0 Likes
Accepted solutions (3)
523 Views
4 Replies
Replies (4)
Message 2 of 5

diagodose2009
Collaborator
Collaborator
Accepted solution

Many developers AutoLisp unknown.  they need upgrade the many Lisp-programs onto the Applet.Jc,with-Lisp.source.

😅Very easy, you can store all program/s with Source100%AutoLisp inside Pkzip,but the name of programs are very important for togheter constructor.lisp

This program is  freeware 😴if you want the last-vesion of kit  with help from us, then you .***...

(gmouse.com "Please you accept The GNU General Public License (GNU GPL or simply GPL) is a series of... 

Message 3 of 5

martti.halminen
Collaborator
Collaborator
Accepted solution

 

Every Lisp function loaded into the Lisp environment of a drawing is visible to all the other functions, so loading a.lsp, b.lsp and c.lsp would mean that anything defined in c.lsp is usable in b.lsp  and a.lsp without any importing.

 

So think of the files as a device for loading several definitions at once, but after loading all those definitions are in one flat namespace with no knowledge of which file they originated in.

 

- also means that if you have a definition with the same name in several files, the one loaded last is the only one in existence at runtime after that.

 

You can see what this means in practice by calling the function ATOMS_FAMILY.

Message 4 of 5

Sea-Haven
Mentor
Mentor
Accepted solution

It is very easy to load a lisp from a lisp, I have 3 multi dialouge lisps that I use all the time now they are library routines for use in any code. I just demand load when required. A simple If not test. 

 

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= but nil)(setq but 1))
(setq ans (atoi(ah:butts but "V" '("Choose a number" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10")))) 
; ans holds the button picked as an integer value

 

 

Message 5 of 5

scadcam
Contributor
Contributor

Thanks Sea-Haven, Martti_Halminen and diagodose2009 for taking the time to explain me a way to solve my issue.

Regards,

Hector

0 Likes