NumWords Version 4.3

Express a number in words in English, Deutsch, Français, Español, Italiano, & Turkish.
For programs that print cheques etc.

Italiano and Français money routines are untested
Español has no money support at the moment

Copyleft Andy Preston, Apollo Developments, 1999.

Licensing

This is Free Software, released under the LGPL (Copy Enclosed).
OSI Certified Open Source Software.

Platforms

Delphi 2 - 5; Quick Reports 2, and 3 (optional)

Installation

  1. If you are upgrading from a version earlier than 3.1, DELETE qr_cusdbt.pas from your library directory.

  2. If you are upgrading from a version earlier than 4.0, DELETE dollar.res, and pound.res from your library directory.

  3. Copy numwords.pas, numw.pas, numw_deu.pas, num_eng.pas, num_esp.pas, num_fra.pas, numw_ita.pas, & num_trk.pas, to your library directory.

  4. If you don't want Quick Reports functionality you can just delete QRCusDBT.pas and QRDBCash.pas

For Quick Reports Functionality:

  1. Also copy QRCusDBT.pas and QRDBCash.pas to your library directory.

  2. Install components from QRDBCash.pas in the normal way

Use (Without Quick Reports)

See Demo.dpr, Demo1.dfm, & Demo1.pas (included in this archive) for more information.

  1. Add NumWords to the Uses clause of the Implementation section of your application unit.

  2. You can use the various members of the object InWords : TNumWords as illustrated below

Function HasGender (Gender : TGender) : Boolean

This fuction allows you to find out if a given language uses a gender

TGender = (genMale, genFemale, genNeuter) is defined in NumW.pas

e.g. English has no gender; Deutsch has Masculine, Feminine, & Neuter; Français has Masculine & Feminine.

Example

Uses
  NumWords, NumW;

Procedure CheckGenderList;
Begin
  GenderList.Items.Clear;
  If InWords.HasGender (genMale) Then GenderList.Items.Add ('Male');
  If InWords.HasGender (genFemale) Then GenderList.Items.Add ('Female');
  If InWords.HasGender (genNeuter) Then GenderList.Items.Add ('Neuter');
End;

Procedure SelectLocale (CountryCode, LanguageCode : Integer)

Your local language and currency information is automatically obtained from Windows when your program starts, you can use this procedure to override the defaults and use a foreign language, or currency

Example

Uses
  Windows, NumWords;

Procedure TForm1.FormShow (Sender : TObject);
Begin
  InWords.SelectLocale (CTRY_GERMANY, LANG_GERMAN);
End;

Function Number (TheNumber : Integer; Gender : TGender) : String

TGender = (genMale, genFemale, genNeuter) is defined in NumW.pas

This function returns a String containing the value passed in TheNumber in words

If you want to select the gender of the string returned pass a value in Gender if you are not worried about gender, use genNeuter

If the language in use does not support gender this parameter is ignored

Example

Uses
  NumWords, NumW;

Procedure Convert (ANum : Integer);
Var
  AString : String;
Begin
  AString := InWords.Number (ANum, genFemale);
  .
  .
  .
  AString := InWords.Number (StrToInt (NumBox.Text), genNeuter);
  .
  .
  .
End;

Function IMoney (Major, Minor : Integer; EuroMode : Boolean) : String

Convert a sum of money into words: Dollars are passed in Major, Cents are passed in Minor.

The EuroMode parameter is for European countries who are currently operating both their national currencies and the new Pan-EEC 'Euro' / 'Cent' currency. If this flag is False (noEuro) then the value will be printed using the local currency. If this flag is True (useEuro) then the value will be printed using the 'Euro' and 'Cent'.

For non-European languages this parameter is ignored

Example

Uses
  NumWords;
  
Procedure TRepForm.QRLabel1Print (Sender : TObject; Var Value : String);
Begin
  Value:=InWords.IMoney (Trunc(DataModule1.Table2.FieldByName ('Pounds').AsFloat
),
                         Trunc(DataModule1.Table2.FieldByName ('Pence').AsFloat)
,
                         useEuro
                        );
End;
   
Procedure TRepForm.QRLabel2Print (Sender : TObject; Var Value : String);
Begin
  Value:=InWords.IMoney (Trunc(DataModule1.Table2.FieldByName ('Pounds').AsFloat
),
                         Trunc(DataModule1.Table2.FieldByName ('Pence').AsFloat)
,
                         noEuro
                        );
End;

Function EMoney (TheAmount : Extended; EuroMode : Boolean) : String

The same as the previous function except that the value is passed as an Extended value, with Dollars in the integer part, and Cents in the remainder.

Example

Uses
  NumWords;
  
Procedure TRepForm.QRLabel1Print (Sender : TObject; Var Value : String);
Begin
  Value:=InWords.EMoney (DataModule1.Table2.FieldByName ('Pounds').AsFloat, useE
uro);
End;
   
Procedure TRepForm.QRLabel2Print (Sender : TObject; Var Value : String);
Begin
  Value:=InWords.EMoney (DataModule1.Table2.FieldByName ('Pounds').AsFloat, noEu
ro);
End;

Use (With Quick Reports)

See QRDemo.dpr, QRDemo1.dfm, QRDemo1.pas, QRDemo2.dfm, And QRDemo2.pas (included in this archive) for more information.

  1. After installation, you will have a new component on the Samples tab: TQRDBMoneyWords

  2. Use TQRDBMoneyWords exactly the same as TQRDBText (any numeric fields will be displayed as money, and in words.)

Example form definition

   object QRDBMoneyWords : TQRDBMoneyWords
     DataSet = DataModule1.Table3
     DataField = 'Amount'
     Gender = genNeuter
     EuroMode = True
     Alignment = taLeftJustify
     AutoSize = True
     AutoStretch = False
     WordWrap = True
   end

Additional Properties

Gender is of type TGender (See Function Number (TheNumber : Integer; Gender : TGender) : String above). If the field you are trying to print is an integer, this property controls the gender that it will be printed in.

EuroMode a Boolean flag. If it is True and the selected language is in use in the EEC, the value will be printed in Euros and Cents. If it is False or the selected language is not in use in the EEC, the value will be printed in the normal currency.

See Function IMoney (Major, Minor : Integer; EuroMode : Boolean) : String above for more details.

Missing Functionality

The following parts of NumWords are currently 'missing'.

Most of these issues can be resolved with a quick e-mail conversation. If you need this functionality, you will also be able to give me the information I need to implement it.

History

Testing

If you've tested it with Delphi 3, 4, or 5; or C++ Builder, e-mail me (Andy Preston) and let me know. Then I can update this.

If you've got any fab-and-groovy modifications or just want to let me know you love NumWords, I'd also be glad to hear from you.


OSI Certified is a certification mark of the Open Source Initiative. Borland Delphi, and C++ Builder are trade marks of Inprise Corp. Quick Reports is a trade mark of QU-Soft ASD. Windows is a trade mark of Microsoft Corp.


This page has been checked by Weblint, Version 1.020