Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
5.3 KiB

  1. <HTML>
  2. <HEAD><TITLE>PerlScript sample: RPN Calculator</TITLE></HEAD>
  3. <BODY BGCOLOR="#FFFFFF" TOPMARGIN=8>
  4. <!--
  5. ActiveState PerlScript sample
  6. PerlScript: The coolest way to program custom web solutions.
  7. -->
  8. <TABLE CELLPADDING=0 BORDER=3 CELLSPACING=0>
  9. <TR VALIGN=TOP ><TD>
  10. <A NAME="TOP"><IMG SRC="PSBWlogo.gif" WIDTH=400 HEIGHT=48 ALT="The power of PerlScript!" BORDER=2></A><P>
  11. </TD></TR></TABLE>
  12. <HR>
  13. <FONT FACE=ARIAL SIZE=3> <!-- global default -->
  14. <SCRIPT LANGUAGE="PerlScript">
  15. $flagNewNum = 1;
  16. @stack = 0;
  17. sub NumPressed($)
  18. {
  19. my $num = $_[0];
  20. my $Keypad = $window->document->Keypad;
  21. if ($flagNewNum) {
  22. $flagNewNum = 0;
  23. push @stack, $Keypad->Readout->{'Value'};
  24. $Keypad->Readout->{'Value'} = $num;
  25. } else {
  26. $Keypad->Readout->{'Value'} .= $num;
  27. }
  28. }
  29. sub Decimal_onClick()
  30. {
  31. my $Keypad = $window->document->Keypad;
  32. if ($flagNewNum) {
  33. $flagNewNum = 0;
  34. $Keypad->Readout->{'Value'} = "0.";
  35. } else {
  36. $_ = $Keypad->Readout->{'Value'};
  37. $Keypad->Readout->{'Value'} = $_ . '.' if (/\./);
  38. }
  39. }
  40. sub Decimal_onclick()
  41. {
  42. Decimal_onClick()
  43. }
  44. sub Plus_onClick()
  45. {
  46. $flagNewNum = 1;
  47. $window->document->Keypad->Readout->{'Value'} += pop @stack;
  48. }
  49. sub Plus_onclick()
  50. {
  51. Plus_onClick()
  52. }
  53. sub Minus_onClick()
  54. {
  55. my $Keypad = $window->document->Keypad;
  56. $flagNewNum = 1;
  57. $Keypad->Readout->{'Value'} =
  58. (pop @stack) - $Keypad->Readout->{'Value'};
  59. }
  60. sub Minus_onclick()
  61. {
  62. Minus_onClick()
  63. }
  64. sub Multiply_onClick()
  65. {
  66. $flagNewNum = 1;
  67. $window->document->Keypad->Readout->{'Value'} *= pop @stack;
  68. }
  69. sub Multiply_onclick()
  70. {
  71. Multiply_onClick()
  72. }
  73. sub Divide_onClick()
  74. {
  75. my $Keypad = $window->document->Keypad;
  76. $flagNewNum = 1;
  77. $Keypad->Readout->{'Value'} =
  78. (pop @stack) / $Keypad->Readout->{'Value'};
  79. }
  80. sub Divide_onclick()
  81. {
  82. Divide_onClick()
  83. }
  84. sub SquareRoot_onClick()
  85. {
  86. my $Keypad = $window->document->Keypad;
  87. $flagNewNum = 1;
  88. $Keypad->Readout->{'Value'} =
  89. sqrt($Keypad->Readout->{'Value'});
  90. }
  91. sub SquareRoot_onclick()
  92. {
  93. SquareRoot_onClick()
  94. }
  95. sub Square_onClick()
  96. {
  97. my $Keypad = $window->document->Keypad;
  98. $flagNewNum = 1;
  99. $Keypad->Readout->{'Value'} =
  100. $Keypad->Readout->{'Value'} * $Keypad->Readout->{'Value'};
  101. }
  102. sub Square_onclick()
  103. {
  104. Square_onClick()
  105. }
  106. sub Neg_onClick()
  107. {
  108. my $Keypad = $window->document->Keypad;
  109. $Keypad->Readout->{'Value'} =
  110. -($Keypad->Readout->{'Value'});
  111. }
  112. sub Neg_onclick()
  113. {
  114. Neg_onClick()
  115. }
  116. sub Percent_onClick()
  117. {
  118. my $Keypad = $window->document->Keypad;
  119. $flagNewNum = 1;
  120. $Keypad->Readout->{'Value'} = ($Keypad->Readout->{'Value'}) / 100;
  121. }
  122. sub Percent_onclick()
  123. {
  124. Percent_onClick()
  125. }
  126. sub Enter_onClick()
  127. {
  128. my $Keypad = $window->document->Keypad;
  129. $flagNewNum = 1;
  130. push @stack, $Keypad->Readout->{'Value'};
  131. }
  132. sub Enter_onclick()
  133. {
  134. Enter_onClick()
  135. }
  136. </SCRIPT>
  137. <form action="" Name="Keypad">
  138. <TABLE>
  139. <B>
  140. <TABLE BORDER=2 WIDTH=50 HEIGHT=60 CELLPADDING=1 CELLSPACING=5>
  141. <CAPTION ALIGN=top>
  142. <b>RPN Calculator</b><p>
  143. </CAPTION>
  144. <TR>
  145. <TD COLSPAN=3 ALIGN=MIDDLE><INPUT NAME="ReadOut" TYPE="Text" SIZE=24 VALUE="0" WIDTH=100%></TD>
  146. <TD></TD>
  147. <TD><INPUT NAME="Square" TYPE="Button" VALUE=" sqr " ></TD>
  148. <TD><INPUT NAME="SquareRoot" TYPE="Button" VALUE=" sqrt " ></TD>
  149. </TR>
  150. <TR>
  151. <TD><INPUT NAME="Seven" TYPE="Button" VALUE=" 7 " onClick="NumPressed(7);"></TD>
  152. <TD><INPUT NAME="Eight" TYPE="Button" VALUE=" 8 " onClick="NumPressed(8);"></TD>
  153. <TD><INPUT NAME="Nine" TYPE="Button" VALUE=" 9 " onClick="NumPressed(9);"></TD>
  154. <TD></TD>
  155. <TD><INPUT NAME="Neg" TYPE="Button" VALUE=" +/- " ></TD>
  156. <TD><INPUT NAME="Percent" TYPE="Button" VALUE=" % " ></TD>
  157. </TR>
  158. <TR>
  159. <TD><INPUT NAME="Four" TYPE="Button" VALUE=" 4 " onClick="NumPressed(4);"></TD>
  160. <TD><INPUT NAME="Five" TYPE="Button" VALUE=" 5 " onClick="NumPressed(5);"></TD>
  161. <TD><INPUT NAME="Six" TYPE="Button" VALUE=" 6 " onClick="NumPressed(6);"></TD>
  162. <TD></TD>
  163. <TD ALIGN=MIDDLE><INPUT NAME="Plus" TYPE="Button" VALUE=" + " ></TD>
  164. <TD ALIGN=MIDDLE><INPUT NAME="Minus" TYPE="Button" VALUE=" - " ></TD>
  165. </TR>
  166. <TR>
  167. <TD><INPUT NAME="One" TYPE="Button" VALUE=" 1 " onClick="NumPressed(1);"></TD>
  168. <TD><INPUT NAME="Two" TYPE="Button" VALUE=" 2 " onClick="NumPressed(2);"></TD>
  169. <TD><INPUT NAME="Three" TYPE="Button" VALUE=" 3 " onClick="NumPressed(3);"></TD>
  170. <TD></TD>
  171. <TD ALIGN=MIDDLE><INPUT NAME="Multiply" TYPE="Button" VALUE=" * " ></TD>
  172. <TD ALIGN=MIDDLE><INPUT NAME="Divide" TYPE="Button" VALUE=" / " ></TD>
  173. </TR>
  174. <TR>
  175. <TD><INPUT NAME="Zero" TYPE="Button" VALUE=" 0 " onClick="NumPressed(0);"></TD>
  176. <TD><INPUT NAME="Decimal" TYPE="Button" VALUE=" . " ></TD>
  177. <TD COLSPAN=3></TD>
  178. <TD><INPUT NAME="Enter" TYPE="Button" VALUE="Enter"></TD>
  179. </TR>
  180. </TABLE>
  181. </TABLE>
  182. </B>
  183. </FORM>
  184. <BR><BR>
  185. </FONT>
  186. <HR>
  187. <FONT SIZE=2>
  188. If this sample doesn't work, download <A HREF="http://www.microsoft.com/ie">Internet Explorer 3.0</A> now.
  189. </FONT>
  190. <TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 width=600>
  191. <TR VALIGN=TOP>
  192. <TD ALIGN=RIGHT>
  193. <FONT FACE="Arial, Helvetica" SIZE="1">
  194. <B>Best experienced with<BR>
  195. <A HREF="http://www.microsoft.com/ie" TARGET="_top"><img src="ie_animated.gif" width="88" height="31" border="0" alt="Microsoft Internet Explorer" vspace="5"></a>
  196. <BR>Click here to start.</B>
  197. </FONT></TD>
  198. </TR>
  199. </TABLE>
  200. </BODY>
  201. </HTML>