Revisiting SaveAsText from a form

This was previously posted on Jan 19 by another user but there was no response:

“I have used SaveAsText with forms with previous versions. It’s no longer supported. What is the best solution to replace that can include headers, footers and calculations?”

I now find myself with the same dilemma. This information used to be saved as a simple text doc that could be imported to a website database. I can successfully print to .pdf and print to postscript from the print dialog and get the report formatted the way I want, but I don’t believe either can be imported to a database. Is there another way to massage either into a text document that can be importable?

Use filesave with arraybuild(. Here’s an example of exporting tab delimited data with a header and a footer.

filesave "~/Documents/somefile.txt",
    "Name"+tab()+"Phone"+lf()+
    arraybuild(lf(),"",{Name+tab()+Phone})+lf()+
    "Exported on "+datepattern(today(),"Month ddnth, yyyy")

This approach wasn’t practical in Panorama 6 and earlier except for small databases. But Panorama X allows pretty much unlimited length output generated from a formula, so this will work for any database.

Thank you Jim.

Will this work with information on summary tiles as well? The records are grouped, summarized and need to be exported with the info on a header tile, data tile and summary tile.

Yes, you just need to adjust the arraybuild( to your needs. If you look that up in Help you’ll see it optionally includes a query term. Which like the formula term in Jim’s example needs to be quoted, ie. surrounded in curly braces. To include only first level summary records you’d use {info(“summary”)=1} as your query. With creativity you can file save any data subset you want with fixed text before and/or after it.

I think it could be done. The tricky one would be to mimic a group header tile. Your formula needs to know that the record is the first record of a group. I would give the database an integer field, and sequence the field with a sequence "" command. The sequence starts over again with each new group.

The formula could be something like

?(«Sequenced Field» = 1, (header formula) + ¶ ,"") +
?(info("summary") = 0, (data formula) + ¶, "") +
?(info("summary") = 1, (summary formula) + ¶, "")

This code has nothing to do with summary tiles, or any other kind of tile. The ability to export text thru a form no longer exists, and won’t exist.

However, you can adjust your formula to the same effect by using the info(“summary”) function. You would probably want to use it with the switch( or ?( functions. Here’s an example that you could use if your database has been grouped by month, also with a grand total.

filesave "~/Documents/checksbymonth.txt",
    "Date"+tab()+"Check"+tab()+"Amount"+lf()+
    arraybuild(lf(),"",{switch(info("summary"),
        1,datepattern(Date,"Mon YY")+tab()+tab()+Amount,
        2,"GRAND TOTAL"+tab()+tab()+Amount,
        datepattern(Date,"MM/DD/YY"))}+lf()+
    "Exported on "+datepattern(today(),"Month ddnth, yyyy")

The switch functions allows a different export format for different summary levels.

Thank you Jim, Dave and John. Your replies give me a starting point and a lot to chew on.