Hum, got a bit "excited" about 'EVAL()' and "syntax" in my previous Post, after a long night, ah-ah...!
But OK, I had another "Look" at your Scenario, but hum, I don't really understand the Logic you want for the 'SET !LOOP', and the 'SET !LOOP' only gets executed on the first Loop (by design)..., and I guess on the first Loop your Col_1 will never be empty, hum, unless you hardcode the '!DATASOURCE_LINE', but even if Col_1 is not empty, '!LOOP' will be undefined as you don't return a Value for the 'ELSE' Condition...
Is "Better Practice" btw to always return a Value for the 'ELSE', even if you don't use it, but that comes in "handy" if you need to debug your Script with 'PROMPT' to follow your Vars... 'EVAL()' Statements with 'IF/ELSE' Conditions "often" behave "unexpectedly", especially with Numbers coming from previous Vars that iMacros and/or 'EVAL()' (at least on FF) tend to treat like Strings, and a "6<8" will (still) return 'TRUE', but "6<10" will return 'FALSE' because of the "10" being treated like a String which starts with a "1" which "alphabetically" is sorted before the "6".
Hum, but OK, you do return a Value for the 'ELSE', got confused by your 'if/else' Syntax that I don't use...
Code: Select all
SET !VAR1 EVAL("var c1='{{!COL1}}'; var z=c1.length; z;")
SET !LOOP EVAL(parseInt("({{!VAR1}}<1)?1:{{!LOOP}}"))
=> Stg like...:
Code: Select all
SET !VAR1 EVAL("var c1='{{!COL1}}'; var z=c1.length; z;")
SET !VAR2 EVAL("var v1='{{!VAR1}}', n='{{!LOOP}}'; var z; if((v1*1))<1){z=n;} else{z=999;}; z;")
SET !LOOP {{!VAR2}}
PROMPT COL1:<SP>_{{!COL1}}_<BR>Length:<SP>{{!VAR1}}<BR><BR>VAR2:<SP>{{!VAR2}}<BR>LOOP:<SP>{{!LOOP}}
Not tested, but even on the 2nd Run (with Col_1 not being empty on Loop=1), '!LOOP' will already =1000, I expect... (And you need to specify some Nb>999 in the 'Loop_Max' Field of course, or the Script will only loop once...)
If Col_1 was empty on Loop=1, '!LOOP' will always =2 on Loop=2 no matter if Col_1 is then empty or not on Loop='!LOOP'=2, because the 'SET !LOOP' will not be executed, iMacros will pull the Value for '!LOOP' from its internal Memory...
But hum, OK, I'm still not "sure' that's the Mechanism that you want...
>>>
EDIT: Hum, wait... I made a Mistake..., got confused by your 'if/else' Syntax that I don't use... Yep indeed, not good, ah-ah...!
OK, 2nd Try...:
Code: Select all
SET !VAR1 EVAL("var c1='{{!COL1}}'; var z=c1.length; z;")
SET !VAR2 EVAL("var v1='{{!VAR1}}', n='{{!LOOP}}'; var z; if((v1*1))<1){z=1;} else{z=n;}; z;")
SET !LOOP {{!VAR2}}
PROMPT COL1:<SP>_{{!COL1}}_<BR>Length:<SP>{{!VAR1}}<BR><BR>VAR2:<SP>{{!VAR2}}<BR>LOOP:<SP>{{!LOOP}}
But this one will always return 1 for the 'SET !LOOP', I would think..., no matter if Col_1 is empty or not on the first Loop.
=> Can simply use, which is the Default anyway...:
Hum, unless you already had a previous '!SET LOOP' Statement in the same Script..., which would be a bit cumbersome in my Opinion..., and not "Best Practice" I would think...
(Even if hum..., I use it myself as a "Trick" in one of my own Scripts, oops..., but it's meant as a "creative Trick" in a long Script (5000 Lines) with some Calculations based on '!LOOP' (to activate or mute different parts of the whole long Script) where at the end, the Script "decides" by itself if it was "successful" (enough) and/or if it needs to run again and how many times... Hum, and it is also meant as a "Workaround" in that Script for the Lack of a '!LOOP_MAX' Var that I've been asking for several years already, and that I use to display some dynamic Log/Report in the Display Area of the Side Panel only on the last Run..., to confirm the "successful" (final) Run and that alerts me if some further Action(s) is/are needed..., and to be able to implement that Functionality in pure '.iim' without using a '.js' Script...)
- (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...