From SeedCode Documentation

SeedCodeCalendar12: Perform Script on Server (PSOS)

Note: The PSOS option is included in SeedCode calendar version 7.25 (a paid upgrade from earlier versions). Check out our version history for more.

Why would I want to use PSOS?

The "Perform Script on Server" script step was introduced in FileMaker 13. PSOS lets a client of a hosted file run a sub script on the server. So with some careful planning, you can have the server do a lot of the heavy lifting the client machine would normally have to do (finding, sorting, processing, other data manipulation, etc.). You can also avoid moving large amounts of data over the network, which is what normally happens when the client machine runs a Perform Find or an SQL query on a hosted file.

Using PSOS can result in dramatic performance improvements in these types of operations when working over a WAN (i.e. opening your file from outside your local network). Our tests with the Pro Calendar showed refresh times 10-40 times faster when using PSOS on a WAN (your mileage may vary).

You'll likely not see any improvement on a LAN (when you're ON the local network).

Note: This may be obvious, but PSOS will only work when your file is hosted in FileMaker Server 13.

Why wouldn't everyone want PSOS on?

The speed improvements in PSOS are most dramatic when you're far away from your FileMaker Server. But it does come with a trade off: scripts run with PSOS don't cache their results the way scripts running locally would. So if your server is close enough, you may not want PSOS running because you'd rather have the caching.

Here is an exaggerated example:

Without PSOS opening your calendar from another country takes 9 minutes to move from month to month. But once you've been to a given month, going back to that month takes only a couple seconds.
With PSOS on, it only takes 5 seconds to go from month to month... but it always takes 5 seconds. Going back to a previously visited month is no faster than going to a new month.

Thus, PSOS is a "switch" in the Pro Calendar. You can turn this on from the calendars's settings tab or turn it on by default by editing the comment for PSOS in the script ""Load Calendar Settings - On Startup --- Edit Configuration Here ---".

Adding PSOS to your Calendar file

If you want to add this PSOS functionality into a SeedCode calendar you already have, you can... following these instructions.

First, upgrade to the new calendar. And you'll need FileMaker Advanced so you can add custom functions and copy/paste script steps from that file: then follow these instructions:

1. Import these three custom functions into your file: (yes, that “#” sign is the full name of the first one)

#
#Assign
#AssignGlobal

2. Copy/paste the new "Check for FileMaker Server" script into your file.

3. Replace the entire contents (all steps) of these seven scripts in your file with the contents of these scripts from the new file using Select All and Copy/Paste: (NOTE: do not delete the scripts themselves; only the contents)

Insert Events File Into Calendar
Cast Events as Variables - Build Query
Capture Events by Date Range - Run SQL Query
Upon Opening
Toggle PSOS (added in version 7.25)
Clear Event Parsing Variables
Click in / Drag Event
Load Calendar Graphics

(NOTE: those last three scripts are unrelated to PSOS, but updating them will fix some minor bugs we found.)

4. You'll also have to edit the "Load Calendar Settings - On Startup --- Edit Configuration Here ---" script. If you haven't modified any of the settings in this script in your file, then you can just copy/paste the entire contents from the new file into yours (like you did with the other scripts above). However, if you have modified your settings, you'll want to selectively copy/paste these new steps:

Set Variable [$$sc_PSOS; Value:"No"...]
Set Variable [$$sc_SortEvents; Value:"Yes"...]
The entire If[] section at the end of the script (which contains a few other nested If sections), immediately following the comment "If PSOS is on, make sure PSOS is available."

5. The calendar ships with that new $$sc_PSOS variable mentioned above set to "No". To start using PSOS (with your file being hosted in FileMaker Server 13 and having made all of the modifications outlined above), change the value that is set into the $$sc_PSOS variable to "Yes", then rerun the "Upon Opening" script.

That's it, enjoy!

I'm Getting a Notification Dialog saying PSOS isn't available?

We thought developers would like to know about those cases where they'e set the calendar to use PSOS but it won't be used: such as when the calendar is opened shared from FileMaker Pro instead of FileMaker Server.

To get rid of this dialog simply delete the first Show Custom Dialog step in the script "Cast Events as Variables - Build Query" after the comment "Script is running on the server (PSOS)."

Retrieved from http://archive.seedcode.com/pmwiki/pmwiki.php?n=SeedCodeCalendar12.PSOS
Page last modified on June 27, 2014, at 08:17 PM