Board index » delphi » confusion about tstringlists

confusion about tstringlists

I am using indy 9.0.3b to retrieve a webpage. No big deal, right?

Well, the problem that I have is I am getting an access violation, and
Delphi is informing me that .Text on a TStringlist isn't allowed. When
checking Remotefile1.Text I see the 'hint' Expression illegal in Evaluator.

with this information :

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ComCtrls, ExtCtrls, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdHTTP, Dialogs;

 Remotefile1: Tstringlist;
 http : tidhttp;

LoginURL := 'http://my.website.com/anasp.asp?login=%s&password=%s';

urltext:= Format(LoginURL, [UserName.Text, PassWord.Text]);
Remotefile1.Text := HTTP.Get(urltext);

I don't understand what's wrong, because  I have another program that I got
to work on indy 8 that did the same thing, and I can still run it under 9.

 

Re:confusion about tstringlists


Quote
"Frederick" wrote:
> N/M
> I thought of something after I posted.

> Why do I have to do the following:

> Remotefile1 := TStringList.Create;

> When the other program does not?

What other program? What does it do with the TStringList?

--
Dave Nottage (TeamB)

Re:confusion about tstringlists


N/M
I thought of something after I posted.

Why do I have to do the following:

Remotefile1 := TStringList.Create;

When the other program does not?

I don't get that.

Quote
> I am using indy 9.0.3b to retrieve a webpage. No big deal, right?

> Well, the problem that I have is I am getting an access violation, and
> Delphi is informing me that .Text on a TStringlist isn't allowed. When
> checking Remotefile1.Text I see the 'hint' Expression illegal in
Evaluator.

> with this information :

> uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
>   Buttons, ComCtrls, ExtCtrls, IdBaseComponent, IdComponent,
>   IdTCPConnection, IdTCPClient, IdHTTP, Dialogs;

>  Remotefile1: Tstringlist;
>  http : tidhttp;

> LoginURL := 'http://my.website.com/anasp.asp?login=%s&password=%s';

> urltext:= Format(LoginURL, [UserName.Text, PassWord.Text]);
> Remotefile1.Text := HTTP.Get(urltext);

> I don't understand what's wrong, because  I have another program that I
got
> to work on indy 8 that did the same thing, and I can still run it under 9.

Re:confusion about tstringlists


the same thing I did, because I modified it to see if I could do what I want
to do. When I figured out how, I created my own project. The only difference
between the code in the other one, was the
Remotefile1 := TStringList.Create;

That program did the exact same thing. that's what I don't understand. I
guess it's another 'Don't assume the compiler is going to do your dirty
work, because you don't know that the compiler is going to do it for you
every time' thing.
"Dave Nottage (TeamB)" <d...@removethis.b3.com.au> wrote in message
news:3ca12ca2_2@dnews...

Quote
> "Frederick" wrote:
> > N/M
> > I thought of something after I posted.

> > Why do I have to do the following:

> > Remotefile1 := TStringList.Create;

> > When the other program does not?

> What other program? What does it do with the TStringList?

> --
> Dave Nottage (TeamB)

Re:confusion about tstringlists


I'm a novice too, but as explained in the Delphi Help, if you declare your
RemoteFile as TStrings or Tstringlists in the Declarations section, then you
must initialize the var using Tstringlist.Create in the Form.Create
procedure, before you can use the var.

Ishaan

Quote
"Frederick" <jupiter11...@mn.rr.com> wrote in message

news:3ca131d4_1@dnews...
Quote
> the same thing I did, because I modified it to see if I could do what I
want
> to do. When I figured out how, I created my own project. The only
difference
> between the code in the other one, was the
> Remotefile1 := TStringList.Create;

> That program did the exact same thing. that's what I don't understand. I
> guess it's another 'Don't assume the compiler is going to do your dirty
> work, because you don't know that the compiler is going to do it for you
> every time' thing.
> "Dave Nottage (TeamB)" <d...@removethis.b3.com.au> wrote in message
> news:3ca12ca2_2@dnews...
> > "Frederick" wrote:
> > > N/M
> > > I thought of something after I posted.

> > > Why do I have to do the following:

> > > Remotefile1 := TStringList.Create;

> > > When the other program does not?

> > What other program? What does it do with the TStringList?

> > --
> > Dave Nottage (TeamB)

Re:confusion about tstringlists


But, the other program did NOT initialize the var using TStringlist.Create.
Delphi seemed to handle it automatically, so I assumed it did that every
time.

That is where my confusion came from. And what I meant by 'dirty work' was
creating and freeing the variable. But I still don't understand why a group
of code that is the same in one program doesn't do the same thing in
another.... I have seen that happen with Borland C++ before... about 2 years
ago.  I think it was ver 4.something.... I remember creating a program, and
it not work, but then I copied the code on top of one of the demo's,
completely replacing the code with mine, and it worked just fine..... but
vice versa didn't.  I never did figure that out.

Yes I assumed, I know, I know, that can get you in lots of trouble,  Look at
Windows.

Quote
"Ishaan Dalal" <i...@izx.yoll.net> wrote in message news:3ca2c06d_2@dnews...
> I'm a novice too, but as explained in the Delphi Help, if you declare your
> RemoteFile as TStrings or Tstringlists in the Declarations section, then
you
> must initialize the var using Tstringlist.Create in the Form.Create
> procedure, before you can use the var.

> Ishaan

> "Frederick" <jupiter11...@mn.rr.com> wrote in message
> news:3ca131d4_1@dnews...
> > the same thing I did, because I modified it to see if I could do what I
> want
> > to do. When I figured out how, I created my own project. The only
> difference
> > between the code in the other one, was the
> > Remotefile1 := TStringList.Create;

> > That program did the exact same thing. that's what I don't understand. I
> > guess it's another 'Don't assume the compiler is going to do your dirty
> > work, because you don't know that the compiler is going to do it for you
> > every time' thing.
> > "Dave Nottage (TeamB)" <d...@removethis.b3.com.au> wrote in message
> > news:3ca12ca2_2@dnews...
> > > "Frederick" wrote:
> > > > N/M
> > > > I thought of something after I posted.

> > > > Why do I have to do the following:

> > > > Remotefile1 := TStringList.Create;

> > > > When the other program does not?

> > > What other program? What does it do with the TStringList?

> > > --
> > > Dave Nottage (TeamB)

Other Threads