Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Checkbox
Mon, Jan 14 2013 9:22 PMPermanent Link

cwsymons

Hi everyone,
 I am trying to use the following line of code to toggle a checkbox

frmServerSettings.chkWinUser.Checked := StrToBool(aStringList.Values['winuser']);

aStringList.Values['winuser'] has a value of 'True' or 'False'.

This is failing yet I can toggle the checkbox by using

frmServerSettings.chkWinUser.Checked := True/False;

can someone investigate please
Tue, Jan 15 2013 11:40 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<<  I am trying to use the following line of code to toggle a checkbox

frmServerSettings.chkWinUser.Checked :=
StrToBool(aStringList.Values['winuser']);

aStringList.Values['winuser'] has a value of 'True' or 'False'. >>

Are you sure that the value being returned from the Values reference is
'True' or 'False' ?

I tried the following here:

procedure TForm1.Button3Click(Sender: TObject);
begin
  if CheckBox1.Checked then
     CheckBox1.Checked:=StrToBool('False')
  else
     CheckBox1.Checked:=StrToBool('True');
end;

and it correctly checks/un-checks the check box, as expected.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Jan 15 2013 7:30 PMPermanent Link

cwsymons

"Tim Young [Elevate Software]" wrote:


<<  I am trying to use the following line of code to toggle a checkbox

frmServerSettings.chkWinUser.Checked :=
StrToBool(aStringList.Values['winuser']);

aStringList.Values['winuser'] has a value of 'True' or 'False'. >>

Are you sure that the value being returned from the Values reference is
'True' or 'False' ?

I tried the following here:

procedure TForm1.Button3Click(Sender: TObject);
begin
  if CheckBox1.Checked then
     CheckBox1.Checked:=StrToBool('False')
  else
     CheckBox1.Checked:=StrToBool('True');
end;

and it correctly checks/un-checks the check box, as expected.

Tim Young
Elevate Software
www.elevatesoft.com

Hi Tim,
 I can duplicate what you have been able to do, but I cannot for the life of me get the TStringlist.Values to succeed.

I did a test to see if the presence of additional non visible characters

if (pos(aStringList.Values['winuser'], #13) > 0) then
 ShowMessage('Carriage Return');

This displayed the message, so I tried removing the #13.

Test := StrReplace(aStringList.Values['winuser'], #13, '');
frmServerSettings.chkWinUser.Checked := StrToBool(Test);

Still failed.

Test := copy(aStringList.Values['winuser'], 1, 4);
frmServerSettings.chkWinUser.Checked := StrToBool(Test);

Worked (obviously if Test = 'True' it was checked otherwise unchecked)

what am I missing?
Tue, Jan 15 2013 9:09 PMPermanent Link

Raul

Team Elevate Team Elevate


On 1/15/2013 7:30 PM, cwsymons wrote:
> what am I missing?
>

Your aStringlist value is not true or false.

Start with something simpler.

Does following work for you ?

procedure TForm1.Button1Click(Sender: TObject);
var
   aStringList:TStringList;
begin
   aStringList := TStringList.Create;
   aStringList.Add('truevalue=False');
   aStringList.Add('winuser=True');
   aStringList.Add('truevalue=False');
   CheckBox13.Checked := StrToBool(aStringList.Values['winuser']);
   aStringList.Free;
end;

It works fine here (checkbox gets checked) so the issue has to be value
in your stringlist since both stringlist values and checkbox work as
expected.

What does the aStringList.Values['winuser'] actually return in your case
(and what does the aStringList.Text show )?

Raul

NB! When replying please do not include the previous message in entirety.
Tue, Jan 15 2013 9:33 PMPermanent Link

cwsymons

Hi Raul,
 yes it works for me.  

I've attached what is displayed when I show the text



Attachments: aStringList.png
Wed, Jan 16 2013 11:15 AMPermanent Link

Raul

Team Elevate Team Elevate

This looks all good so it should clear the checkbox - is it still not
doing so ?

Raul


On 1/15/2013 9:33 PM, cwsymons wrote:
>    yes it works for me.
> I've attached what is displayed when I show the text
>
Wed, Jan 16 2013 5:13 PMPermanent Link

cwsymons

Hi Raul,
 sorry but no, I have created a work around for the time being

regards


Craig
Thu, Jan 17 2013 10:16 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<<  I can duplicate what you have been able to do, but I cannot for the life
of me get the TStringlist.Values to succeed. >>

Where are the values in the string list coming from ?  Are they coming from
the back-end via a TServerRequest, or are you populating them in the EWB
application ?

<< I did a test to see if the presence of additional non visible characters

if (pos(aStringList.Values['winuser'], #13) > 0) then
  ShowMessage('Carriage Return'); >>

That's not a good sign and indicates that the initial population of the
string list is going awry.

As always, if you want to send me a project, I'll be happy to test it and
see if there's any issue on the EWB side.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com


Thu, Jan 17 2013 8:43 PMPermanent Link

cwsymons

"Tim Young [Elevate Software]" wrote:


<<  I can duplicate what you have been able to do, but I cannot for the life
of me get the TStringlist.Values to succeed. >>

Where are the values in the string list coming from ?  Are they coming from
the back-end via a TServerRequest, or are you populating them in the EWB
application ?

<< I did a test to see if the presence of additional non visible characters

if (pos(aStringList.Values['winuser'], #13) > 0) then
  ShowMessage('Carriage Return'); >>

That's not a good sign and indicates that the initial population of the
string list is going awry.

As always, if you want to send me a project, I'll be happy to test it and
see if there's any issue on the EWB side.

Thanks,

Hi Tim,
 yes the values in the stringlist are coming from the backend via a TServerRequest. I've attached the line of code that returns the strings. Below is the text as diaplyed in the evaluator.

'abscontrol=C:\Program Files\SmartBear\Automated Build Studio\bin'#$D#$A'absserver=LocalHost'#$D#$A'winuser=True'#$D#$A'userpc=False'#$D#$A'macrolocation=Macro'#$D#$A'parameterlocation=Parameter'#$D#$A'refreshperiodsec=10'#$D#$A

This is standard for Delphi text out of a stringlist.

regards

Craig




Attachments: ServerCode.png
Fri, Jan 18 2013 9:28 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Craig,

<< yes the values in the stringlist are coming from the backend via a
TServerRequest. I've attached the line of code that returns the strings.
Below is the text as diaplyed in the evaluator. >>

Okay, try this in your TServerRequest before executing the request:

MyServerRequest.ResponseContent.LineSeparator:=CR+LF;
MyServerRequest.Execute;

The default LineSeparator is just the LF character, and CR and LF are
defined as constants in the WebCore unit.  In the browser, LF is normally
the only thing necessary for line feeds in things like memos, etc., so that
is what it defaults to.

If you have any other questions, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com
Image