Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

  • Newbies
Posted

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

  • Newbies
Posted

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.

Posted

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

Posted

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
Posted

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

Posted

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

Posted

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.

This topic is 8017 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.