Meno1.Text := p
HTH
Graham Harris
SetLength(S,50);
FileStream.Read(S[1], 50);
hth, glynn
Mark Machen wrote:
> I know there's an easy answer to this, so forgive me for the question. I am
> trying to read in portions of text from a file into a TMemo. Ideally I
> would do this:
>
> var
> p: PChar;
> s: String;
>
> FileStream.Read(p^, 50);
>
> //this doesn't work
> Memo1.Lines.Add(p);
>
> //I don't this this does either
> Memo1.Lines.Add(p^);
>
> Also, is there a way to do this:
>
> FileStream.Read(s, 50); //generates an error
Also just assigning a string := pchar should do the typecasting.
or
setLength(somestring, len)
FileStream(pchar(somestring), len)
--
Iman
"I was looking handsome,
she was looking like an erotic vulture" The Pixies
in article <3aca1a70$1_2@dnews>, you wrote:
> Also, is there a way to do this:
>
> FileStream.Read(s, 50); //generates an error
>
FileStream.Read(s[1], 50)
--
Regards
Ralph (TeamB)
===
var
p: PChar;
s: String;
FileStream.Read(p^, 50);
//this doesn't work
Memo1.Lines.Add(p);
//I don't this this does either
Memo1.Lines.Add(p^);
Also, is there a way to do this:
Shane
> //this doesn't work
> Memo1.Lines.Add(p);
It does.
> //I don't this this does either
> Memo1.Lines.Add(p^);
It shouldn't.
> Also, is there a way to do this:
>
> FileStream.Read(s, 50); //generates an error
SetLength(S, 50);
FileStream.Read(S[1], 50);
or
SetLength(S, 50);
FileStream.Read(PChar(S)^, 50);
--
Rudy Velthuis (TeamB)
I didn't realize that f.Read(s[1], 50) would work like that. It looks like
you are only trying to fill that one character - not the string. Thanks
again.
Eduardo
Quito-Ecuador
"Mark Machen" <ma...@producingfaith.org> wrote in message
news:3aca1a70$1_2@dnews...
> I know there's an easy answer to this, so forgive me for the question. I
am
> trying to read in portions of text from a file into a TMemo. Ideally I
> would do this:
>
> var
> p: PChar;
> s: String;
>
> FileStream.Read(p^, 50);
>
> file://this doesn't work
> Memo1.Lines.Add(p);
>
> file://I don't this this does either
> Memo1.Lines.Add(p^);
>
> Also, is there a way to do this:
>
> FileStream.Read(s, 50); file://generates an error
>
>
>
>
memo1.lines.loadfromstream(Filestream);
gotta love streams!
Father
Eduardo Gamboa <mega...@uio.satnet.net> wrote in message
news:3ad1f934_1@dnews...
> If you want to convert a PChar to String, You can use StrPas.
> var
> s: String;
> p: PChar
> ....
Use typecasting where possible: pcharvar := pChar(stringvar); or stringvar
:= String(pcharvar);
Make sure you have the memory allocated to the pChar, or use an array of
type Array[0..x] Of Char;
Eduardo Gamboa wrote in message <3ad1f934_1@dnews>...