The object was created with the the ATL COM AppWizard. It contains four methods that were added by hand to the IDL file (ContRot.idl), the object's header file (RotObj.h), and the object's C++ implementation file (RotObj.cpp):
HRESULT OnStartPage(IUnknown* pUnk)
HRESULT OnEndPage()
HRESULT ChooseContent(BSTR bstrDataFile, BSTR* pbstrRetVal)
HRESULT GetAllContent(BSTR bstrDataFile)
OnStartPage
and OnEndPage
are two
optional methods that ASP calls on an object whenever a page is
opened or closed by the user's Web browser. The OnStartPage
method can use the IScriptingContext
interface to
retrieve a pointer to an interface pointer of a built-in object
that enables a component to access that object's collections,
methods, and properties.
ChooseContent
reads a collection of weighted entries from
bstrDataFile
and returns one entry in pbstrRetVal
.
Each entry is a piece of HTML text. It can be used as:
A data file for the Content Rotator looks like this:
%% // Tech Support people <a href="mailto:jsmith">John Smith</a>, Tech Lead %% <a href="mailto:bkidd">Billy (the) Kidd</a>, Trouble Shooter %% #3 // Jane is full-time, so make her the likeliest to be chosen <a href="mailto:jdoe">Jane Doe</a>, Product Support %% // Scare 'em away. Bwah ha ha! Sorry. Tech Support<br> is<br> on<br> <b>Strike!</b>It contains a number of weighted entries. The entries are HTML text. Each entry starts with one or more lines beginning with
%%
. If the
%%
line doesn't have anything on it (as in the one for Billy
Kidd), then the entry's weight is one. If there's a number preceded by a
#
(as in the Jane Doe example), then that's the weight.
Comments on the %%
line start with //
.
The probability of an entry's being chosen by the Content Rotator is its weight divided by the sum of the weights of all the entries (usually 1/n).
GetAllContent
reads a collection of weighted entries from
bstrDataFile
and writes all the entries back to the user's
browser, each one separated by a horizontal rule (an <HR> tag), so
that it can be proofread.
ChooseContent
method.
Click here to run a demonstration of the
GetAllContent
method.