Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Write fields to flat file?

Featured Replies

  • Newbies

I'm new to Filemaker and trying to write some information from a database to a flat file. I don't know how to in Filemaker, so I've tried the "perform applescript" route, but get expected end of line compilation errors (on the write statement) when trying this (as an example - the myfile exists to start with)

set target_file to "myfile"

open for access file target_file with write permission

set eof file target_file to 0

write "example text stuff" to file target_file starting at eof

close access file target_file

display dialog "Done"

this applescript works from the script editor.

Is this something that could be done easily directly from filemaker, i.e. export fields directly to flat file?.

Thanks

Errr, isn't a normal export data file flat?

  • Author
  • Newbies

By flat file I simply meant a text file that would consist of plain text, with carriage return/line feed between each field written. And not one of the standard export file types, i.e. tab, comma, SYLK, DBF etc etc etc

In fact I guess I'm asking if there is a way to export fields separated by carriage return/line feed.

Here is your script...

tell application "FileMaker Pro" to set theDB to every record

set destinFolder to choose folder with prompt "Select a folder for your new file"

repeat

display dialog "Enter the name for the file" default answer "FlatFileExport.txt"

set fileName to text returned of the result

set FilePath to (destinFolder as string) & fileName

try

set fileAlias to alias FilePath

on error

exit repeat

end try

display dialog "File with the name " & fileName & " exists in the folder " &

You can use tab delimited and export a single calculated field comprised of all the fields you want to export concatenated together with paragraph characters (aka carriage returns) in between, like so:

OutputField = Field1 & "

  • 3 months later...
  • Newbies

Hello Bob,

I tried your method but it doesn't work.

Instead of carriage returns I get blank spaces in the plain text file.

Any idea what I should do ?

Greetings, Peter

I've had the same problem, and I can sympathise. In closer examination, however, I found that it wasn't exporting blank spaces, it was actually (and I don't know how it picked this one) inserting the 'column break' character. I just made my applescript open up the text file after export in a text editor (Style is a very good one, for scripting), and search and replace all the instances of column break with a carriage return. Hope that helps. I can send you the AS, if you want.

BTw, if you want to bypass it altogether, the diStyler plugin will create a text file verbatim from your original field, that is, it will actually just make a text field that contains the value of some field. So you could build a field inside the DB that looks how you want, then export it with diStyler

Yes. Sorry, you're right. I overlooked the fact that Filemaker converts the <CR> characters to 'soft returns'. So, you have to process the file afterwards with applescript or another utility to convert them back to carriage returns.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.