Solved

Need Help Delphi 2010 CheckBox1 Stored value in memo

Posted on 2016-11-28
13
113 Views
Last Modified: 2016-12-10
Hello Guys I'm new with Delphi which uses pascal language.
I'm trying to create simple application which loaded all values in sMemo.Text. All Strings were working fine except with Boolean values "CheckBox and radio Buttons"
here is the line I'm using
sMemo1.Lines.Add(sCheckBox1.Create );
it gives me an error
[DCC Error] Unit1.pas(44): E2035 Not enough actual parameters.

here is my whole code

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, sCheckBox, sRadioButton, sGroupBox, sButton, sEdit, sMemo,
  sLabel;

type
  TForm1 = class(TForm)
    sMemo1: TsMemo;
    sEdit1: TsEdit;
    sEdit2: TsEdit;
    sEdit3: TsEdit;
    sButton1: TsButton;
    sButton2: TsButton;
    sGroupBox1: TsGroupBox;
    sRadioButton1: TsRadioButton;
    sRadioButton2: TsRadioButton;
    sCheckBox1: TsCheckBox;
    sMemo2: TsMemo;
    sLabel1: TsLabel;
    procedure sButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.sButton1Click(Sender: TObject);
begin
sMemo1.Clear;
sMemo1.Lines.Add(sEdit1.Text);
sMemo1.Lines.Add(sEdit2.Text);
sMemo1.Lines.Add(sEdit3.Text);
sMemo1.Lines.Add(sCheckBox1.Create);
end;
end.


Anyone here knows that. My main purpose with this app is to load all configuration into memo instead of an ini file wich is easy to read an modified with someone. I want to load all config i memo and encrypt  content in memo and save it as a file format
0
Comment
Question by:Yaku Kakashi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
13 Comments
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 41903736
checkbox.text doesn't exist ?

it's certainly not the constructor
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 41903737
what components are those ?
never seen an sRadioButton, sGroupBox, etc in the uses clause
0
 

Author Comment

by:Yaku Kakashi
ID: 41903749
Sorry that is CheckBox1.Checked
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Yaku Kakashi
ID: 41903751
Just don't mind the other types I remove some of those Just the button1 only
0
 
LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 500 total points
ID: 41903752
for the checkbox and radiobutton you'll have to convert a boolean to a string


why exactly do you want to use "a visual component" (= memo) for something you don't want users to see ?
it is a common misconcept
use a TStrings instead

procedure TForm1.sButton1Click(Sender: TObject);
  function BoolToStr(b: Boolean): string;
  begin
    Result := '0';
    if b then Result := '1';
  end;
var List: TStrings;
begin
  List := TStringList.Create;
  try
    List.Add(sEdit1.Text);
    List.Add(sEdit2.Text);
    List.Add(sEdit3.Text);
    List.Add(BoolToStr(sCheckBox1.Checked));
    List.SaveToFile('yourtextfile.txt');
    // to see the actual text in a memo: 
    // smemo1.Lines.Assign(List);
  finally
    List.Free;
  end;
end.

Open in new window

1
 

Author Comment

by:Yaku Kakashi
ID: 41903766
Geert Gruwez I'll give it a try. Thank You.
0
 

Author Comment

by:Yaku Kakashi
ID: 41903788
it Works Geert Gruwez, thank you.
0
 

Author Comment

by:Yaku Kakashi
ID: 41903816
Hello sorry to ask you again. how can I retrieve in back using button2
here is My code

function StrToBool(b: Boolean): string;
  begin
    Result := '0';
    if b then Result := '1';
  end;
var List: TStrings;
begin
sEdit1.Text := sMemo1.Lines[0];
sEdit1.Text := sMemo1.Lines[1];
sEdit1.Text := sMemo1.Lines[2];
sCheckBox1.Checked := sMemo1.Lines[3];
end;
0
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 41903950
i thought you were going to come back ...
there will be a problem when you add components.


procedure TForm1.sButton1Click(Sender: TObject);
begin
  SaveSettings;
end;

procedure TForm1.SaveSettings;
  function BoolToStr(b: Boolean): string;
  begin
    Result := '0';
    if b then Result := '1';
  end;
var List: TStrings;
begin
  List := TStringList.Create;
  try
    List.Values['Edit1'] := sEdit1.Text;
    List.Values['Edit2'] := sEdit2.Text;
    List.Values['Edit3'] := sEdit3.Text;
    List.Values['Check1'] := BoolToStr(sCheckBox1.Checked);
    List.SaveToFile('yourtextfile.txt');
    // to see the actual text in a memo: 
    // smemo1.Lines.Assign(List);
  finally
    List.Free;
  end;
end.

procedure TForm1.LoadSettings;
function StrToBool(s: string): boolean;
  begin
    Result := False;
    if s = '1' then Result := True;
  end;
var List: TStrings;
begin
  List := TStringList.Create;
  try
    List.LoadFromFile('yourtextfile.txt');
    sEdit1.Text := List.Values['Edit1'];
    sEdit2.Text := List.Values['Edit2'];
    sEdit3.Text := List.Values['Edit3'];
    sCheckBox1.Checked := StrToBool(List.Values['Check1']);
  finally
    List.Free;
  end;
end;

Open in new window


Hit Ctrl-Shift-C for code completion after replacing the Button1Click procedure with above code
0
 

Author Comment

by:Yaku Kakashi
ID: 41903994
I already Solve it using this code..

procedure TForm1.sButton2Click(Sender: TObject);
var
  value :  String ;
begin
value := sMemo1.Lines[0];
sCheckBox1.Checked := StrToBool(value);
end;

end.
0
 

Author Comment

by:Yaku Kakashi
ID: 41903998
Thank You Geert Gruwez, You are a life saver thank you so much.
0
 

Author Closing Comment

by:Yaku Kakashi
ID: 41904005
Question answered by: Geert Gruwez
Thanks Dude
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 41904087
no problem, dude
1

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question