Edit each line in a document


The text window class is the window that contains all of the documents open. The text document class contains the text itself. To interact with the text in an object-oriented manner, call text window n -> text n -> lines.


(*
text window n
text document n
contents --plain text

text window n
text 1
lines --objectified text
*)

tell application "BBEdit"

tell text window 1
tell text 1
repeat with thisLine from startLine to endLine
set contents of line thisLine to CreateConstant(contents of line thisLine) of me
end repeat
end tell
end tell

end tell

on CreateConstant(theVariable) -- (theVariable as string) as string
(* Const constantName = "value" *)
return "Const k_" & theVariable & " = \"" & theVariable & "\""
end CreateConstant