Jump to content

Import txt into field

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

Recommended Posts

I can think of a couple of ways. A native FileMaker method would be to use the Import Folder step. It will import text files into a single field. But, of course, you'd have to put the single file into a folder first.

Another slightly more difficult, but more convenient method would be to use AppleScript to read the file, then set it into a field.

Or use a file plug-in. But that's really the same thing, for more money.

This is an AppleScript that reads a chosen text file using the Unix "cat" command line. It creates a new record in the frontmost FileMaker window with the name and contents:

global theName

global theContents

set theFile to choose file with prompt "Choose a text file"

tell application "Finder"

	set theName to name of theFile

	set posFile to quoted form of POSIX path of theFile

	set theContents to do shell script "cat " & posFile

	-- converts Unix to Mac returns

	my FM_Create_Record()	

end tell

on FM_Create_Record()

	tell application "FileMaker Pro Advanced" -- not needed in FileMaker

		tell window 1

			set newRec to the ID of (create new record)

			go to record ID newRec

			set cell "Filename" of current record to theName

			set cell "Contents" of current record to theContents

		end tell

	end tell -- me neither

end FM_Create_Record

Link to comment
Share on other sites

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