how to loops by odd numbers?

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

how to loops by odd numbers?

Post by a2515125 » Sun Nov 10, 2019 2:16 pm

imacros 8.9.7/firefox 52.0/ windos 10

hey, i would like to loop between 0-50 by odd numbers ...!VAR1 = 1/3/5/7/9/11/~48
but have no idea with my eval sentence.

it is not working when I put my code like below
showing !VAR1 = 3/4/5/6/7/8/9/10/~52
i dont know why :idea:

Code: Select all

SET !VAR1 EVAL("var z=\"{{!LOOP}}\";z = (z % 50);if(z == 0){ z = 50};z+=2;")

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

Re: how to loops by odd numbers?

Post by chivracq » Sun Nov 10, 2019 3:46 pm

a2515125 wrote:
Sun Nov 10, 2019 2:16 pm
imacros 8.9.7/firefox 52.0/ windos 10

hey, i would like to loop between 0-50 by odd numbers ...!VAR1 = 1/3/5/7/9/11/~48
but have no idea with my eval sentence.

it is not working when I put my code like below
showing !VAR1 = 3/4/5/6/7/8/9/10/~52
i dont know why :idea:

Code: Select all

SET !VAR1 EVAL("var z=\"{{!LOOP}}\";z = (z % 50);if(z == 0){ z = 50};z+=2;")


You don't even need 'EVAL()' to do that...:

Code: Select all

SET Odd_Loop {{!LOOP}}
ADD Odd_Loop {{!LOOP}}
ADD Odd_Loop -1
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>Odd_Loop:<SP>_{{Odd_Loop}}_
... And you loop your Script 25 times...
- (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...
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

Re: how to loops by odd numbers?

Post by a2515125 » Wed Oct 21, 2020 12:53 am

[/quote]


You don't even need 'EVAL()' to do that...:

Code: Select all

SET Odd_Loop {{!LOOP}}
ADD Odd_Loop {{!LOOP}}
ADD Odd_Loop -1
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>Odd_Loop:<SP>_{{Odd_Loop}}_
... And you loop your Script 25 times...
[/quote]


thanks ....but I would like to have odd numbers jumping between 1-50 :idea:
i have no idea how to put the additional condition to limit the odd numbers within 1-50 with your creative "ADD" method :?:
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

Re: how to loops by odd numbers?

Post by a2515125 » Wed Oct 21, 2020 1:09 am

Code: Select all


SET Odd_Loop {{!LOOP}}
ADD Odd_Loop {{!LOOP}}
ADD Odd_Loop -1


SET !VAR1 EVAL("var z=\"{{{Odd_Loop}}\";z = (z % 50);if(z == 0){ z = 50};z;")
PROMPT {{!VAR1}}

My {{!VAR1}} show "NaN" :lol: :lol: :lol:
how do I solve it ?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: how to loops by odd numbers?

Post by chivracq » Wed Oct 21, 2020 2:04 am

a2515125 wrote:
Wed Oct 21, 2020 12:53 am
thanks ....but I would like to have odd numbers jumping between 1-50 :idea:
i have no idea how to put the additional condition to limit the odd numbers within 1-50 with your creative "ADD" method :?:

Hum, mention your FCI again when you feel like celebrating the 1 year Anniversary of some poor orphan Thread, ah-ah...! :roll:

+ Typo in your Post to use the ']quote[' Forum-Tags "correctly"... :idea:

Answer is/was already in my Script, simply loop it 25 times, ah-ah...! 8)

>>>
a2515125 wrote:
Wed Oct 21, 2020 1:09 am

Code: Select all

SET Odd_Loop {{!LOOP}}
ADD Odd_Loop {{!LOOP}}
ADD Odd_Loop -1

SET !VAR1 EVAL("var z=\"{{{Odd_Loop}}\";z = (z % 50);if(z == 0){ z = 50};z;")
PROMPT {{!VAR1}}
My {{!VAR1}} show "NaN" :lol: :lol: :lol:
how do I solve it ?

Oh dear - Oh dear - Oh dear...!!, yep, lol-lol-lol...!

Once upon a time in iMacros' Land, there was an iMacros User (let's call him "a" + many_digits_for_anonymity) who had 4 Cats (all 4 called "z" for anonymity), but the 4 Cats got so confused chasing their own Tail that they all died when they finally realized that one of them was "Not_A_Cat"... :?

I don't know where you got this Syntax, but you apparently don't understand it, and to be honest, neither do I completely, use Syntax that I posted on the Forum, "my" Syntax is easy to understand and to reuse/adapt/modify... (and to debug...!) Follow "z" and you'll end up like the Cats, oops...! :idea:

>>>

Hum, and quite "funny" that you revived/bumped this Thread, I stumbled today upon an older Thread on SOF from 2011 where @Marcia from @TechSup had also provided the same Solution, ah-ah...!: :o
- How to step 2 with iMacros loop? How to select every other href?
- (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...
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

Re: how to loops by odd numbers?

Post by a2515125 » Wed Oct 21, 2020 2:46 am

ahaha....finally working :D . Thank you

my fault is here
SET !VAR1 EVAL("var z=\"{{{Odd_Loop}}\";z = (z % 50);if(z == 0){ z = 50};z;")

Code: Select all


SET LOOP -900000

SET Odd_Loop {{!LOOP}}
ADD Odd_Loop {{!LOOP}}
ADD Odd_Loop 180001

SET !VAR1 EVAL("var z=\"{{Odd_Loop}}\";z = (z % 50);if(z == 0){ z = 50};z=z++;")

PROMPT {{!VAR1}}



Last edited by a2515125 on Wed Oct 21, 2020 10:12 am, edited 1 time in total.
a2515125
Posts: 114
Joined: Tue Dec 06, 2016 3:37 am

Re: how to loops by odd numbers?

Post by a2515125 » Wed Oct 21, 2020 10:11 am

a2515125 wrote:
Wed Oct 21, 2020 2:46 am
ahaha....finally working :D . Thank you

my fault is here
SET !VAR1 EVAL("var z=\"{{{Odd_Loop}}\";z = (z % 50);if(z == 0){ z = 50};z;")

Code: Select all


SET LOOP -900000

SET Odd_Loop {{!LOOP}}
ADD Odd_Loop {{!LOOP}}
ADD Odd_Loop 180001

SET !VAR1 EVAL("var z=\"{{Odd_Loop}}\";z = (z % 50);if(z == 0){ z = 50};z=z++;")

PROMPT {{!VAR1}}



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

Re: how to loops by odd numbers?

Post by chivracq » Wed Oct 21, 2020 3:48 pm

a2515125 wrote:
Wed Oct 21, 2020 2:46 am
ahaha....finally working :D . Thank you

my fault is here
SET !VAR1 EVAL("var z=\"{{{Odd_Loop}}\";z = (z % 50);if(z == 0){ z = 50};z;")

Code: Select all

SET LOOP -900000

SET Odd_Loop {{!LOOP}}
ADD Odd_Loop {{!LOOP}}
ADD Odd_Loop 180001

SET !VAR1 EVAL("var z=\"{{Odd_Loop}}\";z = (z % 50);if(z == 0){ z = 50};z=z++;")

PROMPT {{!VAR1}}

Yeah...!, "Thank me", hum..., you are a bit "lucky" in this Case, even if the "{{{" is an "obvious" Typo indeed, but again, the Syntax you are using is very "obscure" and only used by Script-Kiddies on "obscure" Underground-Sites, trying to impress their "Friends", and that Syntax is with iMacros and 'EVAL()' a complete hassle to debug...

Here is the Syntax I "recommend", and it must work pretty well, as I've never needed to ask for any Help, while I'm definitely not a JS Guru at all...!:

Code: Select all

SET !VAR1 EVAL("var n='{{Odd_Loop}}'; var x,y,z; x=(n%50); if(x==0){y=50;} else{y=x;}; z=y+1; z;")
PROMPT Odd_Loop:<SP>_{{Odd_Loop}}_<BR>VAR1:<SP>_{{!VAR1}}_
And if it doesn't work "directly", you can easily debug the 'EVAL()' Statement by simply changing the final (Return) 'z' to 'y'/'x'/'n' to check all intermediary Calculations/Values... 8)
- (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...
DanielPe
Posts: 3
Joined: Mon Nov 16, 2020 4:02 pm

Re: how to loops by odd numbers?

Post by DanielPe » Mon Nov 16, 2020 4:28 pm

Hello chivracq, I have checked your syntax and it works very well for me, thanks for sharing, here we are all learning. Cheers
All is posiblle if you can to believe!
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: how to loops by odd numbers?

Post by chivracq » Tue Nov 17, 2020 12:35 am

DanielPe wrote:
Mon Nov 16, 2020 4:28 pm
Hello chivracq, I have checked your syntax and it works very well for me, thanks for sharing, here we are all learning. Cheers

@DanielPe => Yep, my Syntax always works, ah-ah...! Thanks... :twisted:

=> Post your Script where you used my "Syntax"...! :idea:

>>>

[Forum Mod Hat <ON>...]
But hum, I just approved your 3 Posts on the Forum, all 3 a "bit vague", and you have a "dirty" IP..., and your Sig, even if it doesn't contain any Link/Spam "feels" like you are testing how quick Search Engines will index our Forum... :shock:
[Forum Mod Hat <OFF>...]

But welcome to the Forum otherwise if you are a "Legit" User, planning on helping other Users... :D
... And maybe an "Idea" to post a "real" Quality Post in some Thread where you want to help if you want to earn "my Trust", just saying... :idea:
- (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...
Post Reply