function writeScript sourceScript,varName
if varName is empty then put "scriptVar" into varName
put quoteLines(sourceScript) into resultScript
repeat with i = 1 to the number of lines in resultScript
put "put " before line i of resultScript
put " after " & varName after line i of resultScript
end repeat
put "put empty into " & varName & return before resultScript
return resultScript
end writeScript
This article is adapted from the Claris Tech Info database.