Re: Flip a Table

2010-07-09 Thread John Delacour

At 13:12 -0600 7/7/10, LuKreme wrote:


On 5-Jul-2010, at 14:48, John Delacour wrote:

 then it is simple.  Just write the following little routine, 
select the lines in the document you want to reverse and run the 
script.


You don't even need a script.

TEt Menu - > Sort lines -> Using Pattern and check "Reverse Sort"


Sure, but if you never learn what scripts can do you'll never learn 
how to do things that aren't in the menu.


JD

--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-07 Thread LuKreme

On 5-Jul-2010, at 14:48, John Delacour wrote:

> then it is simple.  Just write the following little routine, select the lines 
> in the document you want to reverse and run the script.

You don't even need a script.

TEt Menu - > Sort lines -> Using Pattern and check "Reverse Sort"

-- 
The early bird gets the worm, but the second mouse gets the cheese.

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-06 Thread Warren Michelsen

At 2:44 PM -0400 7/6/10, Patrick Woolsey sent email regarding Re: Flip a Table:

At 10:11 -0700 07/06/2010, Warren Michelsen wrote:

[...]

I selected the lines I want to reverse within the front-most BBEdit
doc, then selected the JD script from the menu. Nada.

Am I using the script incorrectly?



Please make sure you're applying this code as a filter.

Specifically, it should be stored in the "Unix Filters" folder:

~/Library/Application Support/BBEdit/Unix Support/Unix Filters/

and applied via #! -> Unix Filters -> scriptfile.pl or from the "Unix
Filters" palette.


OK, that works. Thanks muchly to you and JD.

--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-06 Thread Patrick Woolsey
At 10:11 -0700 07/06/2010, Warren Michelsen wrote:

[...]
>I selected the lines I want to reverse within the front-most BBEdit
>doc, then selected the JD script from the menu. Nada.
>
>Am I using the script incorrectly?


Please make sure you're applying this code as a filter.

Specifically, it should be stored in the "Unix Filters" folder:

~/Library/Application Support/BBEdit/Unix Support/Unix Filters/

and applied via #! -> Unix Filters -> scriptfile.pl or from the "Unix
Filters" palette.


Regards,

 Patrick Woolsey
==
Bare Bones Software, Inc.
P.O. Box 1048, Bedford, MA 01730-1048


-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-06 Thread John Delacour

At 12:56 -0400 6/7/10, Patrick Woolsey wrote:


Both filters and scripts must start with a valid shebang line.


The file in question is in my UNIX Filters folder and has the suffix 
.pl.  It has no shebang, like several other filters, and works fine. 
So does BBEdit know something the manual doesn't — for example, if it 
has the .pl suffix it's a perl script?


I'm not in the habit of writing perl scripts without a shebang, so I 
wonder what led me to omitting in my UNIX filters.


JD


--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-06 Thread Warren Michelsen
At 12:56 PM -0400 7/6/10, Patrick Woolsey sent email regarding Re: 
Flip a Table:


Both filters and scripts must start with a valid shebang line.


Which is entirely reasonable.

Adding the shebang line, while it eliminates the error message, does 
not make the script do anything. The script appears to do nothing. No 
errors, no change to the front-most BBEdit doc with the selected 
lines.


I selected the lines I want to reverse within the front-most BBEdit 
doc, then selected the JD script from the menu. Nada.


Am I using the script incorrectly?

--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-06 Thread Patrick Woolsey
>At 9:41 AM +0100 7/6/10, John Delacour sent email regarding Re: Flip a Table:
>>At 17:49 -0700 5/7/10, Warren Michelsen wrote:
>>
>>>Is this a Perl script? Should it start with:
>>>#!/usr/bin/perl
>>
>>Yes; and no, it makes no difference if it is run as a UNIX filter in BBEdit.
>>
>>JD
>
>When put unto: "~/Library/Application Support/BBEdit/Unix
>Support/Unix Scripts/Reverse Lines" and run from the shebang menu -->
>Unix Scripts, I get:
>"This file doesn't appear to contain a valid 'shebang' line
>(application error code: 13304)"
>
>So, this is why I asked.


Both filters and scripts must start with a valid shebang line.


Regards,

 Patrick Woolsey
==
Bare Bones Software, Inc.<http://www.barebones.com>
P.O. Box 1048, Bedford, MA 01730-1048

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-06 Thread Warren Michelsen

At 9:41 AM +0100 7/6/10, John Delacour sent email regarding Re: Flip a Table:

At 17:49 -0700 5/7/10, Warren Michelsen wrote:


Is this a Perl script? Should it start with:
#!/usr/bin/perl


Yes; and no, it makes no difference if it is run as a UNIX filter in BBEdit.

JD


When put unto: "~/Library/Application Support/BBEdit/Unix 
Support/Unix Scripts/Reverse Lines" and run from the shebang menu --> 
Unix Scripts, I get:
"This file doesn't appear to contain a valid 'shebang' line 
(application error code: 13304)"


So, this is why I asked.


--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-06 Thread John Delacour

At 17:49 -0700 5/7/10, Warren Michelsen wrote:


Is this a Perl script? Should it start with:
#!/usr/bin/perl


Yes; and no, it makes no difference if it is run as a UNIX filter in BBEdit.

JD





while (<>) {
  chomp;
  push @_, $_
}
for (reverse @_){
  next if /^$/; # ignore blank lines
  print "$_\n";
};


--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-05 Thread Warren Michelsen

At 9:48 PM +0100 7/5/10, John Delacour sent email regarding Re: Flip a Table:

At 10:37 -0700 5/7/10, Warren Michelsen wrote:

...I'm guessing that Perl is the best tool for this job. It has a 
reverse function so I'm guessing that the original selection could 
be read into an array, using "" as delimiters, then 
regurgitated in reverse order of the original.



How you do it will depend on where your line-breaks are.  If your file reads

1
2
3
4
5

then it is simple.  Just write the following little routine, select 
the lines in the document you want to reverse and run the script.



#UNIX SCRIPT:


Is this a Perl script? Should it start with:
#!/usr/bin/perl

?





while (<>) {
  chomp;
  push @_, $_
}
for (reverse @_){
  next if /^$/; # ignore blank lines
  print "$_\n";
};

Run the above script from the palette or with a key-shortcut to get:



--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-05 Thread Warren Michelsen

At 12:48 PM -0700 7/5/10, Bill Rowe sent email regarding Re: Flip a Table:

This can be done in BBEdit with out a separate scratch file as follows:

Go to Text->Add/Remove Line Numbers...

Add suitable line numbers to the lines you want to reverse the order 
of with a space between the line number and data you want retained.


Then to to Text->Sort Lines...

Select Numbers match by value and Reverse sort. Finally go back to 
Add/Remove Line Numbers... to remove the line numbers previously 
added.


The result will be a reverse order of the data.


Just had to format "compact" first and replace  with \r to 
get each row on its own line, then this add/remove line numbers trick 
worked fine.


Much less hassle than dragging and dropping multiple table rows one at a time!

--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-05 Thread Robert A. Rosenberg

At 12:48 PM -0700 on 7/5/10, Bill Rowe wrote about Re: Flip a Table:


On 7/5/10 at 10:37 AM, wmichel...@gmail.com (Warren Michelsen) wrote:


I have tables containing data in reverse chronological order. I'd
like it to be chronological so I'm thinking I can just move the
table rows around.



Seems like it would require a separate scratch file to hold the
re-ordered rows until all rows have been copied, then replace the
selection with the re-ordered rows.


This can be done in BBEdit with out a separate scratch file as follows:

Go to Text->Add/Remove Line Numbers...

Add suitable line numbers to the lines you want to reverse the order 
of with a space between the line number and data you want retained.


Then to to Text->Sort Lines...

Select Numbers match by value and Reverse sort. Finally go back to 
Add/Remove Line Numbers... to remove the line numbers previously 
added.


The result will be a reverse order of the data.


This would work BUT first you would need to make sure that each row 
(from  to ) is a single line of HTML. If the row is spread 
over more than one line of HTML, the sort will not produce the 
correct order. The simplest way of doing this is to highlight the 
section of code that represents the rows, use format=compact to make 
all of it a single line, and then do a find/replace of the section to 
add new line codes (\r) after each . IOW: Find "" and 
replace with "\r".


--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-05 Thread John Delacour

At 10:37 -0700 5/7/10, Warren Michelsen wrote:

...I'm guessing that Perl is the best tool for this job. It has a 
reverse function so I'm guessing that the original selection could 
be read into an array, using "" as delimiters, then 
regurgitated in reverse order of the original.



How you do it will depend on where your line-breaks are.  If your file reads

1
2
3
4
5

then it is simple.  Just write the following little routine, select 
the lines in the document you want to reverse and run the script.



#UNIX SCRIPT:

while (<>) {
  chomp;
  push @_, $_
}
for (reverse @_){
  next if /^$/; # ignore blank lines
  print "$_\n";
};

Run the above script from the palette or with a key-shortcut to get:


5
4
3
2
1


JD

--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-05 Thread Bill Rowe

On 7/5/10 at 10:37 AM, wmichel...@gmail.com (Warren Michelsen) wrote:


I have tables containing data in reverse chronological order. I'd
like it to be chronological so I'm thinking I can just move the
table rows around.



Seems like it would require a separate scratch file to hold the
re-ordered rows until all rows have been copied, then replace the
selection with the re-ordered rows.


This can be done in BBEdit with out a separate scratch file as follows:

Go to Text->Add/Remove Line Numbers...

Add suitable line numbers to the lines you want to reverse the 
order of with a space between the line number and data you want retained.


Then to to Text->Sort Lines...

Select Numbers match by value and Reverse sort. Finally go back 
to Add/Remove Line Numbers... to remove the line numbers 
previously added.


The result will be a reverse order of the data.

--
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Re: Flip a Table

2010-07-05 Thread Doug McNutt
At 10:37 -0700 7/5/10, Warren Michelsen wrote:
>I have tables containing data in reverse chronological order. I'd like it to 
>be chronological so I'm thinking I can just move the table rows around.
>
>Seems like it would require a separate scratch file to hold the re-ordered 
>rows until all rows have been copied, then replace the selection with the 
>re-ordered rows.
>
>I.e., Take the last table row (cutting or removing it) from the selection and 
>move it to the scratch area.
>
>Take the last table row and move it to the end of the scratch area. 
>Lather, rinse, repeat until all rows have been cut from the original
>Then move the scratch contents to the original document.
>
>I'm guessing that Perl is the best tool for this job. It has a reverse 
>function so I'm guessing that the original selection could be read into an 
>array, using "" as delimiters, then regurgitated in reverse 
>order of the original.  

If the stuff between  and  has a numeric value or a date between 
embedded in the rows with  and  flags it would be fairly simple to 
store each row in a perl hash keyed to the date item.

It's then a standard operation to pick up the keys in a sorted array which can 
be sequentially used to recall the strings from the hash in any order you want.

I have done things like that but it's probably easier to start afresh than to 
look for old code.  Ask. off line but leave the subject as-is to get by filters.

-- 
--> Give me liberty or give me Obamacare <--

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.


Flip a Table

2010-07-05 Thread Warren Michelsen
I have tables containing data in reverse chronological order. I'd like it to be 
chronological so I'm thinking I can just move the table rows around.

Seems like it would require a separate scratch file to hold the re-ordered rows 
until all rows have been copied, then replace the selection with the re-ordered 
rows.

I.e., Take the last table row (cutting or removing it) from the selection and 
move it to the scratch area.

Take the last table row and move it to the end of the scratch area. 
Lather, rinse, repeat until all rows have been cut from the original
Then move the scratch contents to the original document.

I'm guessing that Perl is the best tool for this job. It has a reverse function 
so I'm guessing that the original selection could be read into an array, using 
"" as delimiters, then regurgitated in reverse order of the 
original.  


Anyone have something like this lying around or an example showing how to get 
table rows into an array?


-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.