<scriptlet>
<Registration
Description="Demo"
ProgID="Demo.Scriptlet"
Version="1.00"
ClassID="{3ac6e5c0-9f18-11d1-83d1-f49604c10000}"
>
</Registration>
<implements id=Automation type=Automation>
<method name=Method1>
<PARAMETER name=param1/>
</method>
<property name="Property1" internalname="mProp1">
</property>
</implements>
<script language=JScript>
var mProp1 = "";
function Method1(param1) {
return "Method1(param1)";
}
</script>
</scriptlet>
Figure 4 Factorial Server Scriptlet
<scriptlet>
<Registration
Description="Factorial"
ProgID="Factorial.Scriptlet"
Version="1.00"
ClassID="{4ac6e5c0-9f18-11d1-83d1-f49604c10000}"
>
</Registration>
<implements id=Automation type=Automation>
<method name=Calculate>
<PARAMETER name=num/>
</method>
</implements>
<script language=JScript>
function Calculate(num) {
if( num<2 )
return 1;
return num*Calculate(num-1);
}
</script>
</scriptlet>
Figure 8 ADDScriptlet
<scriptlet>
<Registration
Description="ADOScriptlet"
ProgID="ADOScriptlet.Scriptlet"
Version="1.00"
ClassID="{5ac6e5c0-9f18-11d1-83d1-f49604c10000}"
>
</Registration>
<implements id=Automation type=Automation>
<method name=GetData/>
<property name=Database>
<GET />
<PUT />
</property>
<property name=Table>
<GET />
<PUT />
</property>
<property name=Field>
<GET />
<PUT />
</property>
</implements>
<script language=JScript>
var mDatabase = "";
var mTable = "";
var mField = "";
/*-----------------------------------------
// FIELD property
-----------------------------------------*/
function get_Field() {
return mField;
}
function put_Field( fldName ) {
mField = fldName;
}
/*-----------------------------------------
// DATABASE property
-----------------------------------------*/
function get_Database() {
return mDatabase;
}
function put_Database( dbName ) {
mDatabase = dbName;
}
/*-----------------------------------------
// TABLE property
-----------------------------------------*/
function get_Table() {
return mTable;
}
function put_Table( tblName ) {
mTable = tblName;
}
/*-----------------------------------------
// GETDATA method
-----------------------------------------*/
function GetData() {
obj = new ActiveXObject( "ADODB.Connection" );
obj.Open( mDatabase );
sql = "SELECT * from " + mTable;
RS = obj.Execute( sql );
aRecs = new Array();
i = 0;
while( !RS.EOF ) {
s = "" + RS.fields(mField);
aRecs[i++] = s;
RS.MoveNext();
}
return aRecs;
}
</script>
</scriptlet>
Figure 10 VB.Form Form1
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 3 'Fixed Dialog
Caption = "VB does Server Scriptlets..."
ClientHeight = 3285
ClientLeft = 45
ClientTop = 330
ClientWidth = 4965
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3285
ScaleWidth = 4965
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.TextBox Text3
Height = 375
Left = 1200
TabIndex = 4
Text = "CompanyName"
Top = 1080
Width = 3615
End
Begin VB.TextBox Text2
Height = 375
Left = 1200
TabIndex = 3
Text = "Customers"
Top = 600
Width = 3615
End
Begin VB.TextBox Text1
Height = 375
Left = 1200
TabIndex = 2
Text = "ADOSamples"
Top = 120
Width = 3615
End
Begin VB.ListBox List1
Height = 1425
Left = 120
TabIndex = 1
Top = 1680
Width = 2895
End
Begin VB.CommandButton cmdGetData
Caption = "Invoke GetData"
Height = 375
Left = 3120
TabIndex = 0
Top = 1680
Width = 1695
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
Caption = "Field"
Height = 255
Left = 120
TabIndex = 7
Top = 1200
Width = 735
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Caption = "Table"
Height = 255
Left = -120
TabIndex = 6
Top = 720
Width = 975
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Database"
Height = 255
Left = 0
TabIndex = 5
Top = 240
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdGetData_Click()
Dim g_sctADO As Object
Dim a As Variant
Set g_sctADO = CreateObject("ADOScriptlet.Scriptlet")
g_sctADO.Database = Text1.Text
g_sctADO.Table = Text2.Text
g_sctADO.Field = Text3.Text
' Note that you need to add a dummy argument
' to any method requiring no arguments due to
' a bug in the first beta version.
' Remove the empty string if you're running
' a newer version.
Set a = g_sctADO.GetData("")
bContinue = True
While bContinue
i = InStr(1, a, ",")
If i < 1 Then
s = a
bContinue = False
Else
s = Left$(a, i - 1)
a = Right$(a, Len(a) - i)
End If
List1.AddItem (s)
Wend
Set g_sctADO = Nothing
End Sub