1 2 Previous Next 22 Replies Latest reply on May 18, 2014 9:19 PM by BenKreunen

    Can FMP print to a plain text file?

    geezerhiker

      Title

      Can FMP print to a plain text file?

      Post

           I have a file with weekly events and I want to display them in a nicely formatted way, one event to a row, grouped by months, with maybe a header and footer. And make a printed report. No problem so far.

           But I also want to export this data, with formatting, into an HTML file so that I can include in a web site. The grouping by months that is handled in FMP by sub-summaries will translate into a series of <table>'s in HTML.

           I have made a layout that uses text boxes full of HTML tags and merge fields and sub-summaries to get all this stuff into a report that looks just like the desired plain text HTML file.  Then I print or export to a PDF file, leave FMP, extract the text from the PDF and paste it into text editor.

           This PDF-extracting nonsense offends my sensibilities - it just seems wrong to package this simple text info into a big, fat PDF file just so I can strip the PDF away.

           It also seems to be a brittle solution - if something changes in the way FMP produces PDFs or in the way Mac OS X handles them my solution could shatter. (In fact, this whole process won't work if my layout used Helvetica instead of Courier!! I discovered this by pure chance and dumb luck, since this has absolutely nothing to do with fonts. BTW I believe the issue there is fixed vs. proportional widths. But who knows, really.)

           I am aware that I can use a calculated field to export the weekly records in the format I like, but that doesn't help with the monthly summary parts. And I suppose I could write a big fat script to generate everything from scratch. But it seems a shame (and, once again, a bit brittle) to reinvent that wheel.

           Attaching images of my layout and a preview for (possible) clarification.

      html.png

        • 1. Re: Can FMP print to a plain text file?
          mgores

               Could you build the htm code for the report into a text field, then use the export field script step to save that field as an .htm?

          • 2. Re: Can FMP print to a plain text file?
            philmodjunk
                 

                      This PDF-extracting nonsense offends my sensibilities

                 Saving as PDF should not be used to produce this type of out put.

                 You have two commonly used options:

                 The export field contents option mentioned by Mark Gores or using Export Records to a text file (which can be XML, or calculation fields that include the needed HTML tags for proper formatting.)

                 Both methods can include summary field type subtotals as part of the exported data. You might want to research the GetSummary field to see one method for computing and using such sub totals.

            • 3. Re: Can FMP print to a plain text file?
              geezerhiker

                   from PhilModJunk: Both methods can include summary field type subtotals as part of the exported data. You might want to research the GetSummary field to see one method for computing and using such sub totals.

                   I don't quite see how the GetSummary function would help me; I am not currently using any summary fields, as my report has no numerical summaries (average, total, etc.)

                   What I need is to get the effect of a summary Part - there is no problem getting the stream of weekly events into HTML format. I need to interrupt that stream every four or five records and insert my monthly header and footer (I.e. leading and trailing sub-summaries).

              • 4. Re: Can FMP print to a plain text file?
                mgores

                     It is a little confusing when you use the term summaries when you don't mean that.

                     What is the criteria for determining where the headers and footers go.

                • 5. Re: Can FMP print to a plain text file?
                  geezerhiker

                       I sorry that was confusing; I referred to "sub-summaries" and "summary parts" and I see how you could confuse those with summary fields. But that is FileMaker's choice of terminology, not mine.

                       Those "headers and footers" (technically speaking, "leading and trailing sub-summaries") go at the beginning and end of each month. The month is a numeric field derived from the "Month" function (I.e., Month(date))

                        

                  • 6. Re: Can FMP print to a plain text file?
                    philmodjunk

                         And since it is quite easy to add such data other than the summary field based sub total to your output, we assumed that you needed help with the slightly more difficult case of acquiring a sub total from a summary field.

                         A looping script, could, just to name one possible approach, loop through the data adding lines of text with appropriate HTML tags to the content of a text field--including sub heading type entries representing a group of records in your found set.

                    • 7. Re: Can FMP print to a plain text file?
                      mgores

                           OK, there are header and footer parts that you can use when you don't need summaries.  But if you are going for an output that is an htm file, you won't want those either as they would be more page breaks.  You would want to have a script build a separate text field and check each line for a change in the Month, if it is detected put in the footer for previous month then header for next month.  If no change, just list the next line.

                           Once you build that field, you can export the field.  If you want you can even have the file name determined by a field, calculation or specify it as you save it.  If done right, it should open up in a browser as is, no stripping or anything else required.  You can even set up a layout with a web viewer in it to preview it and see how it looks.

                      • 8. Re: Can FMP print to a plain text file?
                        geezerhiker

                             Yes, as I was writing my earlier reply an outline of that script started coming to mind. But it would surely be ugly and a bear to debug, what with all the quotes within quoted strings and whatnot. 

                             I suppose I could go that route but, once again, FMP has already done all that work (in the context of summary parts) and I hate reinventing things.

                        • 9. Re: Can FMP print to a plain text file?
                          geezerhiker

                               As long as I've got your attention, perhaps you can help me with building the script.

                               The only "export" script steps I can find are 1. "Export Records" and 2. "Export Field Contents".

                               It looks like "Export Records" will squirt all the found weekly records (or selected fields from same) out in one stream, not allowing me to inject my monthly stuff.

                               OTOH it looks like "Export Field Contents" will create a new file every time it is called.

                               Is there any way to create a file and then append one record or field at a time, as one would do in any normal file system? 

                               Or would I have to try to pile all my data from all my records into one big field? And if that's the case, how the heck would I do that? I don't see any "append" operations anywhere, for files or for fields.

                          • 10. Re: Can FMP print to a plain text file?
                            geezerhiker

                                 OK, answered my own question. "Insert Text" is actually "Append Text" with the option to erase first. Heavens to Betsy, this program is opaque!

                                 And this still looks pretty ugly and redundant.

                                  

                            • 11. Re: Can FMP print to a plain text file?
                              geezerhiker

                                   One more question: If I do build this monster field just for the purpose of exporting its contents, what is the most efficient way to handle it? I'm thinking to create a global field, no? And would it save anything to clear out its contents after I'm done exporting it?

                                    

                              • 12. Re: Can FMP print to a plain text file?
                                mgores

                                     At the end of the script you could have it clear itself out if that is what you want to do.  If you wanted to save them, I would create a separate table and have each one be a separate record in that table.

                                      

                                     It is going to be repetitive, scripting it to write html code for you.  Is there any chance you can use the web publisher to create a layout and not bother writing the html in the first place?

                                • 13. Re: Can FMP print to a plain text file?
                                  geezerhiker

                                       I don't know anything about "the web publisher". Is that the same as "Instant Web Publishing"?

                                       And thanks for your help. I have it working very nicely now.

                                  • 14. Re: Can FMP print to a plain text file?
                                    mgores

                                         Yes, instant web publishing is what I meant. ( I think they changed the name in later versions)

                                         Glad to hear you got it working.

                                    1 2 Previous Next