54 lines
1.4 KiB
HTML
54 lines
1.4 KiB
HTML
<html>
|
|
<head>
|
|
<link rel=stylesheet type="text/css" href="styles.css">
|
|
</head>
|
|
<body>
|
|
<H2>
|
|
Pascal samples. Script-defined callback functions.
|
|
</H2>
|
|
<hr>
|
|
|
|
<blockquote>
|
|
|
|
<pre>
|
|
<font color="blue"><b>uses</b></font> Classes;
|
|
|
|
<font color="blue"><b>function</b></font> Compare(Item1, Item2: Pointer): Integer; <font color="blue"><b>register</b></font>;
|
|
<font color="blue"><b>begin</b></font>
|
|
<font color="blue"><b>if</b></font> Integer(Item1) > Integer(Item2) <font color="blue"><b>then</b></font>
|
|
result := 1
|
|
<font color="blue"><b>else</b></font> <font color="blue"><b>if</b></font> Integer(Item1) < Integer(Item2) <font color="blue"><b>then</b></font>
|
|
result := -1
|
|
<font color="blue"><b>else</b></font>
|
|
result := 0;
|
|
<font color="blue"><b>end</b></font>;
|
|
|
|
<font color="blue"><b>var</b></font>
|
|
L: TList;
|
|
I: Integer;
|
|
<font color="blue"><b>begin</b></font>
|
|
L := TList.Create;
|
|
L.Add(Pointer(3));
|
|
L.Add(Pointer(1));
|
|
L.Add(Pointer(2));
|
|
L.Add(Pointer(6));
|
|
L.Add(Pointer(4));
|
|
L.Add(Pointer(5));
|
|
L.Sort(@Compare);
|
|
<font color="blue"><b>for</b></font> I:=0 <font color="blue"><b>to</b></font> L.Count - 1 <font color="blue"><b>do</b></font>
|
|
writeln(Integer(L[I]));
|
|
L.Free;
|
|
<font color="blue"><b>end</b></font>.
|
|
</pre>
|
|
</blockquote>
|
|
|
|
|
|
<p>
|
|
<HR>
|
|
<font size = 1 color ="gray">
|
|
Copyright © 2006-2009
|
|
VIRT Laboratory. All rights reserved.
|
|
</font>
|
|
</body>
|
|
</html>
|