TStringList Assigments lazarus / 61-Beginners ---------------------------------------------------------------------- JLWest · 2020-11-18 23:04 I get an error at line 7. unit1.pas(968,19) Error: Incompatible types: got "TStrings" expected "TStringList" LBWork.Items.Assign(TList); Didn't work. Maybe it should be LBWork.Items.Assign(TList); Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DisplayMemo( AFLENAME : String ); Var  TList : TStringList; begin  TList:= TStringList.Create;  Try   TList := LBWork.Items;                 {<=== Error}   M1.Lines.AddStrings(TList, True);  finally   TList.Free;  end;  M1.Visible := True;  M1.BringToFront; end; ---------------------------------------------------------------------- Sieben · 2020-11-18 23:23 First of all, it's not a good idea to name a var like a type: TList. Second, it's not really clear what LBWork is. Third, the param of this proc is never used. But I guess(!) - supposing M1 is a TMemo - it's just Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i M1.Lines.AddStrings(LBWork.Items,True); ---------------------------------------------------------------------- JLWest · 2020-11-18 23:39 Thanks Yes, that worked. About the parm in DisplayMmemo, At present it is not used. It was earlier and now needs to be removed. Name conventions I suppose I could go to Listbox1 and TStringList1, but I can't do it in this program. Have enough problems the way it is. Maybe trying to something that isn't possible. ---------------------------------------------------------------------- winni · 2020-11-18 23:53 Hi! Short and rough for line 7: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TList := TStringList(LBWork.Items); Winni ---------------------------------------------------------------------- jamie · 2020-11-19 01:08 heck I'll add something Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  Tlist.Assign(LbWork.Items); ---------------------------------------------------------------------- Remy Lebeau · 2020-11-19 17:41 Quote from: JLWest on November 19, 2020, 12:04:30 amI get an error at line 7. unit1.pas(968,19) Error: Incompatible types: got "TStrings" expected "TStringList" The error is self-explanatory.  The LBWork.Items property is clearly a TStrings object, which you are trying to assign to a TStringList variable, but that won't work since TStrings does not derive from TStringList (the opposite is true). In this case, you can simply get rid of your TStringList object altogether (you are not using it correctly anyway), and change your local variable to TStrings, eg: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DisplayMemo( AFLENAME : String );var  TheList : TStrings;begin  TheList := LBWork.Items;  M1.Lines.AddStrings(TheList, True);  M1.Visible := True;  M1.BringToFront;end; Which can then be simplified by getting rid of the variable altogether: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DisplayMemo( AFLENAME : String );begin  M1.Lines.AddStrings(LBWork.Items, True);  M1.Visible := True;  M1.BringToFront;end; ---------------------------------------------------------------------- Remy Lebeau · 2020-11-19 17:44 Quote from: winni on November 19, 2020, 12:53:15 amShort and rough for line 7: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TList := TStringList(LBWork.Items); That will only work if the implementation object that is backing the LBWork.Items property is actually a TStringList object, and not something else, like says a TListBoxStrings object.  In this case, that cast is not needed since the LBWork.Items property returns a TStrings, and M1.Lines.AddStrings() takes a TStrings as input.  The TStringList is completely unnecessary. ---------------------------------------------------------------------- JLWest · 2020-11-19 22:34 @Remy Lebeau Hmh  I try to implement that. Thank You