groundfalling wrote:@chivracq thank you for the info, actually my target is not to close the tab or window, i have been trying to use !EXTRACT in EVAL in imacros 10.0.2.1450 (free) in JS format to make it work in .htm and than use it to check a condition and either break the current macro or call a new macro.
i see that you are an EVAL expert but i know you like to use it raw and not in JS.
Yeah well, then maybe it would "help" if you used some "concrete" and "real" Example of what you really want, when I see an Example where you use a User Defined Var for the 'EVAL()', and meant to reuse for the 'EVENT' Mode, both not supported in v10.0.2 ('Free'), then there is no use to try to "correct" the 'EVAL()', it will never work anyway...
About "raw and not in JS", actually the Syntax I use for "my" 'EVAL()' Statements can also be reused directly in JS without any Modification at all in maybe 80% of the cases as I usually don't use any Special Chars that need to be escaped like Double Quotes for example... (well, unless there is a Double Quote as part of the String I want to "handle", then I'm forced to take care of it, of course...).
But say for example, you want 'EVAL()' to return a "1"/"0" if your Element is found/not found..., to maybe reuse for a 'TAG POS=1/0' in the next 'TAG' Statement, in pure '.iim', I would use:
Code: Select all
SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var z; if(s!='#EANF'){z=1;} else{z=0;}; z;")
PROMPT VAR1:<SP>_{{!VAR1}}_
=> ... and you can reuse it as is in your JS if you use Single Quotes for your 'macroCode' String:
Code: Select all
macroCode += 'SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var z; if(s!='#EANF'){z=1;} else{z=0;}; z;")\n';
macroCode += 'PROMPT VAR1:<SP>_{{!VAR1}}_\n';
By alternating Single and Double Quotes, you don't need to escape anything I would expect...
And to "break" your Macro, I don't know how iMacros now "behaves" with this JS/'.html' Method, with a first Macro aborting on some Element not found or 'MacroError()', if the JS on the '.html' Page is able to "take over" and continue Processing the 2nd Macro, you'll have to try..., or you need to split your Macro into smaller junks and handle the Conditional Workflow from the JS part, or you can "mute" the rest of your Macro for example with the "0" from the 'EVAL()' with 'POS=0' which won't do anything...
Or you can compute a "1"/"2" instead and reuse it to conditionally switch to a fake/dummy 'TAB_2' (already open) where the rest of your Macro won't do anything... (That's a good Workaround btw for a Conditional 'REFRESH', but it doesn't work on a 'TAB OPEN' or 'TAB CLOSE' that will always be executed, no matter on which TAB your Script is...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...