4
A small test of linklist unit.
6
nils.sjoholm@mailbox.swipnet.se
29
AddNewNode(Mylist,'Monday');
30
AddNewNode(Mylist,'Tuesday');
31
AddNewNode(Mylist,'Wednesday');
32
AddNewNode(Mylist,'Thursday');
33
AddNewNode(Mylist,'Friday');
34
AddNewNode(Mylist,'Saterday');
35
AddNewNode(Mylist,'Sunday');
38
WriteLN('This is the list');
42
WriteLN('Now we are going to remove the last node');
43
WriteLN('>> Press return');
45
RemoveLastNode(Mylist);
49
WriteLN('>> Press return to get the size of the list');
52
WriteLN('The size of allocated list is ', SizeOfList(Mylist));
55
writeln('Now we are going to print all strings' +#10+ 'in the list with the internal commands');
56
WriteLN('>> Press return');
59
i := NodesInList(Mylist);
60
MyNode := GetFirstNode(Mylist);
61
FOR temp := 1 TO i DO BEGIN
62
WriteLN(MyNode^.ln_Name);
63
MyNode := GetNextNode(MyNode);
67
WriteLN('We will move the last node to the top');
68
WriteLN('>> Press return');
70
MyNode := GetLastNode(Mylist);
71
MoveNodeTop(Mylist,MyNode);
75
WriteLN('We shall change the value in one node');
76
WriteLN('>> Press return');
78
MyNode := GetFirstNode(Mylist);
79
MyNode := GetNextNode(MyNode);
80
UpDateNode(MyNode,'This is the new day');
84
MyNode := GetNextNode(MyNode);
85
WriteLN('Now we delete one node');
86
WriteLN('>> Press return');
88
WriteLN('This node is going to be deleted ',GetNodeData(MyNode));
93
WriteLN('Sort the list');
94
WriteLN('>> Press return');
100
writeln('Search for a node, in this case Friday');
101
WriteLN('>> Press return');
103
MyNode := FindNodeData(Mylist,'Friday');
104
IF MyNode <> NIL THEN BEGIN
105
WriteLN('found the node ',MyNode^.ln_Name);
106
{ or writeln('found the node ',GetNodeData(MyNode)); }
108
WriteLN('Node not found');
112
WriteLN('And now copy the list to a stringbuffer' +#10+ 'and print it');
113
WriteLN('>> Press return');
115
bufsize := SizeOfList(Mylist);
116
buffer := StrAlloc(bufsize);
117
ListToBuffer(Mylist,buffer);
121
WriteLN('Now we try to copy the list to a new list');
122
WriteLN('>> Press return');
124
templist := CopyList(Mylist);
125
IF templist <> NIL THEN BEGIN
126
WriteLN('That went well, the new list is here');
128
DestroyList(templist);
130
WriteLN('no copy of list');
134
WriteLN('Press return to destroy the list');