TEXT LENGTH

General questions about using TextPad

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

Post Reply
Samuel

TEXT LENGTH

Post by Samuel »

Is there a way to hightlight a list and tell textpad that you want the list names to be no longer than 10 characters?

Thanks
Alan Bellows

RE: TEXT LENGTH

Post by Alan Bellows »

A macro can accomplish this:

1. Go to the very beginning of the first character of the first line in the list.
2. Go to Macros > Record.
3. Click Search > Go To...
4. Select Column, Type 10 in the input box, and click Go To
5. Hold down the Shift key, press End on the keyboard, release Shift and press Delete on the keyboard.
6. Press the keyboard down arrow once, and press Home.
7. Go to Macros > Stop Recording
8. Give it a name, and under "Default Play Mode" select "Repeat Through Selection" and save it.
9. Now, if you highlight the list and run the macro, every item should be shortened to 10 characters.

Good luck, let me know if I was in any way unclear... by the way, I can e-mail you the macro if you'd like, I still have it on my drive.

Alan Bellows
Software Developer, Epixtech
Alan Bellows

RE: TEXT LENGTH

Post by Alan Bellows »

Hmmm, hold on... I found a problem with that macro. Any lines LESS than 10 characters get the line break at the end of them clobbered. I can't think of any way around that using macros. Normally I'd just use a Perl script, but that requires that you have Perl installed and that you have some familarity with it. For instance, the following Perl script would work:

my $file = shift @ARGV;
open(LIST, $file) or die "Failed to open file!";
my @list = <LIST>;
close(LIST);
foreach $item (@list) {
chomp($item);
$item = substr($item, 0, 10);
}
foreach $item (@list) {
print "$item\n";
}
print "\nEND OF LIST\n";
Jeff Epstein

RE: TEXT LENGTH

Post by Jeff Epstein »

I think a simple regular expression can do the trick:

Find What: ^\(.\{10\}\).*
Replace With: \1
Hex ( ) Text (o)
Regular Expression: [X]
Scope: Selected Text
(...the rest of the settings don't matter...)

This takes the first ten characters at the beginning of the line:

^\(.\{10\}\)

Where
^ signifies the "beginning of the line"
. means "any character"
\{...}\ is the "Interval operator"
\(...\) is what declares this expression as "\1"


and any following characters, up to the end of the line

.* Meaning "zero or more of any character"

And replaces it with \1, meaning everything between \( and \)


Check out the documentation on regular expressions for more information. It took me quite a while to get the hang of regular expressions, but they are very cool once you get it.
Robbage

RE: TEXT LENGTH

Post by Robbage »

...or...

Turn Block Select Mode on

Move the cursor to the first character of the first line
Press and hold shift. Cursor right 10 characters
Cursor down the number of lines required.
Press Ctrl-C or select the copy menu item,

Paste the clipboard whereever you want.

Turn Block Select Mode off.
Post Reply