Board index » delphi » ReportSmith Converting of Numbers to String

ReportSmith Converting of Numbers to String

Please help me!

I have a problem with converting numbers to string. The numbers
are the values the way I have stored them in my database table.
For example: 1,2,3,4,5..12, where 1  = January, 2 = February
and so on.

I my report I want to display text instead of numbers, this
will make it easier for the user to understand.

Who can I make a converting-routine that works? Is the
following a good idea?

Sub Int_to_String_Convert
  If Field$(Monthnmb) = 1 then DerivedField "January"
  If Field$(Monthnmb) = 2 then DerivedField "February"
  ...
  If Field$(Monthnmb) = 12 then DerivedField "December"
EndSub

Who can I link such a macro to an event, so that every row in
may table are being evaluated?

Please help!!

Sverre Nymo

 

Re:ReportSmith Converting of Numbers to String


In article <4aa8dq$...@dole.uninett.no> Sverre.N...@samson.slhk.no (Sverre  

Quote
Nymo) writes:
> Please help me!

> I have a problem with converting numbers to string. The numbers
> are the values the way I have stored them in my database table.
> For example: 1,2,3,4,5..12, where 1  = January, 2 = February
> and so on.

> I my report I want to display text instead of numbers, this
> will make it easier for the user to understand.

> Who can I make a converting-routine that works? Is the
> following a good idea?

> Sub Int_to_String_Convert
>   If Field$(Monthnmb) = 1 then DerivedField "January"
>   If Field$(Monthnmb) = 2 then DerivedField "February"
>   ...
>   If Field$(Monthnmb) = 12 then DerivedField "December"
> EndSub

> Who can I link such a macro to an event, so that every row in
> may table are being evaluated?

> Please help!!

> Sverre Nymo

I recommend you to create a derived field with an SQL statement.

Write this in the SQL editor of the derived field :
Decode(Monthnmb,1,'January',2,'Febuary',3,'March',...,12,'December')

With this, the derived field will always contain the appropriate value...

Hope this helps.

Richard Pineault
(r...@logibec.com)  

Re:ReportSmith Converting of Numbers to String


Quote
Sverre.N...@samson.slhk.no (Sverre Nymo) wrote:
>Please help me!

I would use this one:

Type
        Months = 1..12;

Const
        MonthNames: array[Months] of string = ('January', 'February', 'March',
                                         'April', 'May', 'June', 'July',
                                         'August', 'September', 'October',
                                         'November', 'December');

function MonthToStr(iMonth: Months): string;
begin
        Result := MonthNames[iMonth];
end;

<<compiled and tested with Delphi C/S 1.02>>

--
Clatu Verata NeckTie                              9ko D'Ch.
                                                  ---------

Other Threads