Jump to content

Many Lisp files combine in one Lisp file...


CAD USER
 Share

Recommended Posts

I have so many Lisp files, any possibility to all lisp combine in one Lisp file??

 

Thanks in advance..

 

 

sure , paste them all in one file , for example mylisp.lsp. Just load this file every time and any function defined in mylisp.lsp will be available to you.

 

 

gr. Rlx

Link to comment
Share on other sites

If you want 1 lisp have a think about a library lisp ie where you have just previously copied and pasted well tested code that you have put into multiple lisps and make them a defun, our auto load just has an emphasis on all the keyboard shortcuts rather than the code.

 

You can use a (if (not mydefuname )(load "mydefuname")) so only load as required, again the if not finds my individual library code rather than say 30 programs in one lisp. This is simple for run from a menu command.

 

I have again started moving code to a more multi defun approach not the copy and paste. New enter values use my auto create dialouge box routines "Getvals.lsp" this is like 3 lines of code and you have dialouge box entry rather than command line.

 

Have a think about how many times in all your code you ask for say getstring or getreal repeatedly.

 

The AutoLoad function enables a user to load an AutoLISP file when a specific command is entered at the command line.

 

(autoload "COPY0" '("COPY0"))
(autoload "COPYCOMMAND" '("ZZZ"))
(autoload "COVER" '("COVER"))
(autoload "DIMFLIP" '("DIMFLIP"))

Link to comment
Share on other sites

Thanks, Dear, rlx & Dear Bigal......

 

You're welcome , lots of information on this site as well Lee's site. I have several functions I use quite often. Just remember if you ever sent somebody one of your routines to include either your 'library lisp' or include the function used by the another lisp program. It's not unlike xref's , it's a LispRef :-)

 

Gr. Rlx

Edited by rlx
Link to comment
Share on other sites

Ok, rlx, I will do that??? thanks once again for everything...

 

or you can use the concatenate in ms dos, you can combine 100 .lsp in just a second.

as simple as

copy *.lsp merged.lsp

the command copies all .lsp file then create a file merged.lsp and put them all in there. actually you can name it what ever you want.

Link to comment
Share on other sites

  • 6 years later...
On 12/1/2015 at 6:37 AM, ttray33y said:
copy *.lsp merged.lsp
the command copies all .lsp file then create a file merged.lsp and put them all in there. actually you can name it what ever you want.

Need help

(defun c:combinelisps ()
(startapp "cmd" "_cd C:\Users\Company\Documents\Autodesk\Lisp file folder" "copy *.lsp merged.lsp"))

 

Link to comment
Share on other sites

1.

Go to bottom left of Windows type

cmd

cd \Users\Company\Documents\Autodesk\Lisp file folder

copy *.lsp merged.lsp

2.

So in lisp may need to use Shell rather than startapp.

3.

Save above as a batch file .BAT then use (startapp "C:\Users\Company\Documents\Autodesk\Lisp file folder\copylisp.bat")

 

Just a side note can add a security lisp by using, copy security.lsp+lisp1.lsp c:\somewhere\lisp1.lsp

Edited by BIGAL
Link to comment
Share on other sites

6 hours ago, BIGAL said:

1.

Go to bottom left of Windows type

cmd

cd \Users\Company\Documents\Autodesk\Lisp file folder

copy *.lsp merged.lsp

2.

So in lisp may need to use Shell rather than startapp.

3.

Save above as a batch file .BAT then use (startapp "C:\Users\Company\Documents\Autodesk\Lisp file folder\copylisp.bat")

 

Just a side note can add a security lisp by using, copy security.lsp+lisp1.lsp c:\somewhere\lisp1.lsp

cmd
cd \Users\Company\Documents\Autodesk\Lisp file folder
copy *.lsp merged.lsp

You mean paste this to Notepad & change the extension as .bat (To create BAT File)

Link to comment
Share on other sites

No need for cmd when you save as a bat file

 

cd \Users\Company\Documents\Autodesk\Lisp file folder
copy *.lsp merged.lsp

 

For me by the time I have copied pasted and saved code made it work, I would have it all done using 1st manual method.

Link to comment
Share on other sites

1 hour ago, BIGAL said:

For me by the time I have copied pasted and saved code made it work, I would have it all done using 1st manual method.

 

agree plus I dont want to automate updating the master lisp. could overwrite or lose code happend a few times so I always do it manually now.

Link to comment
Share on other sites

BIGAL & mhupp:

Thanks a lot Guys who replied to my thread !

 

I was merging Lisps files to make hard copies on A3 size paper to study & upgrade purpose only not to execute lisp routes.

(To execute you can have max. 50 Lisps programs otherwise it makes you headache as per my knowledge)

 

Another way by Lisp:

(defun c:mergelisps ( / )
(vl-file-copy "c:/Users/Company/Documents/My Lisp programme/LISP1.lsp" "c:/Users/Company/Documents/My Lisp programme/Print_Purpose.lsp" T)
(vl-file-copy "c:/Users/Company/Documents/My Lisp programme/LISP2.lsp" "c:/Users/Company/Documents/My Lisp programme/Print_Purpose.lsp" T)
(vl-file-copy "c:/Users/Company/Documents/My Lisp programme/LISP3.lsp" "c:/Users/Company/Documents/My Lisp programme/Print_Purpose.lsp" T)
(vl-file-copy "c:/Users/Company/Documents/My Lisp programme/LISP4.lsp" "c:/Users/Company/Documents/My Lisp programme/Print_Purpose.lsp" T)
(vl-file-copy "c:/Users/Company/Documents/My Lisp programme/LISP5.lsp" "c:/Users/Company/Documents/My Lisp programme/Print_Purpose.lsp" T)
 (princ))

 

I want your help to upgrade the lisp with the below function

(vl-load-com)
(foreach lispfiles (vl-directory-files "c:/Users/Company/Documents/My Lisp programme" "*.LSP" 1)

Thanks a lot.

Link to comment
Share on other sites

As lisp files are text in old days could just push a text file straight to printer from DOS, should still be able to do the same probably using Powershell. 

 

Printing with Powershell and files in folders - Stack Overflow

 

Please dont ask me how to make it work !

 

Trying to remember copy filename | printer

 

Hey guys remember a dot matrix with a box of continuous paper hanging out the back, ideal for this task. 

Link to comment
Share on other sites

4 hours ago, sivapathasunderam said:

To execute you can have max. 50 Lisps programs otherwise it makes you headache as per my knowledge

 

I want your help to upgrade the lisp with the below function

(vl-load-com)
(foreach lispfiles (vl-directory-files "c:/Users/Company/Documents/My Lisp programme" "*.LSP" 1)

 

 

Far as i know their isn't a limit on how many lisp you can have in one file. Tho I don't edit any lisp inside of the main file. Because when loading a lisp its all or nothing. meaning if you forget a ")" in one of the functions it will error and all other functions wont load either.

So if I am editing a function I will copy it to a new file edit it there make sure its working then put it back into the main file. to avoid this issue.

 

You got to tell it what to do

(vl-load-com)
(foreach lispfiles (vl-directory-files "c:/Users/Company/Documents/My Lisp programme" "*.LSP" 1)
  (load lispfiles) ;load I'm guessing?
)

 

Link to comment
Share on other sites

  • 2 weeks later...
On 8/10/2022 at 3:24 PM, mhupp said:

You got to tell it what to do

(vl-load-com)
(foreach lispfiles (vl-directory-files "c:/Users/Company/Documents/My Lisp programme" "*.LSP" 1)
  (load lispfiles) ;load I'm guessing?
)

 

I wrongly approach to the foreach function

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...