Page 1 of 1
Create a commandline parameter to start a macro (and exit)
Posted: Tue Sep 30, 2003 5:58 pm
by Wcool
No parameter exist to start a macro from the command line and exit Textpad.
This means I can not use Textpad in a shell script.
Example:
I have created a macro which deletes the first 5 characters of a line for every line in the file.
This is something that I would like to automate as a process in a batch file.
This is impossible at the moment.
Suggestion:
Create 2 new command line parameters, for example:
-x <macro name>[no of time to execute]: Execute macro [specified times] and leave Textpad open. No specified no of times = until end of file
-xe <macro name>[no of time to execute]: Execute macro [specified times] and exit Textpad. No specified no of times = until end of file
Posted: Tue Sep 30, 2003 6:40 pm
by talleyrand
I haven't used it but I believe
Macro Scheduler may cure your ills.
Also, you might also want to look at one of the unix toolkits around (
Cygwin and
MinGW are two that come to mind). This a trivial thing to do in unix (
cat myFile | cut -c6-) whereas firing up Textpad would be overkill in my opinion. If you want more info, hit the web or hit me.
Posted: Tue Sep 30, 2003 8:16 pm
by jeffy
I wrote a small Java program that does what you want, and pretty flexibly, to boot. TextPad does great things, but some things it's not meant to do. Processing multiple files one by one, from the command line, is one of those things.
Download it from
http://jeffyjeffy.com/TEMP/DelSpcFromLineEnds.zip
Read the documentation at the top of the Java file for more info. You'll call this from the command line (like COMMAND.exe or 4NT.exe), as you wish.
Try it first with
Code: Select all
java DelSpcsFromLineEnds -file <INSTALL DIR>example/spaces.txt -outfile <INSTALL DIR>example/spaces_bkp.txt -left 2 -right 5
Call it with
to get usage instructions.
INSTALLATION:
Explode the zip onto your machine. If you install it directly into the root of the C:\ drive, then <INSTALL DIR> will equal
You'll need to install the Sun's
Java Runtime Environment 1.3.1 or higher (click on DOWNLOAD underneath "JRE" and to the right of "Windows"). Follow its installation instructions, it's pretty easy.
And then you'll need to add the following to your windows CLASSPATH environment variable (create it if necessary):
Code: Select all
.;<INSTALL DIR>;<INSTALL DIR>/dependencies/xbnjava-0.8.2b.jar;<INSTALL DIR>/dependencies/commons-cli-1.0.jar
(This is definitely complicated, but once you've done it, you can run practically any Java program. Once you *understand* it, you are a better man than I :' )
Posted: Tue Sep 30, 2003 8:22 pm
by jeffy
If CLASSPATH already has an existing value, put a semi-colon ";" between it and the above to-be-added value.
Err, proposed macro was just an example
Posted: Tue Sep 30, 2003 8:28 pm
by Wcool
Thanks for all the replies,
I will definetely have a look at the Macro Scheduler.
BUT, the proposed macro was just an example.
Indeed in Unix it is trivial. The idea is that I can't 'use' Textpad as a vehicle to process files, because there is no way to start tasks from the command line.
That's why I posted it in Enhancements requests and not in Questions.
Jeroen
Posted: Tue Sep 30, 2003 11:09 pm
by Bob Hansen
Macro Scheduler will definitely do what you want here. Will do that and much more......give it a try.....
Posted: Wed Oct 01, 2003 1:48 pm
by jeffy
I do think it would be a good idea to have each document class be able to run a specific macro on, perhaps, file open, save and close.
That way I could, say, write my Java code with tab-indentation, but it could automatically be saved as three space indentation. When I open it again, it'll be re-translated to tab-indentation.
I personally like working with tab indentation, but the standard seems to be spaces.
I could imagine useful open/save/close macros for each document class.
Posted: Wed Oct 01, 2003 11:50 pm
by Bob Hansen
I thnk the initial request is a good idea for an enhancement. I would vote for it in a poll. Add Jeffy's suggestion and the command line switch could override a class default macro that might exist.
No need for a poll
Posted: Thu Oct 02, 2003 3:46 pm
by Wcool
I don't know much about the development process for Textpad.
But the enhancement I requested wouldn't take me more than 2 hours to program. It's utterly easy to build it.
Jeffry's enhancement is a bit trickier I guess.
But still: please not a poll for things that are so easy to build that it should be automatic to put in a next release.
If there is a poll please make Jeffry's enhancement the subject as that has much more consequences
PS I would vote in favour!