Solve: Typecast??
CoolED is a Session variable that is comming from a scrapping session.
I tried to compare the numerical value in CoolED to a number.
I tried:
{
session.scrapeFile( "Cool Get Page number" );
}
Then I get:
Untitled Extractor Pattern--DataRecord 0:
CoolED=22
Storing this value in a session variable.
Cool Recupere collection: Processing scripts after a pattern application.
Processing script: "Cool Get Edtion number"
An error occurred while processing the script: Cool Get Edtion number
The error message was: Operator: '"<"' inappropriate for objects : at Line: 1.
Then I said to myself that a String cannot be compare to a Number.
Then I tried:
{
session.scrapeFile( "Cool Get Page number" );
}
I get:
Untitled Extractor Pattern--DataRecord 0:
CoolED=22
Storing this value in a session variable.
Cool Recupere collection: Processing scripts after a pattern application.
Processing script: "Cool Get Edtion number"
An error occurred while processing the script: Cool Get Edtion number
The error message was: Command not found: Number : at Line: 1.
Do I am on the right track?
And if Yes, to your Java Script support TypeCasting and the funcion Number()
You're right everything that
You're right everything that comes from an extractor pattern is a String even if it looks like a number. You need to parse the String into an Integer.
Try this:
if (Integer.parseInt(session.getVariable("CoolED")) < 120)
{
session.scrapeFile( "Cool Get Page number" );
}
Solve
Thank both of you for the fast answer.
I tried shadders code and it work perfectly.
Thank!!
Yeah, usually the indicator
Yeah, usually the indicator is the "Operator: '"<"' inappropriate for objects" part. If shadders' suggestion doesn't work, then maybe try:
if (Integer.parseInt(session.getVariable("CoolED").toString()) < 120)
instead