6 Replies Latest reply on Jun 10, 2014 7:27 AM by taylorsharpe

    Text field to text file in container field


      Is there a way to use FileMaker 13 calculations to turn a text string into a text file stored in a container field?


      I have a calculated text field (it yields the contents of an HTML page, essentially). I'd like to have a calculated container field with a file called "index.html" that contains the results of my text field. If I have the Base64-encoded version of the file, I can use the Base64Decode() calculation to get my desired result, but I don't know how to get that encoded string. Is there (just wishing here) some sort of standard header/prefix and footer/suffix on Base64-encoded text files that I can prepend/append to my file contents to make a standard encoded file?





        • 1. Re: Text field to text file in container field

          Hi, Rob.


          Is there a reason it has to be base 64? You can create an HTML document by this method quite easily:


          1) Store your HTML code in a field.

          2) Export a single record of just that field in tab-separated text format using a file extension of ".htm" or ".html".


          You can use a global field for this purpose for multi-user safety.


          Once you've created the document, you should be able to get it back into a container field easily enough by retaining the export path in a variable.


          Or is there something I'm missing?



          • 2. Re: Text field to text file in container field

            Hi, Mike. thanks for replying.


            I'm aware of the functionality you describe, but I'm trying to avoid both import/export and scripting to achieve this result. (I had also tried the Export Field Contents script step, but it seems to always create UTF-16 files [at least on a Mac] when I need UTF-8.)


            I was looking at Base64 encoding/decoding because the decoding has the potential for the result I want: a binary text file in the container field. I mentioned it in case there was something obvious I was missing. I had hoped there was something where a Base64-encoded text file had the raw text of the file as the majority of its data, but that doesn't seem to be the case.

            • 3. Re: Text field to text file in container field

              a container field CAN contain TEXT. try it. set a container field to plain text.


              Export Field Contents will be UTF-16 (from a text field), and that can break when uploaded to various places. However, you have to get this data somewhere (presumably), so how are you getting it there without export?


              Base64 will NOT make it a "file", if it's already text, so no need to do this.


              You can put the text into a text field and export one record, one field as "tab" delimited and get UTF-8 (or whatever flavor is selectable). You will find that returns-in-field are still converted to spaces, but an HTML page doesn't care, unless you need a



              I export HTML all the time from FileMaker.



              • 4. Re: Text field to text file in container field

                Hi, Beverly. Thanks for chiming in.


                I know you can put text in a container, but it's not a text _file_. The larger context is that I wanted to use external, open storage for this container field, so that the desired result index.html file is in a specific directory that's being served by a web server. However, I'm seeing that you can't do external storage for a calculated container field, so I'll go back to a scripted export.

                • 5. Re: Text field to text file in container field

                  If you don't like script, there are some plug-ins to write text to file.

                  I like ScriptMaster, but this is not free on server.

                  BaseElements is free.

                  • 6. Re: Text field to text file in container field

                    +1 on BaseElements especially... I use it all the time (Thanks, Goya!).  ScriptMaster is also free, but more complicated (and powerful too) with the full language of Groovy (type of Java).  It is from 360Works.  You can even use ScriptMaster to make your own custom plugin to do whatever you want if you know Groovy.  But with web API's and need for file manipulations so common, and Base Elements having no cost, it is a no brainer to use. 


                    PS:  If you really want to get into text manipulation, you can use the Monkey Bread Software plugin that has the entire CURL language along with about 2400 functions.  Quite amazing.  But it is a commerical license.  However, I use it a lot!