[fpc-devel] Indy IdHTTP

ABorka fpc-devel at aborka.com
Sun May 24 23:22:34 CEST 2009


"If you are only using Pascal code in the real program, this should all 
  be handled transparently for you."

I agree, so why it doesn't?
It only shows a few strange characters but not the string, as if it is 
just trying to display the pointer as a string.

As you say, the

ShowMessage('Redirected to:' + dest);

should work as is. But it does not.
UTF8 and ANSI conversion problems cannot happen here because "dest" is a 
  URL so the UTF8 and ANSI characters are the same.


Jonas Maebe wrote:
> 
> On 24 May 2009, at 04:32, ABorka wrote:
> 
>> In FPC/Lazarus:
>> procedure TForm1.IdHTTP1Redirect(Sender: TObject; var dest: String;  
>> var NumRedirect: Integer; var Handled: Boolean;  var VMethod: 
>> IdHTTPMethod);
>> begin
>>  ShowMessage('Redirected to:' + dest);
>> end;
>>
>> However, it seems that the parameter "dest" is passing a pointer to a 
>> pointer and not just a pointer to the string (displaying only some 
>> strange characters instead of the redirecting URL).
> 
> It is normal that dest is (implicitly) a pointer to a pointer. A "var" 
> parameter means that the address of some variable is passed to a 
> function, rather than only its value.
> 
> Now, an (Ansi)String is a pointer to an array of characters, with some 
> extra data before it. So if you have a "var" parameter of the type 
> (Ansi)String, you get a pointer to that "pointer to an array of 
> characters". Otherwise you would be unable to change the address stored 
> inside that pointer (you would only be able to permanently change the 
> data in the array it points to, but not make it point to a different 
> array in a way that persists after the function exits).
> 
> If you are only using Pascal code in the real program, this should all 
> be handled transparently for you.
> 
> 
> Jonas
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
> 




More information about the fpc-devel mailing list