Core FileMaker Blog

Keep up to date with CoreSolutions

Writing Plain text from FileMaker Pro

2004-02-29_Ball_point_pen_writing

In some cases, you might be able to get away with putting the text that is ultimately to be written to a file, within a single field in your database, and simply choosing to “Export Field Contents”. What I’ve been finding more and more lately though, is that the written file’s encoding is such that the resultant file cannot be used as intended.

Whenever that approach fails for me, my next logical step is to turn to the “Export Records” script step. This one has the benefit of letting me specify the Output file character set. This fixes the problem that I have with encoding using the “Export Field Contents” script step. Moving forward from here, the process is very similar. I will isolate a single record, and export only the one field’s contents for that one record. Simple. Then comes the point in time where I have to specify the output file’s type though. You’ll quickly realize that there’s no option to specify plain text, so I usually end up selecting either a .tab file or a .csv file. Both of those their own drawbacks though, and sometimes the resultant export no longer matches the text you wanted to export verbatim.

The next approach that I’ve taken in the past is going to be OS dependent. There are various ways to write text files using features specific to your OS, such as using the command line (Send Event ; cmd /c) on Windows, or using some AppleScript for instance on OSX. Obviously though, I want to avoid limiting my solution to working on only one type of platform. That rules out this approach as well.

Because of all these issues, the only way I was ever able to accomplish writing plain text from within FileMaker in the past involved using a plugin. This works remarkably well, however, I like to avoid using plugins whenever and wherever I can.

This brings me to the new approach that I’ve been taking lately, and it’s one that some of you have probably already used… but it’s new to me.
Lately, my approach to this problem uses Export Records (so that I get the benefit of choosing the file’s encoding), but instead of specifying the formats that I deemed appropriate in the past (.csv, .tab), I’m now choosing to Export XML. When you choose to export XML, you will also be granted the opportunity to transform that XML using XSLT. XSLT can be as simple or as powerful as you need it to be. We have a very simple task to perform here however, so our XSLT will be very simple also.

The XSLT file that I wrote for this purpose essentially just strips away all of the extra XML baggage that gets written when you export records as XML from within FileMaker. It assumes of course, that you’ve only chosen to export a single field (like in the examples specified above).

Download XSLT

PS –> If you’ve come up with a more elegant solution to this problem, I’d love to hear it!

 

Leave a comment

CoreSolutions Logo

London Office:
1-1615 N Routledge Park
London, ON N6H 5L6

Toronto Office:
2425 Matheson Blvd East
7th Floor
Mississauga, ON L4W 5K4

Toll Free: (800) 650-8882
London: (519) 641-7727
Toronto: (416) 410-8649
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.

SUBSCRIBE

Click the 'Subscribe' button to sign up for news & software tips.

Beyond Software

Copyright © 2018 CoreSolutions Software, Inc. All Rights Reserved