Autor Beitrag
Apo95
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 129

Win2000, WinXP, WinServer 2003 Standard x86, Win7x64
Delphi 6 Enterprise, D2009 Architect, RAD Studio XE6 Architect
BeitragVerfasst: Di 06.11.12 23:48 
Liebe Community,

ich möchte ein Werkzeug schreiben, was Seriennummern auf Gültigkeit prüft.

Gedacht habe ich mir das so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
            if (Edit3.Text = '75475-09408-24881-53371-07741'or (Edit3.Text = '48090-48938-70401-95127-28075'or
            (Edit3.text = '76315-87873-32685-36470-64126'or (Edit3.Text = '17032-73316-42406-74026-72489'or (Edit3.Text = '33660-37236-51521-33065-22426'or
            (Edit3.Text = '49856-16314-32028-92560-28316'or (Edit3.Text = '49424-19867-07733-35950-90691'or (Edit3.Text = '36546-35187-99492-42434-19190'or
            (Edit3.Text = '19762-84982-57230-85446-40507'or (Edit3.Text = '48804-72071-93219-27780-02817'or (Edit3.Text = '15755-65551-23622-84769-82797'or
            (Edit3.Text = '45922-11513-41417-25355-84374'or (Edit3.Text = '08896-48651-14984-14537-49135'or (Edit3.Text = '62642-57594-59441-13193-15085'or
            (Edit3.Text = '98485-57291-89948-35326-49359'or (Edit3.Text = '04175-04769-69742-30189-14078'or (Edit3.Text = '28848-72965-68434-40166-69027'or
            (Edit3.Text = '63258-17404-50100-33977-72736'or (Edit3.Text = '89258-23953-71251-80432-28597'or (Edit3.Text = '72744-95349-84944-17428-33814')
            then
          Application.MessageBox('Überprüfung erfolgreich abgeschlossen.','GoetheQuiz 2010 Sicherheit',mb_ICONINFORMATION or mb_OK);

            if (Edit3.Text <> '75475-09408-24881-53371-07741'or (Edit3.Text <> '48090-48938-70401-95127-28075'or
            (Edit3.text <> '76315-87873-32685-36470-64126'or (Edit3.Text <> '17032-73316-42406-74026-72489'or (Edit3.Text <> '33660-37236-51521-33065-22426'or
            (Edit3.Text <> '49856-16314-32028-92560-28316'or (Edit3.Text <> '49424-19867-07733-35950-90691'or (Edit3.Text <> '36546-35187-99492-42434-19190'or
            (Edit3.Text <> '19762-84982-57230-85446-40507'or (Edit3.Text <> '48804-72071-93219-27780-02817'or (Edit3.Text <> '15755-65551-23622-84769-82797'or
            (Edit3.Text <> '45922-11513-41417-25355-84374'or (Edit3.Text <> '08896-48651-14984-14537-49135'or (Edit3.Text <> '62642-57594-59441-13193-15085'or
            (Edit3.Text <> '98485-57291-89948-35326-49359'or (Edit3.Text <> '04175-04769-69742-30189-14078'or (Edit3.Text <> '28848-72965-68434-40166-69027'or
            (Edit3.Text <> '63258-17404-50100-33977-72736'or (Edit3.Text <> '89258-23953-71251-80432-28597'or (Edit3.Text <> '72744-95349-84944-17428-33814'then
          Application.MessageBox('Ihre Angabe ist unvollständig oder fehlerhaft.','GoetheQuiz 2010 Sicherheit',mb_ICONSTOP or mb_OK);

end;


Leider wird, wenn die Seriennummer richtig ist, sowihl das negative, als auch das positive Dialogfeld eingeblendet. Ich weiß aber nicht warum.

Überprüft werden müssen 20 Seriennummern.

Besten Dank im Voraus! :-)

_________________
Lette-Verein MIA
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Di 06.11.12 23:50 
Moin.

Heißer tipp:

Versuchs mal mit

ausblenden Delphi-Quelltext
1:
if (seriennummer=blablabla ... ... ) then ... else Showmessage('Falsch');					


BTW: Strings kann man mit dem editor aus der exe-datei auslesen.

Für diesen Beitrag haben gedankt: Apo95
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Di 06.11.12 23:54 
Man könnte die Prüfung in eine eigene Funktion auslagern, die intern eine StringArray-Konstante oder eine Stringliste verwendet (Hinweis von FinnO gilt dort auch weiterhin). Das würde Logik und Darstellung trennen und auch sehr viel kürzer ausfallen.
Apo95 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 129

Win2000, WinXP, WinServer 2003 Standard x86, Win7x64
Delphi 6 Enterprise, D2009 Architect, RAD Studio XE6 Architect
BeitragVerfasst: Mi 07.11.12 00:05 
Vielen Dank! Problem erfolgreich gelöst!

:-D

_________________
Lette-Verein MIA
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Mi 07.11.12 00:08 
Die Lösung würde mich (und evtl. auch andere) interessieren.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 07.11.12 08:47 
Obwohl das mit dem else natürlich besser ist, noch eine Ergänzung:

Die Negation von
ausblenden Quelltext
1:
(a=b) or (c=d)					
ist
ausblenden Quelltext
1:
2:
NOT ((a=b) or (c=d))
= (a<>b) and (c<>d)

_________________
We are, we were and will not be.

Für diesen Beitrag haben gedankt: Apo95
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Mi 07.11.12 13:45 
Wenn er wie es sinnvoll wäre über Listen oder Arrays läuft fällt die Verkettung eh raus ...

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS