Re:Dynamic length of PChar's, Pos() searching inside PChar
On Sun, 01 Feb 1998 16:20:24 GMT, in comp.lang.pascal.delphi.misc
Quote
PleaseSeeAddr...@TheBottom.OfMyMessage.co.uk (Matthew) wrote:
>Dynamic length of PChar's, Pos() searching inside PChar
>Procedure Speedbutton1.click(Sender: TOjbect)
>var MyPCar: PChar
>begin
> PChar:='hi there its a test of 36 characters'#0;
> speedbutton1.caption:='Length is:'+ inttostr(sizeof(PChar));
>end;
I assume you meant to type "MyPCar" in the last two uses of PChar.
Quote
>The results shows a length of 4!. What is this? I wish to know how
>long (how many characters) the text is that is stored in the PChar.
The reason is that MyPCar is a pointer, and in Delphi, pointers are 4
bytes long. You want to find out how long is the string that it
points to. Use StrLen for that.
Quote
>Also, I see no Pos() function for PChar's in 16-bit. I wish to search
>and replace a substring within a PChar.
I think StrPos does what you want.
Duncan Murdoch
Quote
P.S.: You wrote:
>N.B.: To email me, please send your message to this email address:
> ...
>That is my correct address. I do not enter my address in the automatic
>header of the newsgroup. This helps avoid junk-email from
>address-gathering robots.
Actually, all that it does is to inconvenience people trying to
respond to you. The robots can gather your address from the body just
as well as from the headers. If you want to try to foil them, you
should get a new email address (the one you used has already been
gathered), and then never include it anywhere in any of your messages.