Blacknight962
03-06-2009, 07:41 AM
What im trying to do:
Read a file called "script.txt" if the line starts with Walk then get the coordinates inbetween
Example: First line = Walk(500,500)
then the coordinates that it needs to get are 500,500
and then finally send it to Walk();
however im getting this error: http://img16.imageshack.us/my.php?image=errorqjk.jpg
BufferReader code:
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("Script.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println ("Full Line: " + strLine);
if (strLine.toLowerCase().startsWith("walk") ) {
int x = Integer.parseInt(strLine.substring(strLine.indexOf('(') + 1, strLine.indexOf(',')));
int y = Integer.parseInt(strLine.substring(strLine.indexOf(',') + 1, strLine.indexOf(')')));
Walk(x + "," + y);
}
}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
Walk();
public void Walk(int x, int y)
{
menuID[0] = 920;
menuActionX[0] = x - areaX;
menuActionY[0] = y - areaY;
menuClick(0);
}
script.txt:
Walk(500,500)
Thanks,
Blacknight
Read a file called "script.txt" if the line starts with Walk then get the coordinates inbetween
Example: First line = Walk(500,500)
then the coordinates that it needs to get are 500,500
and then finally send it to Walk();
however im getting this error: http://img16.imageshack.us/my.php?image=errorqjk.jpg
BufferReader code:
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("Script.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println ("Full Line: " + strLine);
if (strLine.toLowerCase().startsWith("walk") ) {
int x = Integer.parseInt(strLine.substring(strLine.indexOf('(') + 1, strLine.indexOf(',')));
int y = Integer.parseInt(strLine.substring(strLine.indexOf(',') + 1, strLine.indexOf(')')));
Walk(x + "," + y);
}
}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
Walk();
public void Walk(int x, int y)
{
menuID[0] = 920;
menuActionX[0] = x - areaX;
menuActionY[0] = y - areaY;
menuClick(0);
}
script.txt:
Walk(500,500)
Thanks,
Blacknight