0
votes

Is there a built in function that converts integers to strings in Free Pascal, as in returns a string object of the integer input? I've scowered the Google and the docs for 2 hours now and have found nothing but false hope and disappointment. Using Lazarus 1.4.4 on Windows 10.

Also, why is pascal so complex/aggravating? There are tons of versions, IDEs, application support vs not application support, and the docs are mediocre at best (at least for Free Pascal, although Delphi's doesn't look too good at a glance either). It's so all over the place, it's like a giant tangled pair of earbuds.

Thank you!

2
There are two main ways to convert Integer to decimal string representation: built in procedure Str and function IntToStr from SysUtils unit. There are also several functions in the StrUtils unit: IntToBin, IntToRoman, Dec2Numb... - Abelisto
You spent two hours trying to find documentation to convert an integer to string in Pascal? What exactly did you try to Google? I just Google'd "pascal integer to string" and the very first two hits were the functions that have been given as answers to your first question. Your second question is unrelated and a matter of opinion. - lurker

2 Answers

7
votes

As said there is inttostr, which is Delphi's way of doing it. The classic Pascal solution is str. Both work in FPC and Delphi, though inttostr might require a object oriented (Delphi alike) mode in FPC.

A string is not an object btw, but a first class native type.

Basically Lazarus/FPC and Delphi are the only really active native Pascal products. Typically the two last versions of Lazarus are in active use (1.4.4 and rc's for the upcoming 1.6). Some older versions are still visible on specially Debian and derivatives(because these versions are default in that Debian Stable).

For Delphi of course there are more versions in active use because a new version must be bought (in the Eur/$ 500-600 range).

The FPC docs are quite good, there are several thousands of pages (and the doxygen like tool is set not to generate pages without content). Lazarus has a different setting and generates also pages with skeleton info only.

For a totally self supported project (no major, continuous corporate sponsors, no dedicated FTEs, either directly it the project (like Firefox) or at sponsors (like e.g. LLVM) ) this is quite good.

4
votes

I believe IntToStr() converts int to string in Free Pascal.