Jump to content

Write fields to flat file?


This topic is 7829 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • 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

Link to comment
Share on other sites

  • 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.

Link to comment
Share on other sites

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 " &

Link to comment
Share on other sites

  • 3 months later...

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

Link to comment
Share on other sites

This topic is 7829 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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