I’m using an AppleScript to search and replace in an HTML BBEdit file. Is there syntax available for including line returns in the replace string? In the following fragment I’d like to insert a real line return between and .
Yes, the HTML code works just fine without a return, but returns in the correct place definitely makes HTML code easier to read. I’ve tried adding \r in between but AppleScript just adds the characters /r to the file, not an actual line return. Haven’t been able to find anything in the AppleScript Dictionary for BBEdit.
I use \r. If you use \r it is escaping the backslash and will
add an actual \r just as if it were text.
--insert return after ;
set x to my simpleReplace(";", "; <--the \r went here
In this example I entered the \r just after the second ; in the second line.
When I compiled the script the \r is replaced with the actual return
and takes the code following the \r and puts it on the next line.
Let me know if this does not solve your problem.
When the AppleScript is compiled \r does indeed disappear, replaced by a line return.
However when the script is made to run on a BBEdit file here’s the result – vertical rectangle symbol , all on the same line. Exactly the same as if I manually entered a return in the AppleScript at that point. Obviously placing an unknown ascii character instead of a line return.
Would you mind posting your script.
does this not work?
Probably, but I’ve been caught up with non-scripting issues in the past couple of days. Your solution is indeed very probable, just depends on whether that syntax is understood by AppleScript. So often the answer is obvious, right there in front of you, just not seen until its features are pointed out by someone else.
Will respond yeah or nay likely tomorrow, when I finally get back to coding.
Yes, it’s true, it’s true. The syntax " & return & " does indeed insert a return at the designated spot. Tested and it works.
In hindsight, is self evident, but not when you’re just starting out with AppleScript.