AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Eliminating two exactly same lines

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
TestPilot



Joined: 26 Jun 2007
Posts: 52

PostPosted: Wed Apr 16, 2008 7:32 am    Post subject: Eliminating two exactly same lines Reply with quote

I want my script to catch and delete lines/paragraphs that identical and follow each other. Example:

Quote:
PHEVs are similar to current hybrid electric vehicles but have larger batteries that can be charged from the electric grid. More and more consumers are buying HEVs – sales in the US have grown by 80% per year since 2000. The same trend might be expected for PHEVs in the future. What's more, car manufacturing firms such as Toyota and Ford are now offering to convert HEVs into PHEVs and plan to sell retrofit kits to help consumers "upgrade".
Plug-in hybrid
Plug-in hybrid
By using grid electricity, PHEVs could reduce a driver's fuel costs by hundreds of dollars per year. However, car battery costs need to decrease by at least 50% from current levels to make PHEVs economical for most consumers, says team member Alex Farrell. At present, near-term costs for PHEVs appear to be too high to justify the savings that come from buying electricity, which is cheaper than gasoline. But economic calculations are only part of the reason consumers buy cars, Farrell adds, so some people would probably buy PHEVs even at current costs.
Another important result from the team's work is that the time when PHEVs are charged needs to be properly managed. There is sufficient electricity capacity to charge several million PHEVs in California without expanding the electricity grid in the state. But adding even one single PHEV to the grid at peak hours (2.00 p.m. to 6.00 p.m.) will create demand for new electricity infrastructure, explains Farrell.
Charging up
Charging up
"These results are important because PHEVs offer consumers a whole new choice, and a way to advance key social goals – including reducing consumption of petroleum and lowering greenhouse gas emissions," he told environmentalresearchweb.


I want to become

Quote:
PHEVs are similar to current hybrid electric vehicles but have larger batteries that can be charged from the electric grid. More and more consumers are buying HEVs – sales in the US have grown by 80% per year since 2000. The same trend might be expected for PHEVs in the future. What's more, car manufacturing firms such as Toyota and Ford are now offering to convert HEVs into PHEVs and plan to sell retrofit kits to help consumers "upgrade".
By using grid electricity, PHEVs could reduce a driver's fuel costs by hundreds of dollars per year. However, car battery costs need to decrease by at least 50% from current levels to make PHEVs economical for most consumers, says team member Alex Farrell. At present, near-term costs for PHEVs appear to be too high to justify the savings that come from buying electricity, which is cheaper than gasoline. But economic calculations are only part of the reason consumers buy cars, Farrell adds, so some people would probably buy PHEVs even at current costs.
Another important result from the team's work is that the time when PHEVs are charged needs to be properly managed. There is sufficient electricity capacity to charge several million PHEVs in California without expanding the electricity grid in the state. But adding even one single PHEV to the grid at peak hours (2.00 p.m. to 6.00 p.m.) will create demand for new electricity infrastructure, explains Farrell.
"These results are important because PHEVs offer consumers a whole new choice, and a way to advance key social goals – including reducing consumption of petroleum and lowering greenhouse gas emissions," he told environmentalresearchweb.


Those lines always start from new line and follow each other.
I can fix above text with something like
Code:

clipboard:=RegExReplace(clipboard, "Plug-in hybrid\R", "")
clipboard:=RegExReplace(clipboard, "Charging up\R", "")

but real problem is that text in redundant lines always different Confused And it could be way more then two words - but it always new lines following each other.

PS. This happens all the time when I copying text from Wikipedia or blog articles into clipboard using Firefox - any image descriptions create two new identical lines, and I don't want image descriptions in a clipboard.

Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Wed Apr 16, 2008 8:35 am    Post subject: Reply with quote

Code:
~^c::
sleep 2000 ; 'clipwait' may not be ideal in this case
StringReplace, Clipboard, Clipboard, `r`n, `n, all
Sto := ErrorLevel
Loop, Parse, Clipboard, `n
{
   If ( aline == A_LoopField )
      Loop 2
         StringReplace, Clipboard, Clipboard, `n%aline%`n, `n
   If A_LoopField
      aline := A_LoopField
}
If !Sto
   StringReplace, Clipboard, Clipboard, `n, `r`n, all
return
Try that, it fires when you use [ctrl][c] to copy text.
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
TestPilot



Joined: 26 Jun 2007
Posts: 52

PostPosted: Wed Apr 16, 2008 9:03 am    Post subject: Reply with quote

Wow. Thank you. It do work perfectly.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group