by Peter Vinogradov

Tip of the hat

Having skipped DevCon in order to afford an iPhone, I’ve been dealing with my DevCon envy by exploring some of the wonderful sample files that people have been putting together for FM9.

The fuss over Andy’s conditional formatting tricks, for example, is certainly well-deserved (though let’s face it, we all would have worked that stuff out on our own, right? no?).  After playing with those for a bit, a post about Ray Cologon’s “Progress Bars” ( http://www.nightwing.com.au/FileMaker/demos.html ) caught my attention, and I ended up spending a good afternoon hacking that file apart.

What I particularly love about this solution is the idea of dumping a bunch of webviewer resources (pictures, etc.) into the user’s temp folder using the get (temporarypath) function. While I’ve certainly employed some variations on this – sneaking some garbage PDFs into a my docs folder or out to the desktop prior to e-mailing, etc – I’ve been overlooking the temp folder for years (mostly I guess because there’s never been a convenient get function for it before). Now with FM 9 data URLs finally working, the webviewer has (almost) completely arrived, and a convenient place to dump huge amounts of rubbish couldn’t be more timely. [edit - just read the "dispatches from DevCon" post. Evidently this demo was a big hit there, too]

Lately, I’ve been scrambling to finish a rewrite of a scheduling solution for a school that I work for. The requirements are simple – be able to define courses in any variety of blocks and times and dynamically generate graphical student schedules with seamless handling of overlaps and conflicts. Once upon a time, I tried to achieve this using microscopic portal rows and a schedule table with zillions of records and dozens of lead-like calculations. It worked, but it was only “dynamic” from a geologic perspective and it made white smoke pour out the back of my Dell.

With the web viewer, of course, that all changed – almost. I was able to throw out the schedule table and generate a whole mess of CSS Divs instead. The schedules were coming out slicker and faster than ever, but FM was still doing all the heavy lifting of stitching together adjacent course blocks, knocking out overlaps, and sizing text based on available block sizes. Spitting out a batch of schedules was no longer an overnight project, but it was still burdened with a sluggishness that gnawed at me in light of all the extra coding and testing it took to implement.

Over the course of this project, it did occur to me to try moving the heavy lifting over to the web browser, but I hesitated for a couple of reasons:

- I hadn’t written a word of Javascript in over 3 years
- generating HTML in an FM calc or CF is painful enough. Imagine having to debug a bunch of Javascript with escaped quotations everywhere.

Finally, though, it was Ray’s sample file that gave me the kick I needed. If I could simply pack my javascript into a container file, have that dumped into the user’s temp folder, and reference it in my HTML, life would be a lot simpler.

After two days of dusting off the cobwebs in my Javascript memory (nothing like a few years of FM calc habits to help THAT along…), I’ve finally got a rough library of functions that can connect and polish several dozen disjointed, poorly formatted div tags in a split-second. It beats the pants off the custom functions I had going in FM, and only rarely does it lock up my browser in an endless loop (okay, so there’s some debugging to do).

So, three cheers for sample files, particulary Ray’s 9 for 9 collection. Looking forward to 10 for 10 - unless of course FM comes out with something boneheaded, like  ”FM Creative Suite”, “FMX”, “FM smooth ultra king 100s”…

Comments

One Response to “Tip of the hat”

  1. dandanthesushiman on September 19th, 2007 7:53 am

    I like the idea of the javascript to display the schedule. I am the FMP developer in an international school in London and this is something I have had to do. I used global fields as columns and then step through the students schedule to enter the course details and carriage returns and lines to display blocks of different lenghts. It actually works pretty well and is fast enough. Having said that I am always interested in finding a better way. Is there any chance you could post the code and an example. I would love to see what you have done.

    All the best

Leave a Reply

You must be logged in to post a comment.