[阅读: 462] 2006-10-09 07:46:56
<?XML version="1.0"?>
<component id="ScriptletFactorial">
<registration progid="Component.Factorial"/>
<public>
<property name="sname"/>
<property name="age">
<get internalName="readAge"/>
</property>
<property name="dateOfBirth">
<get internalName="readDOB"/>
<put internalName="writeDOB"/>
</property>
<property name="mstatus">
<get/>
<put/>
</property>
</public>
<script language="VBScript">
<![CDATA[
Dim sname ' Read-write sname property (no functions).
Dim gDOB ' Global variable used to store date of birth.
Dim gMStatus ' global variable used to store marital status.
Function readDOB()
' Gets value of dateOfBirth property.
readDOB = gDOB
End Function
Function writeDOB(newDOB)
' Sets value of dateOfBirth property.
If isDate(gDOB) Then
' Error checking.
gDOB = newDOB
End If
End Function
Function readAge()
' Calculates read-only age property.
If isDate(gDOB) Then
dobM = DatePart("m", gDOB)
dobD = DatePart("d", gDOB)
dobY = DatePart("yyyy", gDOB)
todayY = DatePart("yyyy", Date)
age = todayY - dobY
' Adjust if birthday has not yet occurred this year.
bday = DateValue(dobM & "/" & dobD & "/" & todayY)
If DateDiff("d", bday, DateValue(Date)) < 0 Then
age = age - 1
End If
readAge = age
End If
End Function
Function get_mstatus()
' Reads value of mstatus property.
get_mstatus = gMStatus
End Function
Function put_mstatus(s)
' Writes value of mstatus property.
If s = "M" Or s = "S" Then
gMStatus = s
Else
gMStatus = "?"
End If
End Function
]]>
</script>
</component>