Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Is there a way of creating an external function to allow the user to select a text file, and have it inserted into a text field?

Unfortunately, FM8 will allow a text file to be inserted into a container, but the text cannot be manipulated once there.

Regards,

Charlie

Posted (edited)

There's a couple of ways. If it must be cross-platform you could use the Import Folder step, and choose "text files" as the type. It will read all text files of the folder into a single field. Obviously a little awkward if you only want to do one file and it's not in a folder by itself. Easiest solution to that is to use the Troi File plug-in, which can let you choose or specify a file, then read it.

On a Mac you can easily use AppleScript to tell the Finder to read the file (FileMaker itself doesn't like the "read file" command). In a Perform AppleScript step. All fields below are on the current layout, or else you need to specify which layout. _cFilePath_Mac is an unstored calculation, same for all records, in Mac syntax, ie.:

"Macintosh HD:Users:fej:Documents:FileMaker:My_FM:FM 8:8 features.fp7"

set theFile to choose file -- returns an alias

tell application "Finder" to set fileTxt to (read theFile)

set cell "FileText" of current record to fileTxt

or, with a pre-determined file:

set filePath to cell "_cFilePath_Mac" of layout "AS"

tell application "Finder" to set fileTxt to (read file theFile)

set cell "FileText" of current record to fileTxt

[Last but fast, use the shell]

set macFile to choose file

set posFile to quoted form of POSIX path of macFile

set fileTxt to (do shell script "cat " & posFile)

set cell "FileText" of current record to fileTxt

Edited by Guest
Added shell

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