Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-12

Re: longint -> Pchar / string / ansistring

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Balogh, Karoly (Charlie/iNQ
to baron kractor: Is there a (hopefully easy) way to convert a longint variable to either Pchar / string /…

Hi,

baron kractor wrote 6 lines
Is there a (hopefully easy) way to convert a longint variable to either Pchar / string / ansistring without changing the contents of the variable? For example, longint variable containing "12345" converted to one of the string types would still print as "12345". Closest I've been able to get so far results in the converted variable being printed as some strange characters ...

Maybe i misunderstood you on IRC, you need the value of the variable or the contents of the variable?

If you want to have the numerical value as string, simply use the Str() function of the System unit.
See the docs: http://www.freepascal.org/docs-html/ref/refsu177.html

I thought you needed the contents of the variable to printed out from byte to byte. (for eg. you have a 4 byte ID number, as a longint and you wanted it as a string.).

Bye,

Charlie/iNQ .:%[ Cybernetic Hydraulic Android Responsible for ]%:. .:%[ Logical Infiltration and Exploration ]%:. .:%[ Member of TeamOS/2 Hungary ]%:. .:%[ Member of Hungarian Amiga User Group ]%:.

Reply by email

baron kractor

Is there a (hopefully easy) way to convert a longint variable to either Pchar / string / ansistring without changing the contents of the variable? For example, longint variable containing "12345" converted to one of the string types would still print as "12345". Closest I've been able to get so far results in the converted variable being printed as some strange characters ...

Reply by email