JScript variable EVAL error

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

JScript variable EVAL error

by beacher on Thu Feb 01, 2018 12:02 pm

This used to work in Firefox before its Quantum release or until whenever the extension was automatically disabled as unsupported.

The error ...:

Error -1250: JScript statement in EVAL contains the following error: Variable 'repatt' has not been declared. Line 13: SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var patt='[\\r\\n]'; repatt=new RegExp(patt, 'g'); s=s.replace(repatt,\"\"); ")


... is triggered by the following:

VERSION BUILD=12.0.501.6698
TAB T=1
SET !EXTRACT_TEST_POPUP NO
' after FF Quantum , installed the trial iMacros version and got
' "Error -1200: Incorrect ATTR or FORM specifier: EXTRACT=TXT"
' which resorting to the unassigned variable VAR1 may or may or may not be
' a suitable workaround for--the script now gets past it anyway.
' TAG POS=1 TYPE=title ATTR= EXTRACT=TXT
TAG POS=1 TYPE=title ATTR={{!VAR1}} EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var patt='[\\r\\n]'; repatt=new RegExp(patt, 'g'); s=s.replace(repatt,\"\"); ")
...


This is running on the iMacros browser installed earlier this week in the following set-up:

Microsoft Windows 10 Home
Microsoft Windows NT 6.3.9600.0
64-bit Operating System
Installed UI Culture: English (United States)
CLR version 4.0.30319.42000
Internet Explorer version 11.192.16299.0
Enhanced Protected Mode = False, 64-bit processes for EPM = False
BrowserEmulation Mode = IE11
iMacros Browser (x86) version 12.0.501.6698
------------------------------------------------------------
Auxiliary Libraries:
iMacros Direct Screen (iimds) 12.0.0.19
iMacros Image Recognition (iimIRm) 12.0.500.8234
iMacros Dialog Manager (imsys) 12.0.501.6698
------------------------------------------------------------
Scripting Interface Libraries:
iMacros IE Scripting Connector (iimConnector) 12.0.0.148
iMacros FX Connector (iimFirefoxConnector) 3.0.0.37
iMacros Scripting Interface (iimInterface) 12.0.0.148
iMacros FX&Cr Scripting (imtcp) 3.0.0.37
...


Some demo macros do encounter problems ...

Detect Javascript Errors.iim ...
Error -1400: Script error detected but ONSCRIPTERROR CONTINUE=NO was specified.
Eval.iim ...
Error -1340: Value is not in the set range. Line 25: SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\", d = parseFloat(s); if(d > 99 && d < 101) d; else MacroError(\"Value is not in the set range\");")


At this stage in the script anyway, the goal is just to strip out quotes. Later on similarly so for URL substrings.

Thanks for any pointers regarding fixes or alternate ways to do this.
beacher
 
Posts: 2
Joined: Thu Feb 01, 2018 10:42 am

Re: JScript variable EVAL error

by chivracq on Thu Feb 01, 2018 12:13 pm

beacher wrote:This used to work in Firefox before its Quantum release or until whenever the extension was automatically disabled as unsupported.

The error ...:

Error -1250: JScript statement in EVAL contains the following error: Variable 'repatt' has not been declared. Line 13: SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var patt='[\\r\\n]'; repatt=new RegExp(patt, 'g'); s=s.replace(repatt,\"\"); ")


... is triggered by the following:

Code: Select all
VERSION BUILD=12.0.501.6698
TAB T=1
SET !EXTRACT_TEST_POPUP NO
' after FF Quantum , installed the trial iMacros version and got
'      "Error -1200: Incorrect ATTR or FORM specifier: EXTRACT=TXT"
'   which resorting to the unassigned variable VAR1 may or may or may not be
'   a suitable workaround for--the script now gets past it anyway.
' TAG POS=1 TYPE=title ATTR= EXTRACT=TXT
TAG POS=1 TYPE=title ATTR={{!VAR1}} EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var patt='[\\r\\n]'; repatt=new RegExp(patt, 'g'); s=s.replace(repatt,\"\"); ")

...

This is running on the iMacros browser installed earlier this week in the following set-up:

Microsoft Windows 10 Home
Microsoft Windows NT 6.3.9600.0
64-bit Operating System
Installed UI Culture: English (United States)
CLR version 4.0.30319.42000
Internet Explorer version 11.192.16299.0
Enhanced Protected Mode = False, 64-bit processes for EPM = False
BrowserEmulation Mode = IE11
iMacros Browser (x86) version 12.0.501.6698
------------------------------------------------------------
Auxiliary Libraries:
iMacros Direct Screen (iimds) 12.0.0.19
iMacros Image Recognition (iimIRm) 12.0.500.8234
iMacros Dialog Manager (imsys) 12.0.501.6698
------------------------------------------------------------
Scripting Interface Libraries:
iMacros IE Scripting Connector (iimConnector) 12.0.0.148
iMacros FX Connector (iimFirefoxConnector) 3.0.0.37
iMacros Scripting Interface (iimInterface) 12.0.0.148
iMacros FX&Cr Scripting (imtcp) 3.0.0.37
...


Some demo macros do encounter problems ...

Detect Javascript Errors.iim ...
Error -1400: Script error detected but ONSCRIPTERROR CONTINUE=NO was specified.
Eval.iim ...
Error -1340: Value is not in the set range. Line 25: SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\", d = parseFloat(s); if(d > 99 && d < 101) d; else MacroError(\"Value is not in the set range\");")


At this stage in the script anyway, the goal is just to strip out quotes. Later on similarly so for URL substrings.

Thanks for any pointers regarding fixes or alternate ways to do this.

Yep..., simply add a "var" before declaring your 'repatt' Var, I would think... (Or replace the Semi-Colon just before it by a Comma...!):
Code: Select all
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var patt='[\\r\\n]'; var repatt=new RegExp(patt, 'g'); s=s.replace(repatt,\"\"); ")

The "var" Declaration is indeed not needed on FF, but iMB is based on IE that uses a different JS Engine which probably still needs the "var" Declaration, is my (uneducated) Guess...!
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6960
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: JScript variable EVAL error

by beacher on Thu Feb 01, 2018 12:25 pm

That was it ... my syntax was too casually shy of the mark ... it has to be

var x=..., y=...; ...


or

var x=; var y=...;


-Thanks!
beacher
 
Posts: 2
Joined: Thu Feb 01, 2018 10:42 am

Re: JScript variable EVAL error

by chivracq on Thu Feb 01, 2018 12:33 pm

beacher wrote:That was it ... my syntax was too casually shy of the mark ... it has to be

var x=..., y=...; ...


or

var x=; var y=...;


-Thanks!

Yep, exactly...!

And FF automatically adds the "var" Declaration, but obviously other Browsers don't... Good to know..., and Good Practice is then to always declare it for (Backward) Browser-Compatibility, you never know if one day you won't need to run your Script in some other Browser/Version... :wink:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6960
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 5 guests

-->