Re: Circle [Code] (files)

From: Walter Goodwin (jgoodwin@expert.cc.purdue.edu)
Date: 02/18/97


Well, first question is, why?!? if it's just 1000 columns of ones,
you could simulate in another way, however, assuming there is a real
reason, I'll give you waht I _think_ should work.  Given that
you know the exact format and it won't change, its actually pretty easy.

I'm not sure of the exact commands, but by looking in parse_mobile
you can find the ones I mean.  First, define your multidimensional array,
and a character string capable of reading in those 2000 characters
(1 for the number, 1 for the spaces, this is assuming you don't do double
digits, if you DO go up to above 10, then of course this increases to
3000)  For good measure make sure there are no extra spaces at the end,
and define it as char line[2001];  (3001 for double digits)

What the hell, here is what _should_ work.

void read_in_array(FILE *fl, int table[TABLE_WIDTH][TABLE_LENGTH])
{
char line[2001];
int index1, index2;

for (index1 = 0; index1 < TABLE_LENGTH; index1++)
{
  get_line(fl, line);
  for (index2 = 0; index2 < TABLE_WIDTH; index++)
  {
    scanf(line, "%d %s", table[index2][index1], line);
  }
}

}


To call this function, define your array, and open the file.
then pass the file and the array to the function.  It then
reads 1 line at a time into a secondary character string,
it then cycles through and reads one value at a time.  As
long as you do this at bootup, your system shouldn't suffer :)
however, if you want, you CAN go through and type out all
1000 %d's along with the table[0][index], table[1][index]
but I'm waaaaaaaay to lazy to do that myself :)  (besides,
your supposed to let the computer do the work anyways :)

BTW, what IS this for?  the only thing I can think of is to generate
a large world file by defining terrain types.

> I know how to open the file
> and do everything needed except to be
> able to load this massive table into this array a.

Well the function I wrote _should_ work to read it in, but you should
take a look through db.c to find out how to open a file.  (Here's
hint, look through discrete_load :)


> Could anyone give me a hand? (Daniel :))

I'm starting to see what he means :)  (Daniel that is ;)
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
|    Or send 'info circle' to majordomo@cspo.queensu.ca     |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST