Incrementing Session Variable as a Range

Hello Support:

I'm scraping a site whereby a user can search for properties by a square foot range. I'm trying to set an initial value for the range, increment the range and set the maximum value for the range.

I'm trying to set an initial value for the range with the following:

BLDG_SQFT_LOW_START = Integer.parseInt(session.getVariable("LOW_START"));
BLDG_SQFT_HIGH_START = Integer.parseInt(session.getVariable("HIGH_START"));

Setting the maximum value for the range with the following:

BLDG_SQFT_LOW_END = Integer.parseInt(session.getVariable("LOW_START"));
BLDG_SQFT_HIGH_END = Integer.parseInt(session.getVariable("HIGH_END"));

Loop

for( int i = BLDG_SQFT_LOW_START; i < BLDG_SQFT_LOW_END; i++ )
for( int i = BLDG_SQFT_HIGH_START; i < BLDG_SQFT_HIGH_END; i++ )
{

Add the next value as a session variable

session.setVariable( "BLDG_SQFT_LOW", String.valueOf(i) );
session.setVariable( "BLDG_SQFT_HIGH", String.valueOf(i) );

Log

session.log("The current BLDG_SQFT_LOW: " + session.getVariable("BLDG_SQFT_LOW"));
session.log("The current BLDG_SQFT_HIGH: " + session.getVariable("BLDG_SQFT_LOW"));

Scrape the next page

session.scrapeFile("04 Search Processing");

}

All put together the code is as follows:

BLDG_SQFT_LOW_START = Integer.parseInt(session.getVariable("LOW_START"));
BLDG_SQFT_LOW_END = Integer.parseInt(session.getVariable("LOW_START"));
BLDG_SQFT_HIGH_START = Integer.parseInt(session.getVariable("HIGH_START"));
BLDG_SQFT_HIGH_END = Integer.parseInt(session.getVariable("HIGH_END"))
// Loop i.  i++ is increase by one.
for( int i = BLDG_SQFT_LOW_START; i < BLDG_SQFT_LOW_END; i++ )
for( int i = BLDG_SQFT_HIGH_START; i < BLDG_SQFT_HIGH_END; i++ )
{
//Add the next value as a session variable
session.setVariable( "BLDG_SQFT_LOW", String.valueOf(i) );
session.setVariable( "BLDG_SQFT_HIGH", String.valueOf(i) );
// Log
session.log("The current BLDG_SQFT_LOW: " + session.getVariable("BLDG_SQFT_LOW"));
session.log("The current BLDG_SQFT_LOW: " + session.getVariable("BLDG_SQFT_LOW"));
// Scrape the next page
session.scrapeFile("04 Search Processing");

}

I'm receiving the following error:

The error message was: class bsh.EvalError (line 13): ; -- illegal use of undefined variable, class, or 'void' literal

Line 13 is:

for( int i = BLDG_SQFT_LOW_START; i < BLDG_SQFT_LOW_END; i++ )

I think I'm receiving the error message because I combining two code into one but I'm not sure how to do it. Also, I understand that i++ increases by 1 but how do I increase by 20?

Thanks again and again and again...

Regards,

Adrian

increase by 20

i+=20; if you're dealing with integers will give you i with an increase of 20. similar to i = i+20;

if you wanted to check the values in BLDG_SQFT_LOW_START and BLDG_SQFT_LOW_END you could always

session.log(BLDG_SQFT_LOW_END)
session.log(BLDG_SQFT_LOW_START)

before line 13 to make sure they aren't void or null.

I could be wrong, but it seems strange to me that you have 2 "for" loops on line 13 and then 14. I'd take a closer look at that. I have a gut feeling that if the values going into those for loops is fine then java doesn't like the double for loop expression you have there. I could be wrong.

hope that helps