Formatting text file in AppleScript

Discussion in 'Mac Programming' started by dam316, May 5, 2014.

  1. dam316 macrumors newbie

    May 4, 2014

    I'm trying to create a txt file from applescript without automating textedit. I'm very new to applescript and trying to keep it simple. I've managed to create a txt file and write my data to it using the WRITE command, but is there a way to format it more?

    My script is creating receipts from a csv file. At the moment I'm mainly interested in trying to insert a page break after each receipt. But I'd also like to know if there are ways to format the text - bold, underline, maybe change font size / page size - etc with out having to automate it. Or do I have no choice but to open text edit and use the whole TELL command thing...

    Any advice would be appreciated!
  2. chown33 macrumors 604

    Aug 9, 2009
    descending into the Maelström
    There's a fundamental flaw in your premise: A plain txt file can't have formatting.

    That's the very definition of plain text: unformatted. If you apply formatting, the text is no longer plain.

    There are many different ways to apply formatting to text, but they all involve adding extra data, called markup or formatting codes. Two examples are HTML and RTF.

    Another approach would be simplified markup text embedded in plain text, which is later interpreted to produce other formats. An example is Markdown:

    Any of these formats can be produce by concatenating the desired text with the appropriate markup codes.

    You said you're creating receipts from CSV, but you didn't say what the receipts are for. Please describe the entire process, so we have an idea of what the overall goal is, as well as its scale.

Share This Page