Ok, that does work. I'm confused about buffers and buffer locations
though. If passing LChar[1] as an untyped var parameter passes a
(constructed on the fly?) address pointing to the first character in
LChar, which is then used as the address to Read into by TFileStream,
shouldn't passing PChar(LChar)^ as an untyped var parameter do the same
thing? Or is the problem one of scoping, that the register or memory
location or whatever which holds the address which has been constructed
by the cast PChar(LChar) isn't persistent inside the call, so that it's
been reused by the time the Read occurs? And did that even make sense
to me, let alone anyone else? :) How can I find out what's really
going on?
Cheers,
Carl Reynolds Ph: +64-9-4154790
CJN Technologies Ltd. Fax: +64-9-4154791
[EMAIL PROTECTED] DDI: +64-9-4154795
PO Box 302-278, North Harbour, Auckland, New Zealand
12 Piermark Drive, North Harbour Estate, Auckland, NZ
Visit our website at http://www.cjntech.co.nz/
> -----Original Message-----
> From: Aaron Scott-Boddendijk [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, August 06, 1999 1:07 PM
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: Strings, PChars, and TFileStream.Read
>
> > LChar := 'X';
> > if Read(PChar(LChar)^, 1) = 0 then begin
>
> Try
> if Read(LChar[1],1)=0 then begin
>
> Since I think it's wanting a buffer location not the character at that
> location which is I think
> what is getting passed in with PChar(LChar)^
>
> > In some cases, depending on what other code I've got in unrelated
> > places, I get 0 returned - ie., the TFileStream thinks that it can't
> > read from the file or that the file is empty, which obviously should
> > never be the case. Things are complicated by the fact that the
> error
> > rarely happens, and when it does putting in a ShowMessage or a
> > breakpoint cause it to _not_ happen!
>
> Because the passed in address possibly is zero... Does the debugger
> change
> the way local variables are initialised (IE blanking memory to nil)...
>
> --
> Aaron@home
>
> ----------------------------------------------------------------------
> -----
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
application/ms-tnef