Have different sets of defined consts to use them while runtime (solved) lazarus / 61-Beginners ---------------------------------------------------------------------- teochris · 2016-03-20 19:55 Hello, In my app i have defined a set of consts for colors like below to use them in runtime but I want to have another three or four sets with the same names so the user of my app could change color combinations just by clicking a button. Can this be done somehow? 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   // set one of consts  const  MainAppBaCol                  = $00F2F1F1;  TitlosMainFoCol               = clBlack;  TitlosMainBaCol             = $00E2D6A1;  InfoMainFoCol                 = TitlosMainFoCol;  InfoMainBaCol                 = clNone;  ButtonsMainFoCol              = clBlack;  ButtonsMainBaCol              = $00E1E1E1;  ButtonsEn1FoCol               = clBlack;  ButtonsEn1BaCol             = $00FBF1E5;  ButtonsEn0FoCol               = ButtonsMainFoCol;  ButtonsEn0BaCol               = ButtonsMainBaCol;    // set two of consts  const  MainAppBaCol                  = $00F2F2F1;  TitlosMainFoCol               = clwhite;  TitlosMainBaCol             = $00E2D6A3;  InfoMainFoCol                 = TitlosMainFoCol;  InfoMainBaCol                 = clNone;  ButtonsMainFoCol           = clBlack;  ButtonsMainBaCol           = $00E1E4E1;  ButtonsEn1FoCol          = clBlack;  ButtonsEn1BaCol            = $00FBF5E5;  ButtonsEn0FoCol            = ButtonsMainFoCol;  ButtonsEn0BaCol          = ButtonsMainBaCol;  So when the the user clicks a button the second set of consts is used and not set one. Or is there a way to declare colors in variables (because when I try it I get the error message saying 'got AnsiString expected TgraphicsColor' I see this error message for example when i set a variable to string type and then define it as 'clBlack' ---------------------------------------------------------------------- howardpc · 2016-03-20 20:55 The attached simple project shows one way to do this using enumerated types and arrays. ---------------------------------------------------------------------- teochris · 2016-03-21 09:15 Quote from: howardpc on March 20, 2016, 09:55:23 pmThe attached simple project shows one way to do this using enumerated types and arrays. Hello and a Great Thanks for sharing your knowledge and time with us! I am still trying to understand how it works exactly but I am sure I does what I need! I am oblidged to you!!! One small thing is that i see the attached error messages after i close the app ---------------------------------------------------------------------- howardpc · 2016-03-21 11:52 I don't get the first error here (Linux 64-bit, Laz 1.6 release). What is your OS and Lazarus/FPC version? The second 'error' is just heaptrc showing you that there are no memory leaks. The Heaptrc window always says "Error" even when there is no memory leak detected. This is a Heaptrc shortcoming that I always mean to submit a patch for, but never have been bothered about enough to give time to devising. However, it does disturb newcomers to Heaptrc. Heaptrc is an invaluable debugging aid, and I always use it when developing Pascal programs. You enable it most simply via a checkbox in the Debugging page of your project's Options (Ctrl+Shift+F11 is the default hotkey). ---------------------------------------------------------------------- teochris · 2016-03-21 16:42 Quote from: howardpc on March 21, 2016, 12:52:26 pmI don't get the first error here (Linux 64-bit, Laz 1.6 release). What is your OS and Lazarus/FPC version? The second 'error' is just heaptrc showing you that there are no memory leaks. The Heaptrc window always says "Error" even when there is no memory leak detected. This is a Heaptrc shortcoming that I always mean to submit a patch for, but never have been bothered about enough to give time to devising. However, it does disturb newcomers to Heaptrc. Heaptrc is an invaluable debugging aid, and I always use it when developing Pascal programs. You enable it most simply via a checkbox in the Debugging page of your project's Options (Ctrl+Shift+F11 is the default hotkey). I have windows 10 x64 and lazarus 1.6 - fpc 3.0.0 - svn 51630 ---------------------------------------------------------------------- howardpc · 2016-03-21 17:07 I tried compiling the example program on Win7. It ran with no errors. So I have no idea why your Win10 target gives an error. I don't have Win10, and am not likely to upgrade. Maybe someone else can shed light on this? Do you still see the error if you compile without debugging info, and run outside the Lazarus IDE? ---------------------------------------------------------------------- teochris · 2016-03-21 17:25 Quote from: howardpc on March 21, 2016, 06:07:47 pmI tried compiling the example program on Win7. It ran with no errors. So I have no idea why your Win10 target gives an error. I don't have Win10, and am not likely to upgrade. Maybe someone else can shed light on this? Do you still see the error if you compile without debugging info, and run outside the Lazarus IDE? I see the similar error (first one) even if I run the executable outside lazarus - I also run the executable in a windows 7 pc and i still get the same error. I re-exctracted the compressed folder in my windows 7 pc and then I compiled it also there and again the same error (first one). ---------------------------------------------------------------------- Bart · 2016-03-21 18:16 No SIGSEV here. Lazarus 1.7 r51837 FPC 3.0.0 i386-win32-win32/win64 32-bit compiler on Win7-64. Bart ---------------------------------------------------------------------- teochris · 2016-03-23 00:02 Quote from: howardpc on March 21, 2016, 06:07:47 pmI tried compiling the example program on Win7. It ran with no errors. So I have no idea why your Win10 target gives an error. I don't have Win10, and am not likely to upgrade. Maybe someone else can shed light on this? Do you still see the error if you compile without debugging info, and run outside the Lazarus IDE? I used your example in my app and everything works fine with no errors like in your file - your suggestion does what i need - thanks again for the useful sharing of your knowledge! * I haven't understood thought, why did i have to write twice type and const for it to work properly, but i can live with this question of mine  ** I had to declared the 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 FColorArr: TColorArr; to the public section so my other forms can also work properly