Now we have created and registered a Server Scriptlet, we're ready to test it. First of all, let's see if all is well when we call it from an HTML page. For the purpose, we prepared a page called datecalc.htm
. The Server Scriptlet must be inserted as if it was an ActiveX control.
<html>
<body>
Click on the page to test the Date Calculator Server Scriptlet.<hr>
<script language=Javascript for="document" event="onclick">
s1 = "May 4, 1998";
s2 = obj.Add( s1, 2 );
alert( s2 );
s3 = obj.Diff( s2, s1 );
alert( s3 );
s4 = obj.IsGreaterThan( s2, s1 );
alert( s4 );
obj.Separator = "-";
alert( obj.DateAsDDMMYYYY() );
</script>
<object id=obj classid="clsid:70AE1C41-99A4-11d1-83D1-F46705C10000"
style="display:none">
</object>
</body>
</html>
By clicking on the page you'll see a message box that displays a date 2 days after my next birthday. Then the difference in days between the two dates (again, it is 2). The page also adds a few lines to test the other functions of the scriptlet. Note that we're using the property Separator
but we implemented it through a variable with another name. The only link between Separator
and the variable mSep
(see the previous listing) is established in the <IMPLEMENTS>
section.
The figure shows the date formatted with a dash instead of the common slash. It follows the notation dd-mm-yyyy.