Lazarus

Free Pascal => Beginners => Topic started by: Raul_ES on January 28, 2020, 08:10:27 pm

Title: Get all components in a form and save values
Post by: Raul_ES on January 28, 2020, 08:10:27 pm
Hello,

I am working in a project where I have a form to manipulate configuration options of the application. This form has several tabsheets, checkboxes, etc.


I dont know how to:

* make a recursive iteration through  all the components contained

* check their values, true, false, a number, a string with a url, etc

* how to store them. I mean, obviously you can store them into a file but what is the best option/format for storing config and parameters when we talk of a multiplatform application? what you recommend? plain text, binary, use records, a dbf file? there are so many ways... is there any example?


regards
Title: Re: Get all components in a form and save values
Post by: Raul_ES on January 28, 2020, 08:15:31 pm
The form is something like this:
Title: Re: Get all components in a form and save values
Post by: Raul_ES on January 28, 2020, 08:20:49 pm
I found this example for iterating all components

Code: Pascal  [Select][+][-]
  1. procedure TForm.GetComponentList(Memo1: TMemo)
  2. var
  3.   i: Integer;
  4. begin
  5.  for i := 0 to ComponentCount-1 do
  6. if (NOT (Components[i] is TControl)) and (NOT Components[i].HasParent) then
  7.   Memo1.Lines.Add(Components[i].Name);
  8. end;


I am not sure about how to read the value if it's an iteration through "unknown" components. It will depend  on the nature of the component isn't it?
Title: Re: Get all components in a form and save values
Post by: CLA on January 28, 2020, 08:37:30 pm
this might help you get started
https://forum.lazarus.freepascal.org/index.php?topic=34222.0 (https://forum.lazarus.freepascal.org/index.php?topic=34222.0)
Title: Re: Get all components in a form and save values
Post by: Raul_ES on January 28, 2020, 10:05:23 pm
thank you very much, I'll check it right now

regards
TinyPortal © 2005-2018