sholle: -------------------------------------------------------------------------------- I have a VBScript that takes, as an input, a file name. It does some processing on the file and outputs it as a new file with a different extension. I would like to add it to PSPad as an option to do the processing on the currently selected file open in PSPad.
I've looked for a simple example but am unable to find any, probably because I am looking in the wrong place. Can someone point me in the right direction? Thanks. -------------------------------------------------------------------------------- sholle: -------------------------------------------------------------------------------- I have a VBScript that takes, as an input, a file name. It does some processing on the file and outputs it as a new file with a different extension. I would like to add it to PSPad as an option to do the processing on the currently selected file open in PSPad. I've looked for a simple example but am unable to find any, probably because I am looking in the wrong place. Can someone point me in the right direction? Thanks. -------------------------------------------------------------------------------- You say you already have the script - so there are really 2 options: (1) You re-write your script to integrate with PSPad (2) You write a "wrapper" PSPad script to call your existing script. I'll explain how to do (2) now - (1) will depend on your script. Although you haven't explained it, I'll suppose that your script takes 2 command-line arguments for the input and output files, in that order: wscript.exe "c:\scripts\your-script.vbs" "c:\data\input-file.txt" "c:\data\output-file.csv" One unfortunate thing about PSPad is that there is no way to tell if an open file has been modified or not. Therefore the actual path of the open file is useless - we'll have to deal with the actual content. Here are the steps: (1) Get the reference to the currently open file [if there is none, quit with an insulting remark to the user] (2) Generate 2 temporary file names - we'll call them tmp_in_file and tmp_out_file (3) Write the contents of the open file into tmp_in_file (4) Externally execute your script [synchronously], passing the 2 filenames (quoted) (5) Open tmp_out_file and read the contents (new_file_contents) (6) Delete the 2 temporary files (7) Replace the open file contents with new_file_contents I've written a demo here: http://openpaste.org/en/3159/. It's in JavaScript - which I prefer over VBScript, but I'm sure you can adapt it. Hope this helps -- <http://forum.pspad.com/read.php?2,42293,42332> PSPad freeware editor http://www.pspad.com
