Does it works well also without an "Author Prefix" ?hmmm, i do not remeber :)
(defun vk_GetAuthorPrefix (/) "")
and tryDoes your routine find the all the code related to all the nested defuns ?at least it does for me :)
Nice one, VovKa.thank you, John
because you have an unclosed comment at the end of your file
WHY ?
the LIST is NOT MALFORMED !
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".
. . .
. . .
And if you ever needed to `package` up your code for compiling or shipment off to a client then you can use the LiFP tool to assemble a file in seconds. LiFP was designed for speed so you can use/call it from another lisp file (it would have zero problem crunching hundreds of files at a time in less then a second).
LiFP is just a preprocessor (it is a fancy way to take files and copies and pastes their contents into another file) so you can use it to build websites, documentation, etc. etc. I have used LiFP in Visual Studio when I did some C# (dotNet) development. It is a very versatile tool.
any idea ?i've been looking at this my function for a while now and the only idea i have is: i have no idea of how it's working :)
i've been looking at this my function for a while now and the only idea i have is: i have no idea of how it's working :)Thanks VovKa.
i'll implement some 'improvements' (i suppose) and post a new version
i've been looking at this my function for a while now and the only idea i have is: i have no idea of how it's working :)
i'll implement some 'improvements' (i suppose) and post a new version
Maybe it could be optimizedvk_FindFunction was the 'weakest link', it did a lot of unnecessary work
(defun vk_GetSysCharset (/) (strcat "windows-" (substr (getvar "SYSCODEPAGE") 6)))
(defun vk_Assemble (Dir WorkFunctionNamesList OutFileName / AllFunctionsList*
FoundFunction FunctionTail WorkFunctionNamesList* WorkFunctionsList
OutFile ;
_FindFunction _TraceFunction _IsFunctionCustom
)
(defun _IsFunctionCustom (Name)
(or
;;; (wcmatch (vl-symbol-name Name) (strcat (vk_AuthorPrefix) "*,C:" (vk_AuthorPrefix) "*"))
(= (type (eval Name)) 'USUBR)
)
)
(defun _FindFunction (Name FunctionsList /)
(cond ((not FunctionsList) nil)
((atom FunctionsList) nil)
((atom (cdr FunctionsList)) nil)
((and (= (car FunctionsList) 'DEFUN) (= (cadr FunctionsList) Name)) FunctionsList)
((car (vl-member-if (function (lambda (e) (and (listp e) (= (car e) 'DEFUN) (= (cadr e) Name))))
FunctionsList
)
)
)
((_FindFunction Name (car FunctionsList)))
(t (_FindFunction Name (cdr FunctionsList)))
)
)
(defun _TraceFunction (FunctionDefun FunctionTail / Found)
(if FunctionTail
(progn (if (atom FunctionTail)
(setq FunctionTail (list FunctionTail))
)
(if (= (car FunctionTail) 'DEFUN)
(_TraceFunction FunctionTail (cdr FunctionTail))
(if (listp (car FunctionTail))
(append (_TraceFunction FunctionDefun (car FunctionTail))
(_TraceFunction FunctionDefun (cdr FunctionTail))
)
(if (and (= (type (car FunctionTail)) 'SYM)
(_IsFunctionCustom (car FunctionTail))
(not (vl-position (car FunctionTail) WorkFunctionNamesList*))
(not (vl-position (car FunctionTail) (caddr FunctionDefun)))
(not (_FindFunction (car FunctionTail) FunctionDefun))
)
(append (if (setq Found (_FindFunction (car FunctionTail) AllFunctionsList*))
(progn (setq WorkFunctionNamesList* (cons (car FunctionTail) WorkFunctionNamesList*))
(cons (car FunctionTail) (_TraceFunction (car FunctionTail) Found))
)
(progn (princ (strcat " " (vl-symbol-name (car FunctionTail)) " not found\n")) nil)
)
(_TraceFunction FunctionDefun (cdr FunctionTail))
)
(_TraceFunction FunctionDefun (cdr FunctionTail))
)
)
)
)
)
)
(textscr)
(setq WorkFunctionNamesList* WorkFunctionNamesList)
(princ (strcat "Reading source files...\n" Dir "\n"))
(setq AllFunctionsList*
(apply 'append
(mapcar (function
(lambda (FileName /)
(princ (strcat " " FileName "... "))
(if (vl-catch-all-error-p (vl-catch-all-apply 'load (list (strcat Dir FileName))))
(progn (princ "ERROR\n") nil)
(progn (princ "OK\n")
(cdr (read (strcat "(progn\n" (vk_ReadTextStream (strcat Dir FileName) (vk_GetSysCharset)) "\n)")))
)
)
)
)
(acad_strlsort (vl-directory-files Dir "*.lsp" 1))
)
)
)
(princ "Done\n\n")
(princ "Tracing functions...\n")
(foreach WorkFunction WorkFunctionNamesList*
(princ (strcat " " (vl-symbol-name WorkFunction) "...\n"))
(setq FoundFunction (_FindFunction WorkFunction AllFunctionsList*))
(_TraceFunction FoundFunction (cdr FoundFunction))
)
(princ "Done\n\n")
(princ (strcat "Writing destination file...\n" OutFileName "\n"))
(setq OutFile (open OutFileName "W"))
(princ "(vl-load-com)\n" OutFile)
(foreach WorkFunctionName WorkFunctionNamesList*
(princ (strcat " " (vl-symbol-name WorkFunctionName) "...\n"))
(prin1 (_FindFunction WorkFunctionName AllFunctionsList*) OutFile)
(princ "\n" OutFile)
)
(foreach WorkFunctionName WorkFunctionNamesList
(if (wcmatch (vl-symbol-name WorkFunctionName) "C:*")
(princ (strcat "(vl-doc-export '" (vl-symbol-name WorkFunctionName) ")\n") OutFile)
)
)
(close OutFile)
(princ "Done\n\n")
(princ)
)
i've rewritten it long ago but never posted new version because nobody was interested in the code
I can't imagine a LISPERit's almost 2021 and all lispers are doing just fine without it :)
that can work without your routine !
This is the complete WORKING (! :smitten:) code !
I don't know what is it for, . . .. . .
there is no big gain in speed-efficiency if subs are as globals
no big gain in speed-efficiency if subs are as globalsWe are not treating this issue.
I am saying that when you code, you should actually put needed subs along with main routine and not to keep them separated.... . . it is frequent that a subroutine contains another sub routine . . .
The argument about the possibility of loosing library code (`sub routines') is a bad argument.
Luckily I have a good practice that I backup
my important stuff on external drives,
so nothing really good wasn't destoyed
A good directory structure and proper programming habits is/are essential.
Of course you should be backing up your files--that goes without saying.The argument about the possibility of loosing library code (`sub routines') is a bad argument.
You can say it so from your point of view... I am not saying or wanting that it can/should happen to anyone, but still there is such a possibility, so argument is just fine... I want to say that if/when you actually loose such a file/files, all your work is worthless, nothing is/would be working... If you though keep a good practice to implement subs within routines, when you loose library, still something may work after all... I have to say that once I was in situation to recover from ransomware attack and half of my data on PC were polluted and I had to permanantly remove affected files... Luckily I have a good practice that I backup my important stuff on external drives, so nothing really good wasn't destoyed, but as you see it can happen and really in reality of all of us...