View Single Post
Old Jun 1st, 2006, 10:50 PM   #6
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
So i've given you the part where it reads from the file/ stores it into the array. That part doesn't give me any errors. Now, here's the code where the error comes into play. I've placed it in blue font.

int tempLength;
        int position = 0;
        int marker = -1; // a negative value so we know it's not anywhere in the file by default

        SearchForGrid: // a label
        for (int m = 0 ; m < fileCount ; m++)
        {
            tempLength = fileData [m].length ();

            position = fileData [m].indexOf ("<GridSize>");

            if (position >= 0) // if strings not found, returns negative. Thus, if found it's (> 0)
            {
                marker = m; // holds place where grid is found
                m++; // we have nothing else to do on this line
                break SearchForGrid; // done looking for grid
            }

        }
        String tempString = new String ("");
        boolean blnXFound = false, blnYFound = false;

        SearchGridSize:
        for (int i = marker ; i < fileCount ; i++)
        {

          System.out.println ("position: " + fileData [i].indexOf ("<GPieceSize>"));
            position = fileData [i].indexOf ("<GPieceSize>");
            // if we passed onto the other tag, exit
            if (position >= 0)
            {
                System.out.println ("Check your file (PieceData.txt), Somethings not right in there. Quit right now.");
                break SearchGridSize;
            }

            position = fileData [i].indexOf ("x=");

            if (position >= 0)
            {
                tempLength = fileData [i].length (); // takes lenght so we know where string ends
                for (int z = 2 ; z < tempLength ; z++)
                {
                    tempString = tempString + fileData [i].charAt (z);
                }
                xGridSize = Integer.parseInt (tempString);
                System.out.println (" " + xGridSize);
                blnXFound = true;
            }

            position = fileData [i].indexOf ("y=");

            if (position >= 0)
            {
                tempLength = fileData [i].length (); // takes lenght so we know where the string ends

                for (int z = 2 ; z < tempLength ; z++)
                {
                    tempString = tempString + fileData [i].charAt (z); // adds the remaining digits together
                }
                yGridSize = Integer.parseInt (tempString);
                System.out.println (" " + yGridSize);
                blnYFound = true;
            }

            if (blnXFound == true && blnYFound == true)
            {
                break SearchGridSize;
            }

        }

    }
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote