![]() It then splits this block of text into lines, stripping off the last line if it’s “USA” or any of the other names in the usNames property defined in Line 12. The addressFromName function finds the contact from their name (Line 64) and gets the first address listed for that contact (Line 67). Both of these functions return a list of address lines in the variable plainList, which is then reformatted on Line 28 by the latexify function and then pasted at the cursor position of the current document by the tell application "LaunchBar"… command on Line 31. If there’s more than one line, we know the argument is an address block, and the addressFromAddress handler is called. If there’s only one line, we know that the argument is the full name of the contact, and the addressFromName handler is called. The handle_string function splits its argument into a list of lines (in AppleScript parlance, paragraphs are separated by linefeeds). Depending on how LaTeXAddress is called, it will get passed either the name of the selected contact-e.g., John Appleseed-or the selected address, which will be a block of text in this form: Apple, Inc. The handle_string handler, Lines 15–32, is required and is the entry point for the script. ![]() One of the job-specific parts is the name and address of the client, which, in a LaTeX letter, is the second argument to the \begin block: \beginġ4: - Handle string passed in from LaunchBarġ8: - Get the plain name and address as a list of text lines.ġ9: - The method called depends on whether a single-line nameĢ0: - or multi-line address (with attn:) is passed in.Ģ4: set plainList to addressFromAddress(sList)Ģ7: - Convert from plain name and address to LaTeXģ1: tell application "LaunchBar" to paste in frontmost application blockTextģ5: - Strip the US line part of the address if it's thereģ7: if last item of aList is in usNames thenĤ3: - Convert from list of lines of plain address to text blockĤ4: - formatted according to LaTeX rulesĤ6: set oldDelims to AppleScript's text item delimitersĤ7: set AppleScript's text item delimiters to linefeedĤ9: - Escape the ampersands and end each line except the last with two backslashesĥ0: set cmd to "echo " & quoted form of (aList as text) & ¬ĥ6: set AppleScript's text item delimiters to oldDelimsĦ4: set match to first item of (people whose name is fullname)Ħ6: - Get the address and strip the country if USĦ7: set addr to formatted address of first item of (addresses of match)ħ1: - Add the company to the top of the list of linesħ7: - Add the name to top of the list of linesħ8: set beginning of addrList to fullnameĩ1: - Loop through and find the addressee via the attn: lineĩ2: - Keep track of the attn: line number and save in aLineĩ5: if (word 1 of theLine) is "attn" thenĩ7: set addressee to text 7 thru aLength of theLineġ03: - Build a list with everything except the attn: lineġ04: set addrList to items 1 thru (aLine - 1) of aList & items (aLine + 1) thru -1 of aListġ05: set beginning of addrList to addressee 1 I write the letter in LaTeX, using TextExpander for the boilerplate and then filling in the job-specific parts. ![]() ![]() When I send a proposal for new work to a client, I do it in the form of a letter addressed to the client and emailed to them as a PDF attachment. Next post Previous post LaunchBar and LaTeX ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |