/* A quickly knocked together program to convert a Slash 'RECORD' file into an HTML table of the top 100 (or less if there aren't 100). I would've made the table look nicer, like centering bits, but adding 'align=center' 100 times increases the size of the file needlessly, so I decided against it. There's probably another way I could've done it, but I haven't got an HTML reference book or anything, so I'm working from memory. It actually sets it up ready for use on my webpage, the colour scheme and the use of 'divider.gif' give that away, but that's easily tweaked if anyone else wants to use the program. ---RavenBlack, 1997. */ #include char* textpointer; int writeon(char* texttoadd) { while(*textpointer++=*texttoadd++); textpointer--; } main() { FILE* infile; FILE* outfile; int num=0,realm,level,maxlev,hp,maxhp,score; char type; char text[200]; if ((infile=fopen("record","r"))==NULL) { puts("Error opening file 'record'"); exit(0); } if ((outfile=fopen("record.htm","w"))==NULL) { puts("Error opening file 'record.txt' as output."); fclose(infile); exit(0); } fprintf(outfile,"
\nSlash Scores\n
\n\n"); fprintf(outfile,"
Slash Scores
\n"); while(fscanf(infile,"%d %d %d %d %d %d %d %d %c%c ",NULL,NULL,&realm,&level,&maxlev,&hp,&maxhp,&score,NULL,&type)!=EOF && num++<100) { textpointer=text; while((*textpointer++=fgetc(infile))!=','); textpointer--; switch(type) { case 'M':writeon(" the Monk, "); break; case 'B':writeon(" the Barbarian, "); break; case 'C':writeon(" the Caveman, "); break; case 'D':writeon(" the Doppelganger, "); break; case 'E':writeon(" the Elf, ");break; case 'K':writeon(" the Knight, ");break; case 'A':writeon(" the Archeologist, ");break; case 'W':writeon(" the Wizard, ");break; case 'F':writeon(" the Flame-Mage, ");break; case 'G':writeon(" the Gnome, ");break; case 'H':writeon(" the Healer, ");break; case 'I':writeon(" the Ice-Mage, ");break; case 'L':writeon(" the Lycanthrope, ");break; case 'S':writeon(" the Samurai, ");break; case 'T':writeon(" the Tourist, ");break; case 'U':writeon(" the Undead Slayer, ");break; case 'V':writeon(" the Valkyrie, ");break; default:writeon(" (unknown class), "); } while((*textpointer++=fgetc(infile))!='\n'); textpointer--; switch(realm) { case 11:writeon(" on the Astral Plane"); break; case 0:writeon(" in the Dungeons of Doom"); break; case 2:writeon(" in the Gnomish Mines"); break; case 3:writeon(" in the Orc Caverns"); break; case 8:writeon(" in the Quest"); break; default:writeon(" who knows where"); } fprintf(outfile,"\n",maxhp,score); } fprintf(outfile,"
HitpointsScore
%d. %s, level %d [max %d]",num,text,level,maxlev); if (hp>0) fprintf(outfile,"%d",hp); else fputc('-',outfile); fprintf(outfile,"/%d%d

"); fclose(infile); fclose(outfile); }