Rev 735 | 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 *) |
||
747 | daniel-mar | 6 | (* Revision: 2022-02-16 *) |
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 |
||
747 | daniel-mar | 13 | Crt, Drivers, StrList, VtsCui; |
733 | daniel-mar | 14 | |
15 | var |
||
16 | items: PStringList; |
||
17 | i, itemIndex: integer; |
||
18 | sTmp: string; |
||
19 | begin |
||
747 | daniel-mar | 20 | InitVideo; |
21 | CursorOff; |
||
733 | daniel-mar | 22 | |
747 | daniel-mar | 23 | CreateList(items); |
24 | |||
733 | daniel-mar | 25 | (* Fill the list for testing *) |
26 | for i := 1 to 5 do |
||
27 | begin |
||
28 | str(i, sTmp); |
||
29 | ListAppend(items, 'list item '+sTmp); |
||
30 | end; |
||
31 | |||
32 | (* Do inserts and deletions to test their functionality *) |
||
33 | ListInsert(items, 'TEST', 0); |
||
747 | daniel-mar | 34 | ListDeleteElementByIndex(items, 0); |
35 | ListDeleteElementByIndex(items, 0); |
||
733 | daniel-mar | 36 | ListInsert(items, 'FirstElement', 0); |
37 | |||
38 | (* Test the selection GUI unit *) |
||
39 | ClrScr; |
||
747 | daniel-mar | 40 | itemIndex := DrawSelectionList(3, 5, 15, 10, items, true, '', 0); |
41 | ResetDefaultDosColors; |
||
733 | daniel-mar | 42 | ClrScr; |
43 | if itemIndex = -1 then |
||
44 | begin |
||
45 | WriteLn('Nothing was selected.'); |
||
46 | end |
||
47 | else |
||
48 | begin |
||
49 | WriteLn('Following element was selected: "'+ListGetElement(items,itemIndex)+'"'); |
||
50 | end; |
||
51 | WriteLn('Press RETURN to return to DOS.'); |
||
52 | |||
53 | FreeList(items); |
||
54 | |||
55 | ReadLn; |
||
747 | daniel-mar | 56 | |
57 | CursorOn; |
||
58 | DoneVideo; |
||
733 | daniel-mar | 59 | end. |