Here’s another one!
If you look at this thread, you’ll see what its supposed to look like:
http://macscripter.net/viewtopic.php?id=43701
But when I open it, it’s garbled. even when I try to revert to and older one that I knw was good, they’re all garbled too. HELP!
--Select the product to be deleted first
tell application "Finder"
set myProduct to the «class pusl» of «class TxtW» 1
set tagLength to 41 + 1
set colorCodeLength to 8
set specialClassesLength to 2
set thumbsLine to "<thumbs>"
set headlineColors to "headlineColors"
set subheadlineColors to "subheadlineColors"
set legalColors to "legalColors"
set specialClasses to "specialClasses"
-------------------------------------------------
--find the line that the thumbs tag is on
«event R*chFind» thumbsLine with «class SelM» given «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:text, «class STop»:true, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false}
copy the «class SLin» of «class pusl» of window 1 to thumbsLineCount
-------------------------------------------------
--find the line that the desired product tag is on
«event R*chFind» myProduct with «class SelM» given «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:text, «class STop»:true, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false}
copy the «class SLin» of «class pusl» of window 1 to productLineCount
-- and subtract it from the thumbs line
set productNumber to productLineCount - thumbsLineCount
set productColor to productNumber - 1
-----------------------------------------------
--Delete the entire line that the product is on
set deleteProductLine to line productLineCount of «class TxtW» 1
delete every character of deleteProductLine
-------------------------------------------------
--LINE COUNT 1
--find the text color tag and get its line number and set var lineCount1
«event R*chFind» headlineColors with «class SelM» given «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:text, «class STop»:true, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false}
copy the «class SLin» of «class pusl» of window 1 to lineCount1
--select first char of chosen product color
select character (productColor * colorCodeLength + tagLength) of line lineCount1 of text of window 1
set startMark to «class Ofse» of «class pusl» of «class TxtW» 1
-- and find next pipe char and extend selection
set targetColor to «event R*chFind» "[|]" with «class ExSl» given «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:false, «class Wrap»:false, «class Rvrs»:false, «class Case»:true}
set endMark to «class Ofse» of targetColor's «class MSpc»
select (characters startMark thru endMark) of «class TxtW» 1
set text of «class pusl» to ""
-----------------------------------------------
--LINE COUNT 2
--find the text color tag and get its line number and set var lineCount2
«event R*chFind» subheadlineColors with «class SelM» given «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:text, «class STop»:true, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false}
copy the «class SLin» of «class pusl» of window 1 to lineCount2
--select first char of chosen product color
select character (productColor * colorCodeLength + tagLength) of line lineCount2 of text of window 1
set startMark to «class Ofse» of «class pusl» of «class TxtW» 1
-- and find next pipe char and extend selection
set targetColor to «event R*chFind» "[|]" with «class ExSl» given «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:false, «class Wrap»:false, «class Rvrs»:false, «class Case»:true}
set endMark to «class Ofse» of targetColor's «class MSpc»
select (characters startMark thru endMark) of «class TxtW» 1
set text of «class pusl» to ""
-----------------------------------------------
--LINE COUNT 3
--find the text color tag and get its line number and set var lineCount3
«event R*chFind» legalColors with «class SelM» given «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:text, «class STop»:true, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false}
copy the «class SLin» of «class pusl» of window 1 to lineCount3
--select first char of chosen product color
select character (productColor * colorCodeLength + tagLength) of line lineCount3 of text of window 1
set startMark to «class Ofse» of «class pusl» of «class TxtW» 1
-- and find next pipe char and extend selection
set targetColor to «event R*chFind» "[|]" with «class ExSl» given «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:false, «class Wrap»:false, «class Rvrs»:false, «class Case»:true}
set endMark to «class Ofse» of targetColor's «class MSpc»
select (characters startMark thru endMark) of «class TxtW» 1
set text of «class pusl» to ""
-----------------------------------------------
--LINE COUNT 4
--find the text color tag and get its line number and set var lineCount4
«event R*chFind» specialClasses with «class SelM» given «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:text, «class STop»:true, «class Rvrs»:false, «class Case»:false, «class Wrds»:false, «class ExSl»:false}
copy the «class SLin» of «class pusl» of window 1 to lineCount4
--select first char of chosen product color
select character (productColor * specialClassesLength + tagLength) of line lineCount4 of text of window 1
set startMark to «class Ofse» of «class pusl» of «class TxtW» 1
-- and find next pipe char and extend selection
set targetColor to «event R*chFind» "[|]" with «class ExSl» given «class FnIn»:text 1 of «class TxtW» 1, «class Opts»:{«class SMod»:«constant SModGrep», «class STop»:false, «class Wrap»:false, «class Rvrs»:false, «class Case»:true}
set endMark to «class Ofse» of targetColor's «class MSpc»
select (characters startMark thru endMark) of «class TxtW» 1
set text of «class pusl» to ""
end tell
--replace (characters 114 thru 121 of line 14) of text window 1 using ""