Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

I've written a little FileMaker Pro advanced 8.5 script to generate HTML and then export the text to a file. For some reason, FMP Advanced writes the text in Unicode UTF-16 Little-Endian. When I point Filemaker's WebViewer (or Safari or FireFox) to this FileMaker generated HRML file, nothing is returned because all the browsers expect the HTML to be in UTF-8 instead of UTF-16.

The HTML I'm generating is a block of text that when executed, makes a request to Google Maps to plot a multi-point map. Does anyone know how to get FileMaker Pro Advanced to export text in UTF-8 format? Is there a plug-in that can do this job?

I thought about using PHP to generate the file, but it seems like PHP is supported from FileMaker Pro Server and is not supported from FileMaker Pro Advanced.

I can go in with BBEdit and open the text file and save it in UTF-8, so I know the HTML is correct. It is just the encoding of the text on a FMP Adv export that is the problem.

Any and all ideas are welcome on how to write UTF0-8 HTML to a file from a FileMaker Pro Adv script.

Posted

The easiest way, on your own Mac, is to use "do shell script," in a Perform AppleScript step. This is what the AppleScript part of it looks like. You'd need fields named to match, on the current layout (preferably).

-- tell application "FileMaker Pro Advanced"

	copy cell "filename" of current record to fileName

	copy cell "Text_" of current record to exportMe

	do shell script "echo -n " & quoted form of exportMe & " > ~/desktop/" & quoted form of fileName

	-- -n prevents a final line feed from being added

-- end tell

This little example file does it a couple ways.

TextExport_Shell.fp7.zip

Posted

Very nice! Thank you. Maybe someday FileMaker will add a parameter to their export text script command to let the user specify the character set for the exported text.

Posted

Well, the embedded script to write the contents of a field in a current record to a disk file in UTF-8 is working great. Now I'm having problems figuring out when the script actually completes so the file is available to read back into filemaker in a field using the embedded web browser. About the only way I can get Filemaker to totally flush data and refresh the internal browser is to go from browse mode to layout mode and then back to browse mode. The script steps like "flush cache to disk" and "set web viewer" with either reset or reload don't seem to make any difference. Also, toggling the layout in a script doesn't seem to force a write and refresh, either.

Anyone have any ideas on how to alter the script below or add steps in Filemaker to detect when OS X actually completes the file write and how to force the FileMaker web viewer to do a refresh of the same URL?

The code snippet below is from the code that was kindly supplied by Fenton.

" copy cell "filename" of current record to fileName

copy cell "Text_" of current record to exportMe

do shell script "echo -n " & quoted form of exportMe & " | strings > ~/desktop/" & quoted form of fileName

-- -n prevents a final line feed from being added

-- strings converts all line returns to Unix line returns (ASCII 10)"

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