Jump to content

HTML generation webviewer sequencing


Paul Derby

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

Recommended Posts

I've written a FMP Adv application that uses FMP scripting to generate HTML, then written the resulting HTML to a file in the webserver directory. I then want to use the "web viewer" to see the resulting web page in the FMP application. Everything is working, including converting the UTF-16 text making up the HTML to UTF-8. My problem is synchronization. I use perform applescript (thanks to another FM Forum member that provided this):

	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 > /Volumes/WebDirectory/whatever.html/" & quoted form of fileName 

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

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

To do the UTF-16 to UTF-8 conversion and to actually write the file to the proper web server directory. Now when I execute another script to read the html using FMPs "web viewer" I have no way of knowing when the file actually gets written so for a minute or so my FMP application shows the old HTML instead of the new HTML.

Does anyone now how to check using FMP script steps to actually check and see when the write has been completed?

Any ideas on how to get the file write event completed before executing the FMP steps to read the resulting html using web viewer?

I'm not using FMP server, so PHP isn't an option and I think it is actually pretty neat to be able to do dynamic HTML from within FMP without having to resort to extra interfaces beyond embedded AppleScript.

Thanks for any help.

Link to comment
Share on other sites

  • 3 weeks later...

Is this Mac only? Don't forget that on the Mac you don't need a file at all to use Web Viewer. Assuming you have a field called HTMLCalc set webviewer to use this calculation as its source:

"data:text/html," & HTMLCalc

Link to comment
Share on other sites

Yes, this is Mac only, though I would like to accomplish the same thing in Windows since we use both XP and OS X at work. Thanks for the tip. Unfortunately I can't pass the file indirectly from the FMP machine. It is a request to Google Maps and the machine holding the HTML request must be registered and have a real IP address, so I'm writing the file from a FMP app running on a laptop with a NAT address to the registered server with the real IP address so the Google Maps request will work.

I did get around the timing sequence problem by generating a unique file name for each FMP generated HTML file that gets written to disk. Seems that if the FMP Webviewer is given the same file name to load, it is hit or miss what gets loaded, even if Webviewer is told to reset or clear and load. If Webviewer is given a new filename each time to load, then all works fine.

Edited by Guest
Link to comment
Share on other sites

I don't understand why you can't just use the export field contents script step..

I.e. generate your HTML within FM

Dump it in a field

Export the field contents directly to the webserver root directory.

Refresh Window

If you can't get directly to your webserver folder, you could then use applescript and / or vbscript to move it and then execute a refresh script within FM.

... no timing issues, cross platform, works for me.

Am i missing something?

Link to comment
Share on other sites

RE: PHP not being an option... maybe not directly with FM, but you could pass variables through a url string to a php file using the get method... that or get it to load what it needs from an FM produced XML file..

But it may be more trouble than it's worth depending on how dynamic your HTML is.

Link to comment
Share on other sites

Export field writes the HTML in UTF-16 which isn't readable when accessed by GoogleMaps. The HTML must be written in UTF-8. At least that is what happens with export field on the Mac. I wish FMP allowed writing text to files in UTF-8 as an option. (Maybe it is an option that I just don't know how to set.) So I'm uisng Applescript to write the file which is on a web server, not the machine that runs FMP. When I overwrite the file and then try to read it with Webviewer, it can take up to a minute or two to get the correct html. A refresh doesn't make the change. It may be a caching issue on the google side of google maps. As I mentioned earlier, always writing to a new file name solved the problem.

Edited by Guest
Link to comment
Share on other sites

Export records gives you the option to choose character set, while for some reason export field content does not give you this option.

Link to comment
Share on other sites

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