Author Topic: Prevent lisp command line output  (Read 4001 times)

0 Members and 1 Guest are viewing this topic.

imbeer

  • Guest
Prevent lisp command line output
« on: June 30, 2015, 07:52:30 PM »
For some time now I was thinking how to make my startup script cleaner. I wondered how to get rid of initial prompts that many commands produce when loaded.

I was about to ask here if you have any idea how one  can suppress output of a lisp script, but then an idea hit me.

I did some quick research, and in fact it wasn't that hard at all. As I was about to post, why not sharing the solution?

Code - Auto/Visual Lisp: [Select]
  1. ; load script without any output to command line
  2. (defun quietload ( file / princ print prin1 prompt )
  3.         ; princ, prin1, print are replaced by read so there is no problems in case of calls with single or without any arguments
  4.         ; read seems to be pretty safe for the task, and of course it supports optional arguments, what cannot be achieved with defun
  5.         (setq princ read)
  6.         (setq prin1 read)
  7.         (setq print read)
  8.  
  9.         ; void function is enough to replace prompt
  10.         (defun prompt ( x ) nil)
  11.  
  12.         ; load the file
  13.         (load file)
  14. )
  15.  

AIberto

  • Guest
Re: Prevent lisp command line output
« Reply #1 on: June 30, 2015, 08:59:52 PM »
Hi imbeer
Thanks for sharing.
But why need stop command line output ?Can you give an example?

bilançikur

  • Newt
  • Posts: 82
Re: Prevent lisp command line output
« Reply #2 on: July 01, 2015, 01:39:55 AM »
I can get the idea, maybe if you want loading lisp files in "stealth mode". So a user would not know that it is loaded. Or maybe you just don't want others to see what is going on...

imbeer

  • Guest
Re: Prevent lisp command line output
« Reply #3 on: July 01, 2015, 06:25:17 AM »
Hi imbeer
Thanks for sharing.
But why need stop command line output ?Can you give an example?

I use this for loading other scripts on startup. Of course it isn't sth absolutely necessary, it was rather an exercise for thought.

Code - Auto/Visual Lisp: [Select]
  1. (defun quietload ( file / princ print prin1 prompt )
  2.         (load file)
  3. )
  4.  
  5. (if (setq path (findfile ".\\Lisp")) (mapcar
  6.         '(lambda (file)
  7.                 (if (or (wcmatch (strcase file) "*.LSP") (wcmatch (strcase file) "*.VLX"))
  8.                         (quietload (strcat path "\\" file))
  9.                 )
  10.         )
  11.         (vl-directory-files path)
  12. ))
  13.  
  14. (princ "\nLisp scripts loaded. ")

Maybe one could use it when creating some batch command, which uses other lisp commands.

Code - Auto/Visual Lisp: [Select]
  1. ; select a set of objects
  2. ; ...
  3.  
  4. (setvar "cmdecho" 0)
  5. (setq oldprinc princ oldprin1 prin1 oldprint print oldprompt prompt)
  6.  
  7. ; a bunch of subroutines manipulating the set
  8. ; ...
  9.  
  10. (setvar "cmdecho" 1)
  11. (setq princ oldprinc prin1 oldprin1 print oldprint prompt oldprompt)

No other examples come into my mind at the moment.

I can get the idea, maybe if you want loading lisp files in "stealth mode". So a user would not know that it is loaded. Or maybe you just don't want others to see what is going on...

Haha thanks for the idea, I'll definetely think about some hijacking-script that quietly loads every other .lsp file user has on his drive!




roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Prevent lisp command line output
« Reply #4 on: July 01, 2015, 07:03:32 AM »
FWIW:
(print) will also take two arguments and (read) will not.

bilançikur

  • Newt
  • Posts: 82
Re: Prevent lisp command line output
« Reply #5 on: July 02, 2015, 10:13:56 AM »
Quote
Haha thanks for the idea, I'll definetely think about some hijacking-script that quietly loads every other .lsp file user has on his drive!

Not per se hi-jacking.... you could of course.
You can alos load .lsp from a web location (you just need to store them on some accessable server).
I have mine uploaded in a subfolder of the rootfolder of my website.

I Dont use it for hi-jacking but for updating lisp programs.