
BEGIN {
        # Read the array data from living.c
        while ((getline buff < living_c) == 1) {
                if (buff ~ /con_bonus\[/) {
			get_values(buff);
		        for(i=1;i<=30;i++) con[i]=array[i];	
                }
                if (buff ~ /sp_bonus\[/) {
                        get_values(buff);
                        for(i=1;i<=30;i++) sp[i]=array[i];
                }
                if (buff ~ /dex_bonus\[/) {
                        get_values(buff);
                        for(i=1;i<=30;i++) ac[i]=-1*array[i];
                }
                if (buff ~ /dam_bonus\[/) { 
                        get_values(buff);   
                        for(i=1;i<=30;i++) dam[i]=array[i]; 
                }
                if (buff ~ /cha_bonus\[/) {
                        get_values(buff);
                        for(i=1;i<=30;i++) { 
			   buy[i] = (6.00*(100-array[i]))/100; 
			   sell[i] = 100.0/(100.0-array[i]); 
			}
                }
                if (buff ~ /speed_bonus\[/) {
                        get_values(buff);
                        for(i=1;i<=30;i++) speed[i]= 1 + array[i];
                }
                if (buff ~ /max_carry\[/) {
			get_values(buff);
		        for(i=1;i<=30;i++) carry[i]=array[i];	
                }
                if (buff ~ /thaco_bonus\[/) {
                        get_values(buff);
                        for(i=1;i<=30;i++) thaco[i]=array[i];
                }
                if (buff ~ /learn_spell\[/) {
                        get_values(buff);
                        for(i=1;i<=30;i++) learn[i]=array[i];
			break;
                }
        }
	# print it out
	for(i=1; i<=30 ; i++) {
		printf("<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s/%2s</td></tr>\n",i,
		   con[i],sp[i],ac[i],dam[i],thaco[i],carry[i],speed[i],learn[i],buy[i],sell[i]); 
	}
	
        close(living_c);
}

function get_values (buff) {
        tind = 0;
        while (1) {
           getline buff < living_c;
           # if(lev==1) getline buff < living_c;
           if (buff ~ /};/)
              break;
           gsub("[ \t]*\"", "", buff);
           nr = split(buff, val, ",");
           for (i = 1; i<=nr ; i++)
               if(val[i]!="") array[tind++]=val[i];
        }
}
