Windows, true executable, editable script

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Post Reply
Posts: 183
Joined: Tue Oct 30, 2007 6:27 pm
Location: Moscow, Russia

Windows, true executable, editable script

Post by Cyril »

In the brave Unix world, anything with an 'x' bit set is an executable, and the interpreter is determined by #! notation. In Windows, you need a real .exe file sometimes. One particular case is Windows screensavers, which in fact are .exe files with .scr extensions.
BTW, screensavers are not only to save your screens! It is just a handy way to do something useful when your computer is idle.
Of course you can link the newlisp executable with your code, but then you lose one of the advantages of scripting languages: ability to modify your code and run it immediately. Linking is too similar to compilation. :-( My solution is to link the newlisp executable with this one-liner:

Code: Select all

(load (replace {\.[^\\.]*$} (main-args 0) ".lsp" 0))
, then rename the resulting executable to, say, ushaper.scr. Then copy it into your c:\windows\system32 folder, set it as your screen saver, and, on run, it will just load ushaper.lsp from the same directory. The only disadvantage is that you must maintain two files instead of one, but in fact the first one don't need any "maintenance".

BTW, "ushaper" is not just a random name, it is my small script to shape uTorrent client bandwith: give it more when you are away, get it back when you return to you computer. Source is here. ;-)
With newLISP you can grow your lists from the right side!

Post Reply