Create a commandline parameter to start a macro (and exit)

Ideas for new features

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Wcool
Posts: 5
Joined: Tue Sep 30, 2003 5:41 pm
Location: Galway, Ireland

Create a commandline parameter to start a macro (and exit)

Post 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
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post 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. ;)
I choose to fight with a sack of angry cats.
User avatar
jeffy
Posts: 323
Joined: Mon Mar 03, 2003 9:04 am
Location: Philadelphia

Post 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

Code: Select all

java DelSpcsFromLineEnds
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

Code: Select all

C:\DelSpcFromLineEnds\
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 :' )
User avatar
jeffy
Posts: 323
Joined: Mon Mar 03, 2003 9:04 am
Location: Philadelphia

Post by jeffy »

If CLASSPATH already has an existing value, put a semi-colon ";" between it and the above to-be-added value.
Wcool
Posts: 5
Joined: Tue Sep 30, 2003 5:41 pm
Location: Galway, Ireland

Err, proposed macro was just an example

Post 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
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Macro Scheduler will definitely do what you want here. Will do that and much more......give it a try.....
Hope this was helpful.............good luck,
Bob
User avatar
jeffy
Posts: 323
Joined: Mon Mar 03, 2003 9:04 am
Location: Philadelphia

Post 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.
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post 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.
Hope this was helpful.............good luck,
Bob
Wcool
Posts: 5
Joined: Tue Sep 30, 2003 5:41 pm
Location: Galway, Ireland

No need for a poll

Post 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!
Post Reply