Rev 733 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
733 | daniel-mar | 1 | program LISTTEST; |
2 | |||
3 | (************************************************) |
||
4 | (* LISTTEST.PAS *) |
||
5 | (* Author: Daniel Marschall *) |
||
735 | daniel-mar | 6 | (* Revision: 2022-02-13 *) |
733 | daniel-mar | 7 | (* License: Apache 2.0 *) |
8 | (* This file contains: *) |
||
9 | (* - Example how to use lists and selection CUI *) |
||
10 | (************************************************) |
||
11 | |||
12 | uses |
||
13 | Crt, StrList, VtsCui; |
||
14 | |||
15 | var |
||
16 | items: PStringList; |
||
17 | i, itemIndex: integer; |
||
18 | sTmp: string; |
||
19 | begin |
||
20 | InitList(items); |
||
21 | |||
22 | (* Fill the list for testing *) |
||
23 | for i := 1 to 5 do |
||
24 | begin |
||
25 | str(i, sTmp); |
||
26 | ListAppend(items, 'list item '+sTmp); |
||
27 | end; |
||
28 | |||
29 | (* Do inserts and deletions to test their functionality *) |
||
30 | ListInsert(items, 'TEST', 0); |
||
31 | ListDeleteElement(items, 0); |
||
32 | ListDeleteElement(items, 0); |
||
33 | ListInsert(items, 'FirstElement', 0); |
||
34 | |||
35 | (* Test the selection GUI unit *) |
||
36 | ClrScr; |
||
37 | itemIndex := DrawSelectionList(3, 5, 15, 10, items, true, 0); |
||
38 | ClrScr; |
||
39 | if itemIndex = -1 then |
||
40 | begin |
||
41 | WriteLn('Nothing was selected.'); |
||
42 | end |
||
43 | else |
||
44 | begin |
||
45 | WriteLn('Following element was selected: "'+ListGetElement(items,itemIndex)+'"'); |
||
46 | end; |
||
47 | WriteLn('Press RETURN to return to DOS.'); |
||
48 | |||
49 | FreeList(items); |
||
50 | |||
51 | ReadLn; |
||
52 | end. |