=============================================================================== WEST COAST WEB ADVENTURES, INC. NEWSLETTER - Vol #1, Issue #3, November 28, 2001 Online version at: http://www.WestCoastWebAdventures.com/news/news11282001.txt =============================================================================== Visit http://www.WestCoastWebAdventures.com for additional information, to add your two sense, or to unsubscribe from this newsletter. =============================================================================== Contents - About this Newsletter - Cool Tools: FGL Programming Guide - Case Study: Online Insurance Rating - Working with Code: Object Database Storage - FGL Tips: The SESSION Object - This Week's Referral: DOWNLOAD.COM =============================================================================== About this Newsletter =============================================================================== First, a special thanks to all those users that have exhibited extreme patience with our efforts. This newletter was created as a free resource by West Coast Web Adventures for people interested in providing themselves with more control of their web presence, software development, and overall computer experience. It is published via email once or twice per month, more or less, as the opportunity and need arises. We hope that users of all experience levels will get something out of each issue. The newsletter is published in-house by West Coast Web Adventures staff members, but outside content contributions are always welcome. Contact the webmaster if you have something to contribute. =============================================================================== COOL TOOLS: FGL Programming Guide =============================================================================== OK, so it's taken a while, but the entire FGL programming guide is now available online. This represents all of the documentation necessary to start programming in the FGL environment, or to create extremely advanced web-based applications. The online guide includes the following sections: Introduction A Brief History of the FGL Language Language Features Platforms and System Requirements The Virtual Machine Variables and Data Types Global, Static, and Local Variables Data Conversion Arrays Operators Functions and Procedures The "Main" Function Flow Control Database Programming Ini Files Low-level File Manipulation Code-blocks & Macro Expansion Object Oriented Programming Active Pages Task Management Debugging Your Program Error Handling Error Messages The SYSCLASS library FGL Programming Utilities Extending FGL with Dynamic Link Libraries License and Distribution Agreement Access the online FGL documentation from the developer's section of the West Coast web site, then click on the FGL documentation link followed by the LANGUAGE link. You can also access the guide directly at: http://www.westcoastwebadventures.com/fgl/Language/index.htm The individual function documentation is still in the process of being converted to the web. Thanks for your patience during this process. Let us know if we can help with specific questions in the mean time. =============================================================================== CASE STUDY: Online Insurance Rating =============================================================================== The insurance industry has been slow to embrace the technology revolution that the web has created. Many sites that offer online quotes amount to not much more than fill-in forms that generate consolidated email requests. The process of creating a quote involves selecting the desired product category and applicable geographic region, gathering information about the user and relevant item to be insured, then performing various look-ups and calculations in order to deliver an accurate quote. In order for this process to be efficient, only information required to generate the quote should actually be gathered. Likewise, the reward for providing the information and going through the process should be an instantaneous result. That is, the quote should be delivered immediately. From a prgramming perspective, this overall process can be broken down into several areas. First, the user is instructed to select the product line and region in which to quote. Second, a form is presented that requests the minimum information necessary to generate the quote. Following submittal of the form, a validation routine checks the input and prompts for correction if applicable. Once the data has been validated, the process of look-up and calculation is performed to determine the rating information. Usually this involves accessing rate tables, regional factors, underwriting rules, and a host of other components. Finally, the resultant information is formatted into an actual quote and returned to the user in theform of an HTML file. This entire process can easily be implmented using the dynamic content delivery vehicle found in Active Pages. Ongoing modifications and maintenance are simplified through the use of integrated object technology. Visit an implementation of an online insurance rater at the following web address: http://208.60.0.61/insmgmt/oem/asic/hoflams.htm =============================================================================== WORKING WITH CODE: Object Database Storage =============================================================================== Traditonal database architectures provide fixed-length fields for storage of specific data elements. This works fine for instances where the data to store is known in advance and each element's length is predetermined. Changing the database, however, involves altering its internal structure, and fixed-length fields tend to waste LOTS of space. Variable length database structures provide provide many benefits over fixed- length structures, however the price is often significant loss of performance. One solution is to create a hybrid database structure that employees the best components of each structure within a single entity. With FGL, this is possible by using the built-in database functionality for relational fixed-length fields with an associated BLOB field to store the variable length components. This is significantly enhanced through the use of objects as an interface to the database. For example, consider a contacts database. Basic information such as First and last name can be used for high-speed access by using the relational portion of the structure, while additional information can be added at will through an object component that utilizes the BLOB functionality of FGL. The database structure might look like this: local db_struct = { { "FNAME", "C", 20, 0 }, { "LNAME", "C", 30, 0 }, { "DATA", "B", 20, 0 } } dbCreate( filename, db_struct ) This will create a database identified by FILENAME containing three fixed- length fields: FNAME, LNAME, and DATA. The DATA field will be created as a BLOB field which stores variable length data in an associated .BLB file. Then, you can use an object wrapper as an interface to the database, as in: ///////////////////////////////// // Object Database Source Code // ///////////////////////////////// CLASS myContacts PUBLIC: local dbfile, dbindex, delim local fname, lname local addr, city, state, zip, country METHOD new( ) ::dbfile = 'c:\data\contacts.db' ::dbindex = 'c:\data\contacts.dx' ::delim = chr( 1 ) ::init( ) return( 1 ) END METHOD init( ) ::fname = "" ::lname = "" ::addr = "" ::city = "" ::state = "" ::zip = "" ::country = "" return( 1 ) END METHOD open( ) dbopen( ::dbfile, "db" ) db->dbOpenIndex( ::dbindex ) return( 1 ) END METHOD close( ) db->dbClose( ) return( 1 ) END METHOD append( ) db->dbAppend( ) return( 1 ) END METHOD seek( key ) db->dbSeek( key ) return( db->dbFound( ) ) END METHOD Get( key ) ::fname = db->fname ::lname = db->lname ::unpack( db->data ) return( 1 ) END METHOD Set( key ) db->fname = ::fname db->lname = ::lname db->data = ::pack( ) return( 1 ) END METHOD pack( ) local str str = addr + ::delim + city + ::delim + state + ::delim str += zip + ::delim + country return( str ) END METHOD unpack( data ) ::addr = strextract( data, ::delim, 1 ) ::city = strextract( data, ::delim, 2 ) ::state = strextract( data, ::delim, 3 ) ::zip = strextract( data, ::delim, 4 ) ::country = strextract( data, ::delim, 5 ) return( 1 ) END END //////////////////// // End of Listing // //////////////////// The key to this example is the PACK and UNPACK methods. They are used to convert object data into linear data so that it can be stored in and extracted from the BLOB field. Using the above code, the following example can be used to access the data: // create an instance of the object obj = new( "myContacts" ) // open the database obj.open( ) // update the object variables obj.fname = "Steve" obj.lname = "Repetti" obj.addr = "123 East West Highway" obj.city = "Mission Viejo" obj.state = "CA" obj.zip = "92691" // add ablank record obj.append( ) // store the object variables in the database obj.set( ) // close the database obj.close( ) This method not only makes accessing your data easier, by the information stored requires significantly less space than fixed-length architectures. Also, it is extremely easy to add additional fields to the database without changing its defined structure. =============================================================================== FGL TIPS: The SESSION Object =============================================================================== Web development is highly simplified through the use of the SESSION object contained in the SYSCLASS library. This binary library is automatically available to any Active Page and provides a number of web-related features, the most promminant being the SESSION object. The SESSION object can be used to access server details, current user information, and data passed to a page using web forms. For example: <[ // create a session object session = new( "session", param( 1 ), param( 2 ) ) // determine the name of the current web server server = session.data( "SERVER_NAME" ) // determine the web port used port = session.data( "SERVER_PORT" ) // Get the client host name // which can be used for dynamic routing // and virtual hosting host = session.data( "CLIENT_HOST" ) // Get data passed through a web form fname = session.var( "fname" ) lname = session.var( "lname" ) age = 0 + session.var( "age" ) ]> This example first creates a session object. The parameter statements passed the object the server ID and a unique session ID. Then, various internal server information is extracted using the DATA method. Finally, information passed to the page via a web form is extracted with the VAR method. Examine the SERVER.AP file located in the \sdweb\home\system directory for additional examples. =============================================================================== THIS WEEK'S REFERRAL: DOWNLOAD.COM =============================================================================== Looking for a file or application available for immediate download from the net? Then C|NET's DOWNLOAD.COM probably has it. The site features an easy to use interface, fast search, and independent user comments for each download. Software is organized by category or can be accessed directly through the site's search engine. See for yourself at: http://www.download.com =============================================================================== This newsletter is the copyrighted material of West Coast Web Adventures, Inc. (c) 2001 by West Coast Web Adventures, Inc., All Rights Reserved. ===============================================================================