Author Topic: do you have a library of functions saved?  (Read 4687 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
do you have a library of functions saved?
« on: September 04, 2014, 09:59:14 AM »
this is an odd question but...

do you have a library of lisp function you use often?
if so, how do you save your functions?
do you:
save them in 1 big text file
save them in separate text files
or have some other organized way?


dgorsman

  • Water Moccasin
  • Posts: 2437
Re: do you have a library of functions saved?
« Reply #1 on: September 04, 2014, 10:32:07 AM »
"Saved" is a bit of a misnomer.  I take an organized library approach to design, building LISP functions to support LISP functions to support LISP functions to support command functions.  They are grouped into files by general function and/or application and/or client, depending how far up the tree they are, where they need/don't need to be loaded.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

JohnK

  • Administrator
  • Seagull
  • Posts: 10623
Re: do you have a library of functions saved?
« Reply #2 on: September 04, 2014, 10:43:27 AM »
I don't do lisp any longer but when I did, I kept a library of functions in separate files.

I created a tool in C++ that will allow you to "assemble" a function(s) with all your latest library code files called LiFP (It has many more uses, but this was it's main intention). I even supplied a "starter library" of AutoLisp code for you in that tool.
http://www.theswamp.org/index.php?topic=37700.msg427343#msg427343
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

BlackBox

  • King Gator
  • Posts: 3770
Re: do you have a library of functions saved?
« Reply #3 on: September 04, 2014, 10:44:10 AM »
I save them to individual .LSP files by function, and group them into logical VLIDE projects (i.e., 2014_ACAD, 2014_C3D, 2015_ACAD, 2015_C3D, Common, etc.)... Most are demand-loaded into their respective applications via AcadDoc.lsp file.

I am slowly migrating to Autoloader for the ease of maintaining per-[environment[version]] loading of all .CUIx, .LSP, .DLL, etc. components, and the built-in Help file association of same.

Cheers
"How we think determines what we do, and what we do determines what we get."

kruuger

  • Swamp Rat
  • Posts: 633
Re: do you have a library of functions saved?
« Reply #4 on: September 04, 2014, 01:50:33 PM »
I don't do lisp any longer but when I did, I kept a library of functions in separate files.

I created a tool in C++ that will allow you to "assemble" a function(s) with all your latest library code files called LiFP (It has many more uses, but this was it's main intention). I even supplied a "starter library" of AutoLisp code for you in that tool.
http://www.theswamp.org/index.php?topic=37700.msg427343#msg427343
still using this one :) it is really helpful.
kruuger

JohnK

  • Administrator
  • Seagull
  • Posts: 10623
Re: do you have a library of functions saved?
« Reply #5 on: September 04, 2014, 03:13:39 PM »
I don't do lisp any longer but when I did, I kept a library of functions in separate files.

I created a tool in C++ that will allow you to "assemble" a function(s) with all your latest library code files called LiFP (It has many more uses, but this was it's main intention). I even supplied a "starter library" of AutoLisp code for you in that tool.
http://www.theswamp.org/index.php?topic=37700.msg427343#msg427343
still using this one :) it is really helpful.
kruuger

That's great! I am super happy that you are using it and it helps!!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

d2010

  • Bull Frog
  • Posts: 326
Re: do you have a library of functions saved?
« Reply #6 on: September 07, 2014, 07:37:35 PM »
this is an odd question but...

do you have a library of lisp function you use often?
yes: i develope a big library witn  1481 functions .autolisp&vlisp........

if so, how do you save your functions?
yes: i extract  from zip'library. Each function is equal wiith a 1 file' or
all functions  saved  to one file source. LSP  or .TXT 

 :-P

save them in 1 big text file?
You can  convert  a library functions to one-big-text'file.DTF

or have some other organized way?
Yes. you test
http://lisp2arx.3xforum.ro/post/22/1/DOWNLOADING_vlacompilator_Here_/
 YOU CLICK ON blue-string, "inregis...."
the VL.exe can  convert the  "append_all_functions_toone_source.txt",
 to source 100%autolisp automatically ......[i/]
 :-o
save them in separate text files
You  copy&paste with notepad.exe , and you
             save the new-source with notepad.exe <CTRL-S>

Thanks..........
« Last Edit: September 09, 2014, 05:41:20 PM by d2010 »

reltro

  • Guest
Re: do you have a library of functions saved?
« Reply #7 on: September 29, 2014, 01:19:29 PM »
Hey People...

I was tired of copying a lot of lisps together to make an application run. Normally I try to reduce the namespace-impact to the global namespace to a minimum. So I developed a routine, in lisp, to stick/to combine my library with the MainRoutine...

What is needed is the function wich will do so ;) (found in \\sys\\combine.lsp), an IndexFile (MSV.csv), a Header in the .lsp-files, and the lib-functions declared in readable form, using defun-q instead of defun (combine.lsp has to know how many arguments a function takes)
NOTE: HEADER.lsp is not the header described above...

I built up a quick application, called 'ModelSpaceViewport' (in the attachment)...
Just open up MSV.lsp and change the Path to match the current location (folder) of the File.
Then load it,Done...
There is just one command loaded, C:MSV... but, u can load others to... Just change the string "GUI" to "CMD" or "ALL" or "API"....

Its V0.1 of the combine-routine, so be nice... ;)

greets reltro
« Last Edit: September 29, 2014, 01:29:27 PM by reltro »

JohnK

  • Administrator
  • Seagull
  • Posts: 10623
Re: do you have a library of functions saved?
« Reply #8 on: September 29, 2014, 03:31:01 PM »
I was tired of copying a lot of lisps together to make an application run. Normally I try to reduce the namespace-impact to the global namespace to a minimum. So I developed a routine, in lisp, to stick/to combine my library with the MainRoutine...
...

That seems a bit complicated reltro. Have you checked out my LiFP program (it may help)?
http://www.theswamp.org/index.php?topic=37700.msg427343#msg427343

TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: do you have a library of functions saved?
« Reply #9 on: September 29, 2014, 05:17:22 PM »
i store my lisps in libraries. that is around 30 files
in case i need a standalone application i have this 'assembling" function
Code: [Select]
(defun vk_GetAuthorPrefix (/) "VK_")
(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
   )
    )
  )
)
(defun vk_Assemble (Dir WorkFunctionNamesList
    OutFileName /     AllFunctionsList
    FoundFunction FunctionTail     WorkFunctionNamesList*
    WorkFunctionsList OutFile     vk_FindFunction
    vk_TraceFunction
   )
  (defun vk_FindFunction (Name FunctionsList / Result)
    (if FunctionsList
      (if (and (= (car FunctionsList) 'DEFUN) (= (cadr FunctionsList) Name))
FunctionsList
(if (or (atom (car FunctionsList))
(not (setq Result (vk_FindFunction Name (car FunctionsList))))
    )
  (if (atom (cdr FunctionsList))
    nil
    (vk_FindFunction Name (cdr FunctionsList))
  )
  Result
)
      )
    )
  )
  (defun vk_TraceFunction (FunctionDefun FunctionTail / Found)
    (if FunctionTail
      (progn
(if (atom FunctionTail)
  (setq FunctionTail (list FunctionTail))
)
(if (= (car FunctionTail) 'DEFUN)
  (vk_TraceFunction FunctionTail (cdr FunctionTail))
  (if (listp (car FunctionTail))
    (append (vk_TraceFunction FunctionDefun (car FunctionTail))
    (vk_TraceFunction FunctionDefun (cdr FunctionTail))
    )
    (if
      (and (= (type (car FunctionTail)) 'SYM)
   (wcmatch
     (vl-symbol-name (car FunctionTail))
     (strcat (vk_GetAuthorPrefix) "*,C:" (vk_GetAuthorPrefix) "*")
   )
   (not (vl-position (car FunctionTail) WorkFunctionNamesList*))
   (not (vl-position
  (car FunctionTail)
  (cdr (member '/ (caddr FunctionDefun)))
)
   )
   (not (vk_FindFunction (car FunctionTail) FunctionDefun))
      )
       (append
(if (setq
       Found (vk_FindFunction (car FunctionTail) AllFunctionsList)
     )
   (progn (setq WorkFunctionNamesList*
(cons (car FunctionTail)
       WorkFunctionNamesList*
)
  )
  (cons (car FunctionTail)
(vk_TraceFunction (car FunctionTail) Found)
  )
   )
   (prompt (strcat "    '"
   (vl-symbol-name (car FunctionTail))
   " not found\n"
   )
   )
)
(vk_TraceFunction FunctionDefun (cdr FunctionTail))
       )
       (vk_TraceFunction FunctionDefun (cdr FunctionTail))
    )
  )
)
      )
    )
  )
  (setq WorkFunctionNamesList* WorkFunctionNamesList)
  (prompt "Reading source files...\n")
  (foreach FileName (mapcar (function (lambda (FileName) (strcat Dir FileName)))
    (vl-directory-files Dir "*.lsp" 1)
    )
    (prompt (strcat "  reading \"" FileName "\"...\n"))
    (setq AllFunctionsList
   (append
     AllFunctionsList
     (cdr (read
    (strcat "(progn\n"
    (vk_ReadTextStream FileName "windows-1251")
    "\n)"
    )
  )
     )
   )
    )
    nil
  )
  (prompt "Source files read.\n")
  (prompt "Tracing fucntions.\n")
  (foreach WorkFunction WorkFunctionNamesList*
    (prompt (strcat "  tracing '" (vl-symbol-name WorkFunction) "...\n"))
    (setq FoundFunction (vk_FindFunction WorkFunction AllFunctionsList))
    (vk_TraceFunction FoundFunction (cdr FoundFunction))
  )
  (prompt "Functions traced.\n")
  (prompt "Saving output file...\n")
  (setq OutFile (open OutFileName "W"))
  (princ "(VL-LOAD-COM)" OutFile)
  (foreach WorkFunction WorkFunctionNamesList*
    (prompt (strcat "  writung function '" (vl-symbol-name WorkFunction) "...\n"))
    (princ "\n" OutFile)
    (prin1 (vk_FindFunction WorkFunction AllFunctionsList) OutFile)
  )
  (foreach WorkFunction WorkFunctionNamesList
    (princ (strcat "\n(VL-DOC-EXPORT '" (vl-symbol-name WorkFunction) ")")
   OutFile
    )
  )
  (close OutFile)
  (prompt "Output file saved.\n")
  (princ)
)

which is called like this
Code: [Select]
(setq LibraryDir "X:\\VisualLisp\\"
      WorkFunctionNamesList
       '(C:command1 C:command2)
      OutFileName
       (strcat LibraryDir "SomeFile.lsp")
)
(vk_Assemble LibraryDir WorkFunctionNamesList OutFileName)
then it recursively traces down all dependant functions and saves the result in a separate file
« Last Edit: September 29, 2014, 06:59:32 PM by VovKa »