Imacro JS Help

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information:CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
mccarthy995
Posts: 8
Joined: Fri Aug 03, 2018 4:27 pm

Imacro JS Help

Post by mccarthy995 » Tue Mar 05, 2019 2:13 pm

What version of iMacros are you using?
VERSION BUILD=9030808

What operating system are you using?
ENG UK WIN 7

Which browser are you using?
FF 52.0.1 (32-bit)

ERROR:
MacroSyntaxError: wrong format of SET command, line 24 (Error code: -910)

---------------------------------------------------

Hello!

I am still messing around with JavaScript and I'm improving, My only issue I have now is implementing this into Imacros. I would like a second opinion in relation to the EVAL statement in one of the last lines of code under "Retailer".

I believe the issue I am having is with the quotation marks (Please correct me if I am wrong), I cannot for the life of me make the script work with: " ' or \

I have Eval statements everywhere, Can someone help me with this one so I will be prepared to handle the rest by myself, thanks!! :mrgreen:

Code: Select all

var CODE;
CODE ="CODE:";

CODE +="SET !ERRORIGNORE YES "+"\n";
CODE +="SET !WAITPAGECOMPLETE YES "+"\n";
CODE +="SET !TIMEOUT_STEP 2 "+"\n";
CODE +="SET !EXTRACT_TEST_POPUP NO "+"\n";

//Full Name
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Name: "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR1 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Service ID
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Service<sp>ID: "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR2 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Postal Code
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Address:"+"\n";
   CODE +="TAG POS=R5 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT"+"\n";
    CODE +="SET !VAR4 {{!EXTRACT}}"+"\n";
     CODE +="SET !EXTRACT NULL"+"\n";

//CLI
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:CLI<sp>Number* "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR5 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Retailer
  CODE +="TAG POS=1 TYPE=SPAN ATTR=TXT:Account:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR6 {{!EXTRACT}} "+"\n";
     CODE +="SET !VAR6 EVAL('var s='{{!VAR6}}'; var z=s.substr(8,4); z;')"+"\n";
       CODE +="SET !EXTRACT NULL  "+"\n";

iimPlay(CODE);
chivracq
Posts: 8308
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Imacro JS Help

Post by chivracq » Tue Mar 05, 2019 2:30 pm

mccarthy995 wrote:
Tue Mar 05, 2019 2:13 pm
What version of iMacros are you using?
VERSION BUILD=9030808

What operating system are you using?
ENG UK WIN 7

Which browser are you using?
FF 52.0.1 (32-bit)

ERROR:
MacroSyntaxError: wrong format of SET command, line 24 (Error code: -910)

---------------------------------------------------

Hello!

I am still messing around with JavaScript and I'm improving, My only issue I have now is implementing this into Imacros. I would like a second opinion in relation to the EVAL statement in one of the last lines of code under "Retailer".

I believe the issue I am having is with the quotation marks (Please correct me if I am wrong), I cannot for the life of me make the script work with: " ' or \

I have Eval statements everywhere, Can someone help me with this one so I will be prepared to handle the rest by myself, thanks!! :mrgreen:

Code: Select all

var CODE;
CODE ="CODE:";

CODE +="SET !ERRORIGNORE YES "+"\n";
CODE +="SET !WAITPAGECOMPLETE YES "+"\n";
CODE +="SET !TIMEOUT_STEP 2 "+"\n";
CODE +="SET !EXTRACT_TEST_POPUP NO "+"\n";

//Full Name
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Name: "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR1 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Service ID
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Service<sp>ID: "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR2 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Postal Code
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Address:"+"\n";
   CODE +="TAG POS=R5 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT"+"\n";
    CODE +="SET !VAR4 {{!EXTRACT}}"+"\n";
     CODE +="SET !EXTRACT NULL"+"\n";

//CLI
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:CLI<sp>Number* "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR5 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Retailer
  CODE +="TAG POS=1 TYPE=SPAN ATTR=TXT:Account:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR6 {{!EXTRACT}} "+"\n";
     CODE +="SET !VAR6 EVAL('var s='{{!VAR6}}'; var z=s.substr(8,4); z;')"+"\n";
       CODE +="SET !EXTRACT NULL  "+"\n";

iimPlay(CODE);
Yeah..., but..., can you give a more Descriptive Title to your Thread for me to have a look...? About 50% of all Threads on this Sub-Forum are about "iMacros JS Help", try searching the Forum using those Keywords, especially if you also manage to squeeze 3 Typos in one single Word...! :roll:

But hum, 1 Sec glimpse at your Script and I already see the "Problem", it's exactly the same Pb like in your previous Thread from last year... :idea:
I already gave you the "Tools" and Guideline and all Explanation 7 months ago...
- (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...
mccarthy995
Posts: 8
Joined: Fri Aug 03, 2018 4:27 pm

Re: Imacro JS Eval Issues With quotes

Post by mccarthy995 » Thu Mar 07, 2019 12:58 pm

Sorry Chivracq,

I don't mean to be a pest. I will update the title now and in the future to something more descriptive. As for the same thread I took some time off and still using the solution you provided doesn't seem to be working for me.

The script works when I run it without EVAL but when I now add this, the error I am getting is:
SyntaxError: missing ; before statement, line 37 (Error code: -991)

If I am not mistaken, this is a very common error and Its probably down to a issue with how the code is written, Are you able to assist me further please?

Code: Select all

var CODE;
CODE ="CODE:";

CODE +="SET !REPLAYSPEED FAST "+"\n";
CODE +="SET !ERRORIGNORE YES "+"\n";
CODE +="SET !WAITPAGECOMPLETE YES "+"\n";
CODE +="SET !TIMEOUT_STEP 2 "+"\n";
CODE +="SET !EXTRACT_TEST_POPUP NO "+"\n";

//Full Name
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Name: "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR1 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Service ID
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Service<sp>ID: "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR2 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Postal Code
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Address:"+"\n";
   CODE +="TAG POS=R5 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT"+"\n";
    CODE +="SET !VAR4 {{!EXTRACT}}"+"\n";
     CODE +="SET !EXTRACT NULL"+"\n";

//CLI
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:CLI<sp>Number* "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR5 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Retailer
  CODE +="TAG POS=1 TYPE=SPAN ATTR=TXT:Account:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR6 {{!EXTRACT}} "+"\n";
[b]      CODE +='SET !VAR6 EVAL("var s='{{!VAR6}}'; var z=s.substr(8,4); z;") '+"\n";[/b]
       CODE +="SET !EXTRACT NULL  "+"\n";

iimPlay(CODE);
mccarthy995
Posts: 8
Joined: Fri Aug 03, 2018 4:27 pm

Re: Imacro JS Help

Post by mccarthy995 » Thu Mar 07, 2019 1:00 pm

I tried making the affected line of code bold, since this does not work in the code section please just ignore the

Thanks.
Tom
mccarthy995
Posts: 8
Joined: Fri Aug 03, 2018 4:27 pm

Re: Imacro JS Eval Issues With quotes

Post by mccarthy995 » Thu Mar 07, 2019 1:01 pm

*Sigh*

Please ignore the (B)(/B) Quotes. Thank you.

Tom
chivracq
Posts: 8308
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Imacro JS Eval Issues With quotes

Post by chivracq » Thu Mar 07, 2019 1:55 pm

mccarthy995 wrote:
Thu Mar 07, 2019 12:58 pm
Sorry Chivracq,

I don't mean to be a pest. I will update the title now and in the future to something more descriptive.
mccarthy995 wrote:
Thu Mar 07, 2019 1:00 pm
I tried making the affected line of code bold, since this does not work in the code section please just ignore the (b)

Thanks.
Tom
mccarthy995 wrote:
Thu Mar 07, 2019 1:01 pm
*Sigh*

Please ignore the (B)(/B) Quotes. Thank you.

Tom
OK, nearly good... Your new Post Title ("Imacro JS Eval Issues With quotes) is "nearly" perfect, except for "Imacro" which still contains 3 Typos, correct Spelling is "iMacros". But using this Word in a Thread Title is always a bit useless anyway, as absolutely all Threads on our Forum are all related to "iMacros" and nobody would use that Word as a Search Keyword to search the Forum.

But there is a Difference between "Post Title" and "Thread Title". Every single Post in a Thread gets a Post Title, while the Thread Title is the Post Title of the very first Post in a Thread, which is still the useless "Imacro JS Help".
=> You need to edit your 1st Post in this Thread for the whole Thread to take your new Title.
... Or each new Post in the Thread automatically get the "old" Thread Title from the 1st Post like happened in your "I tried making the affected line..." Post...
And my current Post automatically got your "new" Title because I started my Post by quoting your first Post with the new Title.
And the Thread Title is "important" because this is the Title other Users see when looking at a Sub-Forum like the 'iMacros for FF' Sub-Forum where you opened your Thread, and this is also usually the Title other Users will see as Search Result when searching the Forum.

You can always edit all previous Posts, and even delete your last Post as long as there is no new Post after it, posted by yourself or sbd else...

>>>
mccarthy995 wrote:
Thu Mar 07, 2019 12:58 pm
[...] As for the same thread I took some time off and still using the solution you provided doesn't seem to be working for me.

The script works when I run it without EVAL but when I now add this, the error I am getting is:
SyntaxError: missing ; before statement, line 37 (Error code: -991)

If I am not mistaken, this is a very common error and Its probably down to a issue with how the code is written, Are you able to assist me further please?

Code: Select all

var CODE;
CODE ="CODE:";

CODE +="SET !REPLAYSPEED FAST "+"\n";
CODE +="SET !ERRORIGNORE YES "+"\n";
CODE +="SET !WAITPAGECOMPLETE YES "+"\n";
CODE +="SET !TIMEOUT_STEP 2 "+"\n";
CODE +="SET !EXTRACT_TEST_POPUP NO "+"\n";

//Full Name
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Name: "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR1 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Service ID
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Service<sp>ID: "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR2 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Postal Code
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:Address:"+"\n";
   CODE +="TAG POS=R5 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT"+"\n";
    CODE +="SET !VAR4 {{!EXTRACT}}"+"\n";
     CODE +="SET !EXTRACT NULL"+"\n";

//CLI
  CODE +="TAG POS=1 TYPE=DT ATTR=TXT:CLI<sp>Number* "+"\n";
   CODE +="TAG POS=R1 TYPE=SPAN ATTR=TXT:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR5 {{!EXTRACT}} "+"\n";
     CODE +="SET !EXTRACT NULL "+"\n";

//Retailer
  CODE +="TAG POS=1 TYPE=SPAN ATTR=TXT:Account:* EXTRACT=TXT "+"\n";
    CODE +="SET !VAR6 {{!EXTRACT}} "+"\n";
[b]      CODE +='SET !VAR6 EVAL("var s='{{!VAR6}}'; var z=s.substr(8,4); z;") '+"\n";[/b]
       CODE +="SET !EXTRACT NULL  "+"\n";

iimPlay(CODE);
"the solution you provided doesn't seem to be working for me."
=> Yep it does...!

Your "original" Pb was about Line 24 and "Wrong Format of 'SET' Command", indeed related to your 'EVAL()' Line of Code:

Code: Select all

     CODE +="SET !VAR6 EVAL('var s='{{!VAR6}}'; var z=s.substr(8,4); z;')"+"\n";
... which you've modified to:

Code: Select all

      CODE +='SET !VAR6 EVAL("var s='{{!VAR6}}'; var z=s.substr(8,4); z;") '+"\n";
... which now looks correct to me, as you know "correctly" alternate Single and Double Quotes, confirmed by your "new" RuntimeError which is about Line 37, meaning Line 24 is not posing a Pb anymore and is accepted by the JS Runtime Engine.

But that "new" Line 37 is not included in the (2x) Script you've posted, so I can't help you on that one... :wink:

>>>

As for your Script, the 'REPLAYSPEED' has no real use as "FAST" is already the Default. Hum, unless you "sometimes" need to slow down your Script...
And '!WAITPAGECOMPLETE' is completely useless as this Command is not supported on FF, I'm nearly surprised you don't get some Parsing Error about "Command not supported"...

And you should read again my Replies from your previous Thread from last year about using 'EVAL()' in '.js' Scripts and on-the-fly '.iim' Macros, this is not a very good Practice, you are making "Things" unnecessarily "complicated" and cumbersome for yourself... :idea:
- (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...
Post Reply