Author Topic: Lisp that behaves differently when loaded differently.  (Read 732 times)

0 Members and 1 Guest are viewing this topic.

Prickle Farmer

  • Newt
  • Posts: 33
  • 35+ years of AutoCAD / BricsCAD
Lisp that behaves differently when loaded differently.
« on: July 20, 2022, 10:02:32 PM »
I know the subject line sounds a bit cryptic.  Not sure how else to describe it.  Just wondering if anyone has had this weird thing.
(load "L:\\OCRE\\OCRE_TCD\\OTCD.lsp") loads successfully but does not run properly (Unable to recognize entry. Please try again.)

but if I use this code to load it runs fine. dos_dir is a McNeel DOSLIB function. There is only one .lsp in that folder. Oh, BricsCAD v22 before you ask.

Code - Auto/Visual Lisp: [Select]
  1. (defun C:/T ()
  2.         (setq count 0)
  3.         (setq lsp_list (dos_dir "L:\\OCRE\\OCRE_TCD\\*.lsp"))
  4.         (repeat (length lsp_list)
  5.                 (setq fname (strcat "L:\\OCRE\\OCRE_TCD\\" (nth count lsp_list)))
  6.                 (load fname)
  7.                 (setq count (1+ count))
  8.         );repeat
  9. );defun
I'd rather have a bottle in front of me than a frontal lobotomy.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Lisp that behaves differently when loaded differently.
« Reply #1 on: July 20, 2022, 11:10:57 PM »
You want to avoid (dos_dir)...
Maybe something's wrong with syntax in LSP that is to be loaded (according to your explanation)... AFAIK, I had no problems with (load) function in my past... It could be that LSP was corrupted through process of possible HD copying/moving file(s) from one path to other... It is also good practice to acquire correct file specification by preliminary check existence with (findfile) function... Something like :

Code - Auto/Visual Lisp: [Select]
  1. (if (setq fn (findfile (setq f "L:\\OCRE\\OCRE_TCD\\OTCD.lsp")))
  2.   (load fn (strcat "Loading failure - error in file : " (vl-prin1-to-string f) "..."))
  3.   (progn
  4.     (prompt (strcat "\nUnable to acquire file : " (vl-prin1-to-string f) " ... Quitting..."))
  5.     (exit)
  6.   )
  7. )
  8.  
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Prickle Farmer

  • Newt
  • Posts: 33
  • 35+ years of AutoCAD / BricsCAD
Re: Lisp that behaves differently when loaded differently.
« Reply #2 on: July 20, 2022, 11:29:45 PM »
Thanks Marko for your input.  The point of the dos_dir is to build a list of all the .lsp files in a folder. Then the repeat loop will load each one.  The folder is intended to host a suite of programs.  As each new program is written the /T command will load all .lsp files including new ones.  This functionality is working fine (and has been for more than 20 years).
Both loading methods point to the same location and exact same file.  There is no possibility of corruption.  It is the same file.  There is only one.  Hence my bewilderment.
I'd rather have a bottle in front of me than a frontal lobotomy.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Lisp that behaves differently when loaded differently.
« Reply #3 on: July 21, 2022, 02:31:25 AM »
In the code you are defining a function and a number of global variables. I would check if OTCD.lsp depends on these. Note that BricsCAD has a built-in dos_dir function.

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Lisp that behaves differently when loaded differently.
« Reply #4 on: July 21, 2022, 08:22:00 PM »
It sounds like you want to load lisps on startup. I just load a lsp inside is multiple "Autoload"  commands which load the lisp on demand when you type the command or or plain (load. You can add search path via lisp a much easier way so Load only needs filename.

My Autoload.lsp has 34 Autoload's and 6 (load "filename") plus 38 defuns. Not to mention what is loaded via menu's.

Look up help "Autoload"
A man who never made a mistake never made anything