Date:  08/26/2006 01:30:06 PM Msg ID:  003132
From:  John Sullivan Thread:  003132
Subject:  Best Location of External Procedures

My question relates to procedures and/or COM objects that are called from FWX pages. Where is the best location to establish programs or COM objects?

For example, I have a FWX page that I need to query a database than contains a record for every zip code in the US. To keep things simple I want to display information about each zip code on a State + County basis. This will allow us to keep the page size to a reasonable size for the user.

We have one combo box #1 to select the state. Obviously we use a SELECT statement to obtain just the individual states on a UNIQUE basis. We have another combo box #2 that contains the counties for the specific state displayed in the first combo box #1. When the user selects a different state we need to re-query the master database twice to setup the combo boxes. We also need to build the HTML for each combo box display.

As you can see, the above requires lots of code. I place to locate the code in a COM object and then do a Px = CreateObject("myserver.myclass") at the start of the script to establish the COM object.

This raises several questions, which are:

  1. I don't want the overhead of establishing the COM object with each hit to the page and then releasing it after it is done. Where can I establish the COM object just once and then use it freely in this, and other scripts?
  2. What happens to the COM object is channels are restarted. Do I need to reset the COM object?
  3. Any suggestions on where it is best to locate processing code, where to use SET PROCEDUE TO {library} and so on in FWX scripts or server setup code?

Thanks for your insight to a "best programming practices" relative to FoxWeb.

John Sullivan