[fpc-pascal] How to know the string type of a variable?
Marcos Douglas
md at delfire.net
Mon Dec 30 18:02:59 CET 2013
On Mon, Dec 30, 2013 at 11:47 AM, Michael Van Canneyt
<michael at freepascal.org> wrote:
>
>
>>> No. You make a wrong assumption.
>>>
>>> TypeInfo will return the DECLARED type of S.
>>>
>>> Not the type that was actually passed when calling the routine:
>>> That has been converted to the declared type of S by the compiler even
>>> before the routine ShowType is called.
>>
>>
>> You're right.
>> Well is there another way to do I showed before?
>> I want to create a record/object type to receive a "string" but I need
>> to know which string type was before.
>
>
> There is no way.
>
>
>>
>> If I change the code (see below) to use Pointer type it works but I
>> think this is won't help me.
>
>
> No, it will not help you.
Yes... Well, I was trying the easy way but not possible. :-)
> One thing you can do is use overloading:
>
> [code]
>
> The compiler will choose the correct overloaded version, and you will know
> which one she picked.
>
> But it would help to know what exactly you want to achieve.
I had some ideas looking at your code. Thank you.
Regards,
Marcos Douglas
More information about the fpc-pascal
mailing list