ce n'est pas une grande application ..bien sure !, mais un petit exemple particulier qui peut etre utile dans les traitements de textes (pas de calcul !!!)
Source / Exemple :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
function Chif (X: Byte) : String; { NOM DES CHIFFRES }
begin
case X of
0: Chif := 'zéro';
1: Chif := 'un';
2: Chif := 'deux';
3: Chif := 'trois';
4: Chif := 'quatre';
5: Chif := 'cinq';
6: Chif := 'six';
7: Chif := 'sept';
8: Chif := 'huit';
9: Chif := 'neuf';
10: Chif := 'dix';
11: Chif := 'onze';
12: Chif := 'douze';
13: Chif := 'treize';
14: Chif := 'quatorze';
15: Chif := 'quinze';
16: Chif := 'seize';
17: Chif := 'dix-sept';
18: Chif := 'dix-huit';
19: Chif := 'dix-neuf';
20: Chif := 'vingt';
21: Chif := 'vingt un';
22: Chif := 'vingt deux';
23: Chif := 'vingt trois';
24: Chif := 'vingt quatre';
25: Chif := 'vingt cinq';
26: Chif := 'vingt six';
27: Chif := 'vingt sept';
28: Chif := 'vingt huit';
29: Chif := 'vingt neuf';
30: Chif := 'trente';
31: Chif := 'trente un';
32: Chif := 'trente deux';
33: Chif := 'trente trois';
34: Chif := 'trente quatre';
35: Chif := 'trente cinq';
36: Chif := 'trente six';
37: Chif := 'trente sept';
38: Chif := 'trente huit';
39: Chif := 'trente neuf';
40: Chif := 'quarante';
41: Chif := 'quarante un';
42: Chif := 'quarante deux';
43: Chif := 'quarante trois';
44: Chif := 'quarante quatre';
45: Chif := 'quarante cinq';
46: Chif := 'quarante six';
47: Chif := 'quarante sept';
48: Chif := 'quarante huit';
49: Chif := 'quarante neuf';
50: Chif := 'cinquante';
51: Chif := 'cinquante un';
52: Chif := 'cinquante deux';
53: Chif := 'cinquante trois';
54: Chif := 'cinquante quatre';
55: Chif := 'cinquante cinq';
56: Chif := 'cinquante six';
57: Chif := 'cinquante sept';
58: Chif := 'cinquante huit';
59: Chif := 'cinquante neuf';
60: Chif := 'soixante';
61: Chif := 'soixante un';
62: Chif := 'soixante deux';
63: Chif := 'soixante trois';
64: Chif := 'soixante quatre';
65: Chif := 'soixante cinq';
66: Chif := 'soixante six';
67: Chif := 'soixante sept';
68: Chif := 'soixante huit';
69: Chif := 'soixante neuf';
70: Chif := 'soixante-dix';
71: Chif := 'soixante-onze';
72: Chif := 'soixante-douze';
73: Chif := 'soixante-treize';
74: Chif := 'soixante-quatorze';
75: Chif := 'soixante-quinze';
76: Chif := 'soixante-seize';
77: Chif := 'soixante-dix-sept';
78: Chif := 'soixante-dix-huit';
79: Chif := 'soixante-dix-neuf';
80: Chif := 'quatre-vingt';
81: Chif := 'quatre-vingt un';
82: Chif := 'quatre-vingt deux';
83: Chif := 'quatre-vingt trois';
84: Chif := 'quatre-vingt quatre';
85: Chif := 'quatre-vingt cinq';
86: Chif := 'quatre-vingt six';
87: Chif := 'quatre-vingt sept';
88: Chif := 'quatre-vingt huit';
89: Chif := 'quatre-vingt neuf';
90: Chif := 'quatre-vingt-dix';
91: Chif := 'quatre-vingt-onze';
92: Chif := 'quatre-vingt-douze';
93: Chif := 'quatre-vingt-treize';
94: Chif := 'quatre-vingt-quatorze';
95: Chif := 'quatre-vingt-quinze';
96: Chif := 'quatre-vingt-seize';
97: Chif := 'quatre-vingt-dix-sept';
98: Chif := 'quatre-vingt-dix-huit';
99: Chif := 'quatre-vingt-dix-neuf';
100:chif := ' cent ';
end;
end;
function Nomp (X: Byte) : String; {NOM DES PUISSANCES}
begin
case x of
1: nomp:=' cent ';
2:nomp:=' mille ';
3:nomp:=' million ';
4:nomp:=' milliard ';
end;
end;
function nbcar(N: LongInt) : String;{DEBUT DU TRAITEMENT DE LA FONCTION (N) }
var
s1,s2,txt,TmpTxt: String;
x1,x2: longint;
begin
Str (N, TmpTxt);
txt := '';
{DIZAINE}
if length(tmptxt)<3 then
begin
x1:=strtoint(tmptxt);
txt:=txt+chif(x1);
nbcar:=txt;
end;
if length(tmptxt)=3 then
begin
x2:=(strtoint(tmptxt[2]+tmptxt[3]));
if x2>0 then
s2:=chif(x2)
else
s2:='' ;
x1:=strtoint(tmptxt[1]);
if x1<>1 then
s1:=chif(x1)+nomp(1)
else
s1:=nomp(1);
txt:=s1+s2;
nbcar:=txt
end;
end;{fin}{FIN DE LA FONCTION DE TRAITEMENT }
procedure Affiche(x: longint;var st:string);{AFFICHAGE DU RESULTAT APRES TRAITEMENT}
begin
st:=(NbCar(x));
end;
var
dec,txt,tmptxt,s1,s2,s3:string;
x1,x2,x3:Longint;
centi:integer;
begin { Affiche un nombres entier }
if pos('.',edit1.text) = 0 then
begin
tmptxt:=(edit1.text);
centi:=0;
affiche(centi,dec);
end
else
begin { Affiche un nombres réel }
tmptxt:=copy(edit1.text,0,pos('.',edit1.text)-1);
dec:=copy(edit1.text,pos('.',edit1.text)+1,length(edit1.text));
centi:=strtoint(dec);
affiche(centi,dec);
end;
if length(tmptxt)<=3 then
begin
x1:=strtoint(tmptxt);
affiche(x1,s1);
txt:=txt+s1+' Dinars Algeriens et '+dec+' Centime.'
end
else
case length(tmptxt) of
4:begin
txt:='';
s1:=tmptxt[1];
s2:=copy(tmptxt,2,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
affiche(x1,s1);
affiche(x2,s2);
if x1<>1 then
begin
affiche(x1,s1);
affiche(x2,s2);
if x2=0 then
s2:='';
txt:=txt+s1+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
end
else
begin
if x2=0 then
s2:='';
txt:=txt+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
end;
end;
5:begin
txt:='';
s1:=copy(tmptxt,1,2);
s2:=copy(tmptxt,3,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
affiche(x1,s1);
affiche(x2,s2);
if x2=0 then
s2:='';
txt:=txt+s1+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
end;
6:begin
txt:='';
s1:=copy(tmptxt,1,3);
s2:=copy(tmptxt,4,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
affiche(x1,s1);
affiche(x2,s2);
if x2=0 then
s2:='';
txt:=txt+s1+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
end;
7:begin
txt:='';
s1:=tmptxt[1];
s2:=copy(tmptxt,2,3);
s3:=copy(tmptxt,5,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
x3:=strtoint(s3);
affiche(x1,s1);
affiche(x2,s2);
affiche(x3,s3);
txt:=txt+s1+nomp(3)+s2+nomp(2)+s3+' Dinars Algeriens et '+dec+' Centime.'
end;
8:begin
txt:='';
s1:=copy(tmptxt,1,2);
s2:=copy(tmptxt,3,3);
s3:=copy(tmptxt,6,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
x3:=strtoint(s3);
affiche(x1,s1);
affiche(x2,s2);
affiche(x3,s3);
if x2=0 then
s2:='';
if x3=0 then
s3:='';
txt:=txt+s1+nomp(2)+s2+nomp(1)+s3+' Dinars Algeriens et '+dec+' Centime.'
end;
9:begin
txt:='';
s1:=copy(tmptxt,1,3);
s2:=copy(tmptxt,4,3);
s3:=copy(tmptxt,7,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
x3:=strtoint(s3);
affiche(x1,s1);
affiche(x2,s2);
affiche(x3,s3);
if x2=0 then
s2:='';
if x3=0 then
s3:='';
txt:=txt+s1+nomp(3)+s2+nomp(2)+s3+' Dinars Algeriens et '+dec+' Centime.'
end;
end;
edit2.text:='Arrete la presente facture à la somme de :'+txt;
end;
end.
Conclusion :
Ceci n'est que le code source de mon petit exemple pour avoir une petite idee de ce qu'on peut faire avec les instructions de traitement de texte, je m'excuse pour le fichier zip qui seras joint d'ici quelques temp avec tout les details.
Merci pour votre comprehension
sagit_terre@inbox.com
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.