I am assuming that "and replace it with the line number of the line where the number resides-2." actually means "and replace it with the line number of the line where the number resides, which is 2 in this case." and not "and replace it with the line number of the line where the number resides minus 2."
I'm also assuming the document is return delimited and not ascii character 10 delimited. You can alter the "return" in the code below to "ascii character 10" if this assumption is incorrect. In addition this is an untested code snippet written in Safari on Windows in the middle of the night under the influence of insomnia. You'll need to code the assignment of the text of your document to the documentText variable and the replacement of the original text with the newly generated newText variable's contents at the end. Sorry, but I don't recall the BBEdit commands off hand. --assign your document's text to the documentText variable here. set applescript's text item delimiters to "SE*" copy text item 1 of documentText to textChunk1 copy (text items 2 thru end of documentText) as text to textChunk2 set lineNumber to (length of (paragraphs of textChunk1)) + 1 set applescript's text item delimiters to "*" set textChunk2 to (text items 2 thru end of textChunk2) as text set applescript's text item delimiters to "" set newText to textChunk1&"SE*"&lineNumber&"*"&textChunk2 Grep might be an option here, but I really don't see it being simpler in this case. I hope this helps a bit. Paul On Thursday, November 29, 2007, at 08:27PM, "Douglas W McKibbin" <[EMAIL PROTECTED]> wrote: >I want to find a number located in a text file and replace it with >the line number of the line where the number resides-2. The number >to find is located in the only line that starts with "SE*"and resides >between the first and second "*" in the line ..... eg in line >SE*165*29799905~of the text file the number to replace would be 165 >and the replacement number would be the line number of the >SE*165*2799905~ line-2. I think this is pretty simple but I'm not at >all familiar with grep and only mildly literate with applescript. >Thanks for any help. >Douglas McKibbin > >-- >------------------------------------------------------------------------ >Have a feature request? Not sure the software's working correctly? >If so, please send mail to <[EMAIL PROTECTED]>, not to the list. >List FAQ: <http://www.barebones.com/support/lists/bbedit_script.shtml> >List archives: <http://www.listsearch.com/bbeditscripting.lasso> >To unsubscribe, send mail to: <[EMAIL PROTECTED]> > > > -- ------------------------------------------------------------------------ Have a feature request? Not sure the software's working correctly? If so, please send mail to <[EMAIL PROTECTED]>, not to the list. List FAQ: <http://www.barebones.com/support/lists/bbedit_script.shtml> List archives: <http://www.listsearch.com/bbeditscripting.lasso> To unsubscribe, send mail to: <[EMAIL PROTECTED]>
