Subversion Repositories oidplus

Rev

Rev 735 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. program LISTTEST;
  2.  
  3. (************************************************)
  4. (* LISTTEST.PAS                                 *)
  5. (* Author:   Daniel Marschall                   *)
  6. (* Revision: 2022-02-16                         *)
  7. (* License:  Apache 2.0                         *)
  8. (* This file contains:                          *)
  9. (* - Example how to use lists and selection CUI *)
  10. (************************************************)
  11.  
  12. uses
  13.   Crt, Drivers, StrList, VtsCui;
  14.  
  15. var
  16.   items: PStringList;
  17.   i, itemIndex: integer;
  18.   sTmp: string;
  19. begin
  20.   InitVideo;
  21.   CursorOff;
  22.  
  23.   CreateList(items);
  24.  
  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);
  34.   ListDeleteElementByIndex(items, 0);
  35.   ListDeleteElementByIndex(items, 0);
  36.   ListInsert(items, 'FirstElement', 0);
  37.  
  38.   (* Test the selection GUI unit *)
  39.   ClrScr;
  40.   itemIndex := DrawSelectionList(3, 5, 15, 10, items, true, '', 0);
  41.   ResetDefaultDosColors;
  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;
  56.  
  57.   CursorOn;
  58.   DoneVideo;
  59. end.
  60.