Re: [fpc-pascal] EnumToString

2011-11-01 Thread Florian Klämpfl
Am 01.11.2011 10:30, schrieb Juha Manninen: > WriteStr (S, N); > > > Thanks guys! > WriteStr() was the function I was looking for. > I found some places in Lazarus code where it is used but not > many. Martin's debugger code has some. > I think many lookup string arrays in Lazarus code could

Re: [fpc-pascal] EnumToString

2011-11-01 Thread Jonas Maebe
On 01 Nov 2011, at 10:30, Juha Manninen wrote: >> WriteStr (S, N); >> > > Thanks guys! > WriteStr() was the function I was looking for. You can also use the plain str() procedure. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org h

Re: [fpc-pascal] EnumToString

2011-11-01 Thread Vincent Snijders
2011/11/1 Juha Manninen : >>  WriteStr (S, N); > > Thanks guys! > WriteStr() was the function I was looking for. > I found some places in Lazarus code where it is used but not many. Martin's > debugger code has some. > I think many lookup string arrays in Lazarus code could be replaces > with Write

Re: [fpc-pascal] EnumToString

2011-11-01 Thread Juha Manninen
> > WriteStr (S, N); > Thanks guys! WriteStr() was the function I was looking for. I found some places in Lazarus code where it is used but not many. Martin's debugger code has some. I think many lookup string arrays in Lazarus code could be replaces with WriteStr. It would reduce code size and i

Re: [fpc-pascal] EnumToString

2011-11-01 Thread Thomas Young
Hi, This is code I wrote for converting 1, 2 or 3 digit numbers to string. function NumtoString(N:integer):string; var c1, c2, c3: char; begin if (N<10) then NumtoString := chr(N+48) else if (N > 9) an

Re: [fpc-pascal] EnumToString

2011-11-01 Thread Tomas Hajny
On Tue, November 1, 2011 08:41, Juha Manninen wrote: Hi, > I remember there is a way to get a string representation of an enumerated > type directly without using a lookup string array, but I forgot the > syntax. > Lazarus uses only lookup arrays, maybe because the other syntax is new. > > How i

Re: [fpc-pascal] EnumToString

2011-11-01 Thread Yann Bat
You can directly write enums with Write or WriteLn and convert enums to strings with WriteStr. program EnumStr; {$mode objfpc}{$H+} type TColor = (cRed, cGreen, cBlue, cYellow); function ColorToStr(C: TColor) : String; begin WriteStr(Result, C); end; var Color : TColor; begin for Color

Re: [fpc-pascal] EnumToString

2011-11-01 Thread Felipe Monteiro de Carvalho
One option is RTTI: http://wiki.lazarus.freepascal.org/Runtime_Type_Information_(RTTI)#Converting_a_enumerated_type_to_a_string -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailm