4.4. Multiline StringsIf you've spent any time working in a word processing program like TextEdit or Microsoft Word, you already know that text often spans multiple lines. Unlike typewriters from days of old, you don't have to hit the Return key when you reach the end of a line. Instead, the text just wraps around to the next line, and you continue typing until you reach the end of a paragraph. There are, however, certain times when you might like to break text up onto multiple linessuch as typing your mailing address at the top of a letterand for that, the trusty Return key is right there by your side. But what if you want to use such multiline strings in AppleScript, so you can display a dialog box containing a friend's address, for example? Thankfully, AppleScript supports multiple-line strings as well, but you'll need to enlist some help from escape sequences. Escape sequences are little chunks of slashes and letters that tell AppleScript, "Please insert a special symbol here." To insert a newline symbol in a stringthus knocking text onto the next lineyou use the \n escape sequence. For example, if you ran the following script, you'd see the dialog box shown in Figure 4-3: set multiLiner to "To whom it may concern,\nI want my money back.\nThanks." display dialog multiLiner
There are other escape sequences you can use in your strings, too (Table 4-1 has a list of the most common). Such escape sequences allow you to make AppleScript strings that match what you could create in a TextEdit or Microsoft Word document. That way, you can display dialog boxes with all sorts of punctuation insidenot just letters and numbers.
|