Jump to content
Server Maintenance This Week. ×

Can't access the data inside of a container field? FMP12


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

Recommended Posts

Hi,

 

it's probably very easy, but I don't know how to access the data inside of a container field.

 

I have a script that inserts a small text file (insert, no reference) into a container and all I can see is a file icon with the filename. When I use «GetAsText(ContainerField)», I only get the filename. But how can I access the data inside of this container/file?  I need to perform a couple of text manipulations and store the results in another field of this record.

 

Thanks so much for any help.

 

Gary

 

Link to comment
Share on other sites

That's not something that FM supports natively.  When you insert a file into a container, you insert the binary file, not the contents of the file.  If you need the contents you will need to resort to a plugin for that.  Or do some OS-level manipulation using the OS scripting languages.

Link to comment
Share on other sites

Thanks for the quick reply!

 

So, what you are saying is that there is no way to access even the binary data?  Wow, that's a surprise.

 

I don't know enough AppleScript (I'm on a Mac) to be able to do this.  Any suggestions?

 

Thanks a lot,

 

Gary

Link to comment
Share on other sites

After a couple of hours of trial and error, i have found the easiest way to read a text file into a text field, using a shell command inside an AppleScript (Mac only):

 

Compose a variable $script (for example) and use it in an AppleScript script step:

 

$script =

- - - - - - - - - - - - - - -

 

set fn to choose file
copy POSIX path of fn as text to cell "Path" of current record
set cell "Text" of current record to (do shell script "cat /Users/gc/Desktop/A00542721.txt")

- - - - - - - - - - - - - - -

 
The pathname is still hard coded here, so that you get the idea. I have divided that into two small scripts. In the first, I am saving the file name of the file that the user chose into a gobal «Path» field. And in the second I use this path field to read the contents of the file into my field «Text».
 
I hope that someone finds this useful.
 
I'm still puzzled that FileMaker can't do this simple task by itself.
 
 
Gary
Link to comment
Share on other sites

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