/* Berechnung von den Clubmitgliednummern auf dem Pofo */ /* (R) Michael Schr”der 1995 */ /*Includes .. */ #include #include #include #include #include #include #include #include #include #include #include #include "pglibpgl.h" /* defines ... */ #define breite 40; #define hoehe 8; #define MAXFILES 50; #define warten for(j = 0; j < 30000; j++); /* definieren der Tasten */ #define UARROW 0x48 #define DARROW 0x50 #define LARROW 0x4b #define RARROW 0x4d #define BS 0x0e #define DEL 0x53 #define RET 13 #define ESC 27 #define SPACE 32 #define TAB 0x09 /* Typen deklaration */ /* Boolean Type einfόhren */ typedef enum { FALSE=0, TRUE=1 }boolean; /* Prototypen */ void PlotSpiral(void); void main(void); void neue(void); void pruefen(void); void info(void); boolean berechnen(char plz[5], char name[30], char mnr[10]); boolean berechnen_plz(char plz[5], char name[30], char mnr[10]); boolean berechnen_name(char plz[5], char name[30], char mnr[10]); boolean vorspann(void); int checkit(char zeichen); /* Programmcode*/ void main(void) { char c=0; if(!vorspann()) { clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΝΝΝΝΝΝΝΝΝΉ PC-Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ"); gotoxy(1,3);printf(" Mitglieds Nummern Berechnung"); gotoxy(1,4);printf(" fr "); gotoxy(1,5);printf(" den Portfolio Club Deutschland "); gotoxy(1,6);printf(" von Michael Schr”der in 'C'"); gotoxy(1,7);printf(" vom 21.11.1995"); getch(); }; while(c!=27) { /* Menu auf den Schirm und auf den Benutzerdruck warten */ clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΝΝΉ Menu ΜΝΉ Ver.1.00 ΜΝΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ"); gotoxy(8,3);printf("(N)eue Nummer errechnen."); gotoxy(8,4);printf("(P)rfen einer Nummer..."); gotoxy(8,5);printf("(I)nfo vom Programm....."); gotoxy(8,7);printf("(ESC) MNB beenden......."); c=0; c=getch(); switch(c) { case ESC: clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΝΝΉ Menu ΜΝΉ Ver.1.00 ΜΝΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ"); gotoxy(6,4);printf("Wollen Sie MNB beenden ?(J/N)"); c=0; c=getch(); if((c=='J')||(c=='j')) { if(!vorspann()) { clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΝΝΝΝΝΝΝΝΝΉ PC-Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ"); gotoxy(1,3);printf(" Mitglieds Nummern Berechnung"); gotoxy(1,4);printf(" fr "); gotoxy(1,5);printf(" den Portfolio Club Deutschland "); gotoxy(1,6);printf(" von Michael Schr”der in 'C'"); gotoxy(1,7);printf(" vom 21.11.1995"); getch(); clrscr(); c=27; } else { /* Cursor an */ asm{ mov ah,1111b mov al, 1 mov bl, 1 int 61h }; clrscr(); c=27; }; }; break; case 'N': case 'n': neue(); break; case 'P': case 'p': pruefen(); break; case 'I': case 'i': info(); break; }; }; }; void neue(void) /* Menu zur Berechnung einer neuen Nummer*/ { char name[30], plz[5], mnr[10]; /* Menu auf den Schirm und auf den Benutzerdruck warten */ clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΝΝΉ Neue ΜΝΝΉ Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ"); while(TRUE) { gotoxy(1,3);printf(" Bitte Postleitzahl eingeben:"); gotoxy(1,4);printf(" -----"); gotoxy(30,3);gets(plz); if(strlen(plz)<5) { gotoxy(1,6);printf(" Postleitzahl bitte 5-Stellig eingeben!"); getch(); gotoxy(1,6);printf(" "); gotoxy(29,3);printf(" "); } else break; }; clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΝΝΉ Neue ΜΝΝΉ Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ"); gotoxy(1,3);printf(" Bitte Nachnamen eingeben:"); gotoxy(1,4);printf(" -------------"); gotoxy(27,3);gets(name); if(berechnen(plz, name, mnr)) { clrscr(); gotoxy(1,1);printf("ΝΉ MNB §ΜΝΝΝΝΝΉ Neue ΜΝΝΉ Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ weiter mit Space Ν"); gotoxy(1,3);printf(" Die neue Mitgliedsnummer lautet:"); gotoxy(1,6);printf(" ----------"); gotoxy(1,5);printf(" * %s *",mnr); getch(); } else { clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΝΝΉ Neue ΜΝΝΉ Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ weiter mit Space Ν"); gotoxy(1,4);printf("Es wurden ungltige Zeichen eingegeben!"); gotoxy(1,6);printf(" Bitte noch einmal Berechnen und auf "); gotoxy(1,7);printf(" die Eingaben achten!"); getch(); } }; void pruefen(void) /* Prfen einer Nummer und ermittelt der restlichen Daten*/ { char name[30], plz[5], mnr[10]; boolean back=TRUE; /* Menu auf den Schirm und auf den Benutzerdruck warten */ clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΉ Prfen ΜΝΝΉ Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ Taste Ν"); gotoxy(1,3);printf("Bitte in dem folgenden Menu mindestens "); gotoxy(1,5);printf(" zwei Eingabefelder ausfllen !"); getch(); while(back) { clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΉ Prfen ΜΝΝΉ Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ"); gotoxy(1,2);printf("Mitgliedsnummer: "); gotoxy(1,3);printf(" ----------"); gotoxy(1,4);printf("Nachnamen: "); gotoxy(1,5);printf(" ----------------"); gotoxy(1,6);printf("Postleitzahl: "); gotoxy(1,7);printf(" -----"); gotoxy(17,2);gets(mnr); gotoxy(11,4);gets(name); gotoxy(14,6);gets(plz); if((strlen(mnr)!=0)&&(strlen(name)!=0)&&!(strlen(plz)!=0)) { back=berechnen_plz(plz, name, mnr); if(back) { gotoxy(14,6);printf("%s",plz); back=FALSE; }; }; if((strlen(mnr)!=0)&&!(strlen(name)!=0)&&(strlen(plz)!=0)) { back=berechnen_name(plz, name, mnr); if(back) { gotoxy(11,4);printf("%s",name); back=FALSE; }; }; if(!(strlen(mnr)!=0)&&(strlen(name)!=0)&&(strlen(plz)!=0)) { back=berechnen(plz, name, mnr); if(back) { gotoxy(17,2);printf("%s",mnr); back=FALSE; }; }; }; gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ Taste Ν"); getch(); }; void info(void) { clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΝΝΉ Info ΜΝΝΉ Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ weiter mit Space"); gotoxy(1,2);printf("Dieses Programm wurde geschrieben von "); gotoxy(1,3);printf(" Michael Schr”der"); gotoxy(1,4);printf(" Poststr.16b, 67316 Carlsberg"); gotoxy(1,5);printf(" Die Nutzung ist ausschlieαlich dem"); gotoxy(1,6);printf("Vorstand des Portfolio Clubs Deutschland"); gotoxy(1,7);printf(" gestattet."); getch(); clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΝΝΉ Info ΜΝΝΉ Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ weiter mit Space"); gotoxy(1,2);printf("MNB berechnet die Mitgliedsnummer eines"); gotoxy(1,3);printf("Mitglieds aus mindestens zwei Angaben:"); gotoxy(1,4);printf(" Postleitzahl und Nachnamen. "); gotoxy(1,5);printf("Ebenso werden beim Zurckrechnen ent-"); gotoxy(1,6);printf("weder Postleitzahl und Mitgliedsnummer"); gotoxy(1,7);printf("oder Nachname und Mitgliedsnummer -->"); getch(); clrscr(); gotoxy(1,1);printf("ΝΉ MNB § ΜΝΝΝΝΝΉ Info ΜΝΝΉ Ver.1.00 ΜΝΝ"); gotoxy(1,8);printf("ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ weiter mit Space"); gotoxy(1,2);printf("ben”tigt. "); gotoxy(1,3);printf("Neue Nummern werden mit dem Menupunkt N"); gotoxy(1,4);printf("berechnet. (P)rfen ist fr den Fall "); gotoxy(1,5);printf("gedacht, wenn ein Mitglied eine Nummer"); gotoxy(1,6);printf("angibt und man wissen will ob sie nicht"); gotoxy(1,7);printf("erfunden wurde. "); getch(); }; boolean berechnen (char plz[5], char name[30], char mnr[10]) /* Berechnei die eigentliche Nummer */ { int i,j=0,p,n,erg; for(i=0;i<5; i++) { /* Zeichen in Int umwandelt */ p=checkit(plz[i]); /* Bereich prfen */ if((p<0)||(p>9)) return(FALSE); /* wenn korrekt dann Zeichen aus Name holen */ n=checkit(name[i]); /* Bereich prfen */ if(n==99) if(i<=5) n=0; else return(FALSE); /* Wenn okay berechen */ erg=p+n; /* in MNR eintragen */ if(erg<=9) { mnr[j]='0'; j++; sprintf(mnr+j,"%d",erg); j++; } /* fllt mit Nuller auf, wenn Zahl nur einstellig */ else { sprintf(mnr+j,"%d",erg); j+=2; } }; if(i<5) mnr[10]=0; return(TRUE); }; void PlotSpiral(void) /* nur fr den Portfolio zu Graphig ausgabe */ { int x, y; int x1 = 0; int x2 = 239; int y1 = 0; int y2 = 63; /* plot in quiet mode */ while (y1 < 32) { for (x = x1; x <= x2; x++) PG_QPlot(x, y1, BLACK); for (y = y1; y <= y2; y++) PG_QPlot(x2, y, BLACK); for (x = x2; x >= x1; x--) PG_QPlot(x, y2, BLACK); for (y = y2; y >= y1; y--) PG_QPlot(x1, y, BLACK); x2 -= 2; y2 -= 2; y1 += 2; x1 += 2; } /* now show it */ PG_Refresh(); /* Plot in normal mode */ while(y1 > 0) { x2 += 2; y2 += 2; y1 -= 2; x1 -= 2; for (x = x1; x <= x2; x++) PG_Plot(x, y1, WHITE); for (y = y1; y <= y2; y++) PG_Plot(x2, y, WHITE); for (x = x2; x >= x1; x--) PG_Plot(x, y2, WHITE); for (y = y2; y >= y1; y--) PG_Plot(x1, y, WHITE); } } boolean vorspann(void) { int i, j, result; char c=0; /* initialize the graphics routines */ result = PG_Init(); if(result == 0) { puts("This is not an Atari Portfolio!"); return(FALSE); } /* put Portfolio into graphics mode */ PG_GoGraphic(); /* Plot some pixels */ PlotSpiral(); /* load in a picture */ PG_Show("clubnr.PIC"); c=getch(); if(c==27) { PG_ClearScreen(); PG_GoText(); return(FALSE); }; /* clear the screen */ PG_ClearScreen(); /* return to text mode */ PG_GoText(); /* Cursor aus */ asm{ mov ah,1111b mov al, 1 mov bl, 0 int 61h } return(TRUE); }; int checkit(char zeichen) /* Ermittelt. ob die Buchstaben in Namen korreckt sind und gibt den Wert dafr zurck. es werden hier alle Buchstaben von A-Z behandelt, die Sonderzeichen werden extra berechnet*/ { zeichen=toupper(zeichen); if((zeichen>=65)&&(zeichen<=90)|| (zeichen>=48)&&(zeichen<=57) ) if(zeichen>57) return(zeichen-65); else return(zeichen-48); else switch(zeichen) { case 'Ž': case '„': return(26); case '™': case '”': return(27); case 'š': case '': return(28); case 'α': return(29); case ' ': return(32); default: return(99); }; }; char checkit2(int wert) { switch(wert) { case 26: return('Ž'); case 27: return('™'); case 28: return('š'); case 29: return('α'); case 32: return(' '); default: return(wert+65); }; }; boolean berechnen_plz(char plz[5], char name[30], char mnr[10]) { int i,j=0; for(i=0;i<=5;i++) { sprintf(plz+i,"%d",(checkit(mnr[j])*10+checkit(mnr[j+1]))-checkit(name[i])); j+=2; }; plz[5]=0; return(TRUE); }; boolean berechnen_name(char plz[5], char name[30], char mnr[10]) { int i,j=0; for(i=0;i<=5;i++) { sprintf(name+i,"%c",checkit2((checkit(mnr[j])*10+checkit(mnr[j+1]))-checkit(plz[i]))); j+=2; }; name[5]=0; return(TRUE); };