![]() |
|
|
Published: Tuesday, February 06, 2001 By Luke Bailey
Introduction: This library was developed to handle large amounts of data sent by a Shockwave movie and forward it on to an ASP script on a Web server for input to a database. However it could easily be used for other applications such as a "shopping cart" or to deliver a series "slides" in a DHTML page.
This library actually implements a FIFO buffer structure and has the same function calls
in both the JavaScript and VBScript versions. A buffer is a data structure into which you
can add ( To use the library in the browser or in an ASP script you need to include the script as follows:
Before using the library you need to call the initialisation function and, when finished, you should call the finalisation function. These functions can be called as follows:
Once the library is initialised it is ready to be used, you can call the following functions
to add (
Other useful functions are the ability to read and write the entire buffer as a string,
empty the buffer, and the ability to count the number of elements that are currently in the
buffer. These are accomplished with the The functions to read and write the entire buffer can be particularly useful if you need to iterate through the buffer more than once and therefore wish to preserve its state rather than having the elements removed as you read them. For example (in VBScript) you could use the following code to load a buffer from a HTTP POST, iterate through the buffer and print the contents without removing any elements:
You could also write a simple script that writes the buffer into a database table:
Included with the source code is an example application which consists of a simple browser based shopping cart (which uses DHTML) and a sever side ASP script which displays the shopping cart and a total price. This demonstration emulates a multi-dimensional array by adding two elements to the array for each object which is added to the cart (a name and a price). The client utilises javascript URL’s to call a function when a product is clicked on which adds the product name and cost to the buffer, another piece of Javascript then redraws the shopping basket list. Clicking on the purchase button submits a hidden form to the server side ASP script which includes the contents of the buffer, the ASP script then calculates the total cost and displays the complete shopping basket. (The code for this example is included in the source code download, but you can also try it out in a live demo!) Notes: Note that the buffer only takes character strings so the use integers or decimals they must first be converted to strings using the built in type conversion features for the relevant library. The buffer also reserves one character to demarcate the elements in the buffer, this character can be chosen in the global variables section in the library file but the currently chosen character cannot be used in any of the strings which are added to the buffer. Happy Programming!
Attachments:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||