Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.

You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.

OK, I'm thinking out loud here, so please bear with me or ignore :) Here's a scenario I've had to contend with countless times. I'm translating a large document that contains innumerable specifications, such as power consumption, capacity, operating temperatures, dimensions, weight etc. So, lots of numbers. When translating between English and Polish it involves endless tweaking of punctuation. English "1.5" becomes "1,5" in Polish (decimal separator). English 12,000 becomes "12<non-breaking-space>000" in Polish (thousands separator). Then there are other little tweaks of spacing (we don't put a space before the degree Â° sign, for example) and units of measure. You can imagine it gets tedious quickly. Today I've gone though well over a hundred of such lines.

This needs to be automated, and implemented in such a way that it works with any text editing application. Plus, the solution needs to be abstracted enough to be generally useful.

For a long time I've looked for an excuse to write an app that executes user-created scripts. (At the moment there seems to be a dearth of Delphi scripting solutions that handle Unicode, so this might present a big obstacle, but right now I want to think positive for once :-) Would this be useful at all? Here's what I'm imagining:

1) You press a hotkey, and the as-yet-unnamed app acquires text from the application you are working in. This can be done via the clipboard or (better, harder) by accessing the text directly. So the app grabs the text and:

2) executes a script that you preselected when starting your work. In my case the script would do the appropriate replacements on the various numeric values, but it could do anything. Then:

3) the app puts the result back on clipboard or injects it directly into your editor.

Questions:

So, does this seem like a worthwhile standalone project? Assume the app does nothing else except the points above.

What existing solutions could be used to achieve the same goal? I suppose AHK could be coerced to do that. Anything else? Is it even remotely interesting?

(Yes, I've considered adding this to Echo, but I am not convinced it's a good idea. For one thing, Echo would be capturing the clipboard and modifying its contents nearly instantly, and that would play badly with other apps that monitor the clipboard. In general, I think it'd create a mess, but I haven't excluded that route just yet.)

However, the Anglophile part of the world makes it difficult to simply make one rule. Many or even most Americans have erroneous learned to say and write "kgs" for kilograms. You and I are using "kg", because we know it never is plural; 1 gram, 2 gram. Are you ready to double the set of rules?

However, the Anglophile part of the world makes it difficult to simply make one rule. Many or even most Americans have erroneous learned to say and write "kgs" for kilograms. You and I are using "kg", because we know it never is plural; 1 gram, 2 gram. Are you ready to double the set of rules?

That goes in the script

All the program itself does is grab text, pass it on to the script, then put the changed text back. In the script you can do whatever. You are right of course, and then there are different rules for different languages - which is why for the application to be useful to anyone but me, it has to be script based. Then there is no limit to the transformation rules you can create.

You may be better off using a programmable editor like Vim. The mechanism is already debugged. You may be able to find scripts to do some or all of your substitutions. Windows ports of other Linux tools are available such as sed and nawk.

You could check out the available scripts. If you get stuck you could likely find forums of enthusiasts who tinker with scripts or know where to find more that may help you get over the hurdle.

Windows ports of bash shell are available if you need to pipe the output of one into the input of another. It sounds like the type of task that someone would have automated already. At least partially.

I wish! I could do that in EmEditor or UltraEdit as well, seeing as they both come with JavaScript built in. Trouble is, for my specific needs, I work in a highly specialized "vertical" app called Trados (most translators know (of) it; most non-translators don't). Using it is a requirement, and it is actually a good thing, but it lacks certain features. Anyway, I don't have the liberty of using an editor of choice, hence the idea for a sidekick app.

It would be similar to TextMonkey except for being more open and flexible. Textmonkey has predefined scripts and no ability to change them in any way. But the rest of the functionality is there as far as reading a clip, processing it, and putting the new clip back in the clipboard.

It's sort of a super-charged find&replace program. skwire's "list numberer" is also a very specialized version of something like that. The key point to me is, how do you make something like that easy to use while being flexible enough to be generally appealing? usually things like this are handled with regex, which nobody really knows how to use, nor would want to use without a gun placed to their head.

Several utilities for modifying clipboard text (as opposed to saving clips) already exist. Take a look at my post here in anandcoral's thread NANY 2012 Pledge & Early Beta: Paste Text Like. In particular I'd recommend you look at Clippy, for two reasons. One is that you can already set it up with multiple search-and-replace strings, though I doubt Unicode. The other is for its streamlined operation. You mark your text in the usual way, press the Clippy hotkey, then Ctrl-V, and your modified text is pasted back over the marked text. I found simple and convenient. You might find it interesting to compare Clippy with your current concepts.

Be aware that the Clippy Web site is often down. It's a small program, and I've attached it to the referenced post.

In addition to what you are asking for (running a user-written script, written in any scripting language; copying text before running script, pasting after it finished), it can also apply a large number of built in operations on text (trimming, adding line numbers, etc.) without using any script.

Plus it will allow you to list your saved transformation operations in a menu that you can trigger, or assign them to specific hotkeys for really quick work.

NOTE: Using scripts is an advanced feature in CHS, and not one heavily documented or used by many people. But it was set up for exactly this kind of use.

[edit: i should say that because no one ever uses this feature it may be rough around the edges and not very tested.. so i probably need to do a little improvement on it if people actually plan to use it]

ps. CHS runs "scripts" in a very simple way but one that gives most flexibility. It saves the input text to a temp file, invokes the specified script/executable and passes it temp input file path, desired output file path, and any other arguments. When the launched script/executable finishes it grabs the output file and puts it back onto clipboard.

mouser, I think the scripting configuration might be buried too deep. You have to pick an individual clip, then Modify Format/Case -> User tools -> Configure user tools in order to enter scripts. It's certainly not obvious script-running possibilities exist from the main menu. Should script configuration be an item on the main configuration menu instead?

actually i think that's being too kind. it's pretty horrible and confusing the way it is now.

i think the solution is just to move it as just another option in the configuration dialog above, so you can combine it with any other configured built-in modifier you create, to run before or after the built-in transformations.

the real problem is simply that no one has shown much interest in the feature so i haven't bothered to improve it.

maybe what i can do is change that modification dialog to be a tree-based configuration like the main options are, which would give me a little more room to explain options, and then make it a page there.

anyway -- i don't want to take away from this thread, but i'd be happy to discuss it in the CHS forum section -- and i'd be happy to make some improvements to the script running feature if i can find someone who plans to use it.

I wish! I could do that in EmEditor or UltraEdit as well, seeing as they both come with JavaScript built in. Trouble is, for my specific needs, I work in a highly specialized "vertical" app called Trados (most translators know (of) it; most non-translators don't). Using it is a requirement, and it is actually a good thing, but it lacks certain features. Anyway, I don't have the liberty of using an editor of choice, hence the idea for a sidekick app.

I don't get it. If you can clipboard stuff out, then paste it back in after transformations, you can paste it into a programmable editor and paste it back? Maybe I have to be there to see the obstacle.

edit: Maybe that Text Editor Anywhere could bridge the gap between the specialized editor and one of your programmable ones?

I don't get it. If you can clipboard stuff out, then paste it back in after transformations, you can paste it into a programmable editor and paste it back? Maybe I have to be there to see the obstacle.

Yes but what's the difference between a "formatting program" and an editor that has a script loaded sitting there waiting for the paste? For all purposes the editor is an interpreter running your "formatting program."

Set it as default in Text Editor Anywhere. Select text, hit the hotkey. Hit Go to run the script in the editor. What's the difference?