home *** CD-ROM | disk | FTP | other *** search
- #Version 1.3
- R = [0x000000CC, 0x00008800, 0x00CC0000, "incorrect", "valide", "incomplet"]
-
- def check(S):
- s = S.Text
- if len(s) > 16 or not s.isdigit(): i = 0
- elif len(s) < 16: i = 2
- else:
- T, d = 0, 0
- for c in s:
- if d: T += int(c)
- else: T += (int(c) * 2) % 9
- d = not d
- i = T > 0 and T % 10 == 0
- res.Font.Color = R[i]
- res.Caption ="Le numΘro est %s" %R[i+3]
-
- f = CreateComponent("TForm", None)
- f.Font.Name = "Tahoma"
- f.SetProps(Position="poMainFormCenter", Width=300, Height=180, Caption="ClΘ de Luhn", BorderStyle="bsSingle", BorderIcons=["biSystemMenu"])
- cb = CreateComponent("TLabel", f)
- cb.SetProps(Parent=f, Left=20, Top=20, Width=200, Caption="Carte bancaire n░ :")
- cb.Font.Style = ["fsBold"]
- num = CreateComponent("TEdit", f)
- num.SetProps(Parent=f, Left=20, Top=40, Width=250, OnChange=check)
- res = CreateComponent("TLabel", f)
- res.SetProps(Parent=f, Left=20, Top=70, Width=200)
- res.Font.Style = ["fsBold"]
- ok = CreateComponent("TButton", f)
- ok.SetProps(Parent=f, Left=105, Top=100, Width=90, Height=25, Caption="OK", Default=1, Cancel=1, ModalResult=1)
- f.ShowModal()