Jump to content
Sign in to follow this  
RobinReumers

Import txt into field

Recommended Posts

Hi,

Is there a way to import a txt file into one single field instead of breaking it up into multiple records? I'd like to import the whole content of one txt file into one field / variable! Any help would be appreciated!

Robin

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Thanks a lot for the reply! As this application will also be running on a PC client (no Applescript), I think the easiest way is for me to do the import folder step and make sure taht just that file is in the folder!

Robin

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

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