Grids shows error when compiling lazarus / 39-Graphics ---------------------------------------------------------------------- abtaylr · 2019-07-26 18:59 I am working on updating an application originally done in Delphi. As I have been working through debugging various issues, the compiler began giving an error from the Grids procedures shown beginning at line 2239: 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 CfgSetFontValue(cfg: TXMLConfig; AKey: WideString; AFont: TFont);begin  cfg.SetValue(AKey + '/name/value', AFont.Name);  cfg.SetValue(AKey + '/size/value', AFont.Size);  cfg.SetValue(AKey + '/color/value', ColorToString(AFont.Color));  cfg.SetValue(AKey + '/style/value', Integer(AFont.Style));end; procedure CfgGetFontValue(cfg: TXMLConfig; AKey: WideString; AFont: TFont);begin  AFont.Name := cfg.GetValue(AKey + '/name/value', 'default');  AFont.Size := cfg.GetValue(AKey + '/size/value', 0);  AFont.Color:= StringToColor(cfg.GetValue(AKey + '/color/value', 'clWindowText'));   AFont.Style:= TFontStyles(cfg.GetValue(AKey + '/style/value', 0));end; The two problems arise from Integer(AFont.Style) shown in the first procedure and  AFont.Style:= TFontStyles(cfg.GetValue(AKey + '/style/value', 0)); in the second procedure.  TFontStyles comes from the Graphics unit shown at lines 71-72: 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   TFontStyle = (fsBold, fsItalic, fsUnderline, fsStrikeOut);  TFontStyles = set of TFontStyle; I looked in Pascal Reference Guide and found the following:  "The compiler stores small sets (less than 32 elements) in a LongInt if the Type Range allows it."  The error message that I am getting is : grids.pas(2044,39) Error: Illegal type conversion: "TFontStyles" to "LongInt" and "grids.pas(2052,17) Error: Illegal type conversion: "LongInt" to "TFontStyles". I am perplexed. I don't see anything wrong in the Grids unit coding, yet I get the errors. ---------------------------------------------------------------------- wp · 2019-07-26 20:05 Which Lazarus and FPC version are you using? The current release versions have different code beginning at line 2239 of unit grids.pas. ---------------------------------------------------------------------- howardpc · 2019-07-26 20:07 You can rarely if ever cast a set to an integer type, whatever the details of a set's implementation might be, partly because the size the compiler chooses for the set is unknown. Where you are certain that a small set is involved, you may be able to do an implicit cast something along these lines (untested): 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 CfgSetFontValue(cfg: TXMLConfig; AKey: WideString; AFont: TFont);var  tmp: TFontStyles;  tmpDWord: DWord absolute tmp;  begin    cfg.SetValue(AKey + '/name/value', AFont.Name);    cfg.SetValue(AKey + '/size/value', AFont.Size);    cfg.SetValue(AKey + '/color/value', ColorToString(AFont.Color));    tmp := AFont.Style;    cfg.SetValue(AKey + '/style/value', tmpDWord);  end; procedure CfgGetFontValue(cfg: TXMLConfig; AKey: WideString; AFont: TFont);var  tmp: DWord;  tmpStyles: TFontStyles absolute tmp;begin  AFont.Name := cfg.GetValue(AKey + '/name/value', 'default');  AFont.Size := cfg.GetValue(AKey + '/size/value', 0);  AFont.Color:= StringToColor(cfg.GetValue(AKey + '/color/value', 'clWindowText'));  tmp := cfg.GetValue(AKey + '/style/value', 0);  AFont.Style:= tmpStyles;end; ---------------------------------------------------------------------- abtaylr · 2019-07-27 00:04 Regarding the fpc and lazarus versions used.  FPC is 3.0.5 r42498 and Laz 2.0.2 r61624. I am using Kubuntu 64bit v.19.04 I'll try out the suggested code and see how it fairs. Thanks abt ---------------------------------------------------------------------- abtaylr · 2019-07-27 00:07 We have a winner! I have successfully moved to my next error. Thanks for the assistance.