Author Topic: LISP PACKAGER  (Read 6479 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 723
LISP PACKAGER
« on: December 26, 2020, 06:10:55 AM »
I have all my lisp files, in the same folder.
Some of these files contain only sub-routines.
When I write a routine, it uses some of these sub-routines.
And sub-routines uses other sub-routines and so on.
So there is a TREE of the sub-routines.

In the past I wrote a LISP PACKAGER
that read all the lisp files contained in a folder

Checks the ATOMS-FAMILY for all sub-routines.

And finds all the DEFUNS and their related codes.

When I give it the name of the main routine,
it finds all the related defuns
and create a single lisp file
that contains the main routine and all the related sub-routines
. . .
it contains only what is necessary
. . .
But I wrote this PACKAGER a lot of years ago.
It is a not professional code.

I am wondering if there is already a software that makes the same thing.

And if not,
I want ask you if someone is interested
to write togheter
something that is useful for every one.


domenicomaria

  • Swamp Rat
  • Posts: 723
Re: LISP PACKAGER
« Reply #1 on: December 26, 2020, 07:01:56 AM »
the LISP EDITOR
does the same thing.

It needs to know the TREE of ALL USED SUB-ROUTINES
and find and uses the code defined in every SUB-ROUTINES

So it is sure, that it already exists
an internal function the solve this issue.

The problem is that it is an INTERNAL function !

... or NOT ?

maybe is it accessible ?

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: LISP PACKAGER
« Reply #2 on: December 26, 2020, 10:33:35 AM »
Years ago I wrote a preprocessor called LiFP that will do what you ask but it was intended to keep you organized during the writing process (not after). -i.e. You should have an organized folder for "libarary routines" and not several copies of them amongst many files. If you read the tutorial and/or the initial post you will see what I mean.

https://www.theswamp.org/index.php?topic=37700.0
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: LISP PACKAGER
« Reply #3 on: December 26, 2020, 12:21:23 PM »
I have seen your software.
It seems to be interesting and well done.
But it is not what I need.
. . .
I have TWO KIND of files :
- ONE lisp file that contains a ROUTINE that DOES something
and uses external SUB-ROUTINES

- SOME lisp files that contain ONLY SUB-ROUTINES

The "PACKAGER"
has to pack up the lisp file that contains the MAIN ROUTINE
and to search, the DEFUNs and their related codes,
in the lisp files that contain only SUB-ROUTINES ...


What I want acheive is
ONE LISP FILE that contains
everything it needs to work and only this

This because,
if I want create a VLX,
I don't want put everything in the "compiler".
 . . .



« Last Edit: December 26, 2020, 12:36:02 PM by domenicomaria »

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: LISP PACKAGER
« Reply #4 on: December 26, 2020, 12:30:10 PM »
However it is possible to create this software
. . .
I wrote it
only for internal use (where I was working)
and it was working well
. . .
Maybe I have to re-write it
in a better and more elegant way
. . .
For istance . . .

what is the best way to extract
all the DEFUNs, (the name and the related code)
from a LISP file ?
. . .
what is the best way to find
the TREE of all used SUBROUTINES ?
. . .

is there somebody that can give some suggestions ?



domenicomaria

  • Swamp Rat
  • Posts: 723
Re: LISP PACKAGER
« Reply #5 on: December 26, 2020, 12:38:25 PM »
however . . .
again :

it is sure,
that an internal function the solves this issue
already exists !

The problem is that it is an INTERNAL function !

... or NOT ?

maybe is it accessible ?


Maybe with .NET or C++ ?

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: LISP PACKAGER
« Reply #6 on: December 26, 2020, 01:43:02 PM »

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: LISP PACKAGER
« Reply #7 on: December 26, 2020, 02:29:45 PM »
VovKa thank you for your reply
. . .
I will take a look at it
It seems to be very interesting . . .
I have to study it.
To understand it.

Does it works well also without an "Author Prefix" ?

Because I'm not so organized !

And however, is this code able to answer to my request, at all ?

Does your routine find the all the code related to all the nested defuns ?

ciao

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: LISP PACKAGER
« Reply #8 on: December 26, 2020, 02:42:47 PM »
Nice one, VovKa.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: LISP PACKAGER
« Reply #9 on: December 26, 2020, 05:15:20 PM »
looks like this is one posted is an old version and is quite slow
think i will have to update it

Does it works well also without an "Author Prefix" ?
hmmm, i do not remeber :)
edit the code to
Code: [Select]
(defun vk_GetAuthorPrefix (/) "")
and try
Does your routine find the all the code related to all the nested defuns ?
at least it does for me :)
it recursively scans all functions in all files in the given directory
here's quite a big app of mine https://www.theswamp.org/index.php?topic=47908.0
it requires more than 300 library functions (spread across 30 files) to work and is assembled with the given function without a problem

one should be careful with this function as it uses read thus 'long' reals would be truncated
i usually store long reals as strings and atof them on the run
by 'long' i mean 'with many significant digits'

Nice one, VovKa.
thank you, John

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: LISP PACKAGER
« Reply #10 on: December 27, 2020, 05:52:29 AM »
(defun VK_READTEXTSTREAM (FileName Charset / ADODBStreamObj Result)
   (if (and   (setq FileName (findfile FileName))
            (setq ADODBStreamObj (vlax-create-object "ADODB.Stream"))
       )
      (progn (setq Result
                     (vl-catch-all-apply
                        (function
                           (lambda ()
                              (vlax-put ADODBStreamObj "Charset" Charset)
                              (vlax-invoke ADODBStreamObj "Open")
                              (vlax-invoke ADODBStreamObj "LoadFromFile" FileName)
                              (vlax-invoke-method ADODBStreamObj "ReadText" -1)
                           )
                        )
                     )
             )
             (vlax-release-object ADODBStreamObj)
             (if (not (vl-catch-all-error-p Result))
                Result
             )
      )
   )
)


(setq txt-strm (VK_READTEXTSTREAM "c:\\ your folder \\TEST.LSP" "windows-1251") )
(setq read-txt-strm (read txt-strm) )
RETURNS ONLY the FIRST DEFUN !
(DEFUN C:TEST1 (/ A B C) (SETQ A 1 B 2 C 3) (+ A B C))
. . .
While TEST.lsp contains these 3 DEFUNs . . .
(defun c:test1 (/ a b c) (setq a 1 b 2 c 3) (+ a b c) )
(defun c:test2 (/ a b c) (setq a 4 b 5 c 6) (+ a b c) )
(defun c:test3 (/ a b c) (setq a 7 b 8 c 9) (+ a b c) )
. . .


Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: LISP PACKAGER
« Reply #11 on: December 27, 2020, 07:24:49 AM »
That's why progn is used in the original code, to always yield a single expression.

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: LISP PACKAGER
« Reply #12 on: December 27, 2020, 09:15:49 AM »
Lee, maybe this one,
was not too much difficult to understand . . .

But what is obvious for you, for vovka . . .
is not the same for me.

I am not a genius like you !

Ciao

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: LISP PACKAGER
« Reply #13 on: December 27, 2020, 09:28:22 AM »
however I am finding some problems . . .

(setq txt-strm (VK_READTEXTSTREAM "C:\\YOUR FOLDER\\%ID-POINT.lsp" "windows-1251") )

(setq txt-strm (strcat "(progn\n" txt-strm "\n)" ) )
(setq read-txt-strm (read txt-strm) )

;   malformed list on input   

WHY ?

the LIST is NOT MALFORMED !


VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: LISP PACKAGER
« Reply #14 on: December 27, 2020, 04:33:31 PM »

WHY ?

the LIST is NOT MALFORMED !


because you have an unclosed comment at the end of your file
|; is missing