if For Chrome

Discussions and Tech Support specific to the iMacros for Chrome extension.
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
tusiromania
Posts: 27
Joined: Tue Feb 04, 2020 11:09 pm

Re: if For Chrome

Post by tusiromania » Sun Oct 09, 2022 5:39 pm

Hi there
amazing job @chivracq here and now try by myself to adapt for my needs

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
SET !DATASOURCE 6-ori-zi-shedule.csv
 
SET !VAR1 "a1='1', a1='61', a1='121', a1='181', a1='241', a1='301', a1='361', a1='421', a1='501', a1='561', a1='621', a1='681'"
SET !VAR2 "b1='1', b1='2', b1='3', b1='4', b1='5', b1='6', b1='7', b1='8', b1='9', b1='10', b1='11', b1='12'"


SET !VAR3 EVAL("var s='{{!LOOP}}', brh='{{!VAR1}}', brc='{{!VAR2}}'; var x,y,z; x=brh.split(s); y=x[0].split(',').length; z=brc.split(',')[y-1].split('\\'')[1]; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_VAR3:<SP>_{{!VAR3}}_<BR>brh:<BR>__{{!VAR1}}_<BR><BR>brc:<BR>_{{!VAR2}}_<BR><BR>

SET !DATASOURCE_LINE {{!VAR3}}

The problem here is with the LOOPs I don't declare.
if I declare LOOP 1 will show me 1, and of course on LOOP 61 will show 2, but if I don't declare the LOOPs between them, will show me random numbers.

I need to show me in !VAR3 only the specified LOOPs in !VAR1 with !VAR2
the Loops I don't declare to show nothing
and SET !DATASOURCE_LINE will be empty with error
and with SET !ERRORIGNORE YES will pass the line.

thank you for your advices

I am using (FCI): iMacros for CR v10.1.1 'PE', CR v105.0.5195.102 (_x64), Win10_x64. ('CR' = 'Chrome' / 'PE' = 'Personal Edition')
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: if For Chrome

Post by chivracq » Sun Oct 09, 2022 7:24 pm

tusiromania wrote:
Sun Oct 09, 2022 5:39 pm
Hi there
amazing job @chivracq here and now try by myself to adapt for my needs

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
SET !DATASOURCE 6-ori-zi-shedule.csv
 
SET !VAR1 "a1='1', a1='61', a1='121', a1='181', a1='241', a1='301', a1='361', a1='421', a1='501', a1='561', a1='621', a1='681'"
SET !VAR2 "b1='1', b1='2', b1='3', b1='4', b1='5', b1='6', b1='7', b1='8', b1='9', b1='10', b1='11', b1='12'"


SET !VAR3 EVAL("var s='{{!LOOP}}', brh='{{!VAR1}}', brc='{{!VAR2}}'; var x,y,z; x=brh.split(s); y=x[0].split(',').length; z=brc.split(',')[y-1].split('\\'')[1]; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_VAR3:<SP>_{{!VAR3}}_<BR>brh:<BR>__{{!VAR1}}_<BR><BR>brc:<BR>_{{!VAR2}}_<BR><BR>

SET !DATASOURCE_LINE {{!VAR3}}

The problem here is with the LOOPs I don't declare.
if I declare LOOP 1 will show me 1, and of course on LOOP 61 will show 2, but if I don't declare the LOOPs between them, will show me random numbers.

I need to show me in !VAR3 only the specified LOOPs in !VAR1 with !VAR2
the Loops I don't declare to show nothing
and SET !DATASOURCE_LINE will be empty with error
and with SET !ERRORIGNORE YES will pass the line.

thank you for your advices

I am using (FCI):

Code: Select all

iMacros for CR v10.1.1 'PE', CR v105.0.5195.102 (_x64), Win10_x64. ('CR' = 'Chrome' / 'PE' = 'Personal Edition')

Oh...!, alright, I remember this Thread indeed, ah-ah...! :P
And hum, OK, I understand your Idea/Implementation, but hum, that's pretty cumbersome in my Opinion, it would be much easier in your case to simply use 'Modulo[60]' like in:

Code: Select all

SET !ERRORIGNORE YES
SET DS_Line_Mod60 EVAL("var n='{{!LOOP}}'; var z; if((n%60)==1){z=((n-1)/60)+1;} else{z=0;}; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>DS_Line_Mod60:<SP>_{{DS_Line_Mod60}}_
(Tested in iMacros for FF v8.8.2, PM v26.3.3, Win10.)
- (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...
tusiromania
Posts: 27
Joined: Tue Feb 04, 2020 11:09 pm

Re: if For Chrome

Post by tusiromania » Sun Oct 09, 2022 10:45 pm

wow @chivracq
you made my day :)
thank you. :D
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: if For Chrome

Post by chivracq » Mon Oct 10, 2022 6:50 am

tusiromania wrote:
Sun Oct 09, 2022 10:45 pm
wow @chivracq
you made my day :)
thank you. :D
:D
- (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...
tusiromania
Posts: 27
Joined: Tue Feb 04, 2020 11:09 pm

Re: if For Chrome

Post by tusiromania » Wed Oct 12, 2022 9:18 am

Hi @chivracq
I adapted the code from you to Refresh page at every 5 loops.
I have prompt Refresh, but if I use {{refresh}} only I have error

Code: Select all

SyntaxError: can not parse macro line 4: {{refresh}}
I am missing something ?

Code: Select all

SET !ERRORIGNORE YES
SET refresh EVAL("var n='{{!LOOP}}'; var z; if((n%5)==0){z=\"REFRESH\";} else{z=0;}; z;")
'{{refresh}}
PROMPT {{refresh}}

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

Re: if For Chrome

Post by chivracq » Wed Oct 12, 2022 11:29 am

tusiromania wrote:
Wed Oct 12, 2022 9:18 am
Hi @chivracq
I adapted the code from you to Refresh page at every 5 loops.
I have prompt Refresh, but if I use {{refresh}} only I have error

Code: Select all

SyntaxError: can not parse macro line 4: {{refresh}}
I am missing something ?

Code: Select all

SET !ERRORIGNORE YES
SET refresh EVAL("var n='{{!LOOP}}'; var z; if((n%5)==0){z=\"REFRESH\";} else{z=0;}; z;")
'{{refresh}}
PROMPT {{refresh}}

Thank you

"I am missing something ?"
=> Nope, WE are missing something...! :( , and this is why I maintain a List of Enhancement Requests in the following Thread...: :P 8)
- Re: List of EnhReq's...!! [by @chivracq]

... And you want Item '#14'...!: :P :idea:
chivracq wrote:
Fri Mar 23, 2018 2:24 pm
-14- Implement a "Super" Built-in Var that could contain Commands like 'OPEN' / 'CLOSE' / 'REFRESH' / 'CLEAR' / etc and other (Built-in) Vars like for example in '{{!COL{{!LOOP}}}}'.

... But "Good News" is that there are several Workarounds, search the Forum on "conditional + refresh" [+ "reload" | "url goto"]... :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...
tusiromania
Posts: 27
Joined: Tue Feb 04, 2020 11:09 pm

Re: if For Chrome

Post by tusiromania » Sat Oct 29, 2022 8:49 pm

Hi Chivracq

you helped me with a nice solution bellow
that on loop 1 is 1, loop 61 is 2, loop 121 the result is 3 .. and so on.

Code: Select all

SET !ERRORIGNORE YES
SET DS_Line_Mod60 EVAL("var n='{{!LOOP}}'; var z; if((n%60)==1){z=((n-1)/60)+1;} else{z=0;}; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>DS_Line_Mod60:<SP>_{{DS_Line_Mod60}}_
how can make it on reverse like bellow:
loop1 1 is 1, loop 2 is 61, loop 3 is 121 .. and so on.

Code: Select all

SET !VAR1 "a1='1', a1='2', a1='3', a1='4', a1='5', a1='6', a1='7', a1='8', a1='9', a1='10', a1='11', a1='12', a1='13', a1='14', a1='15', a1='16', a1='17', a1='18', a1='19', a1='20'"
SET !VAR2 "b1='1', b1='61', b1='121', b1='181', b1='241', b1='301', b1='361', b1='421', b1='481', b1='541', b1='601', b1='661', b1='721', b1='781', b1='841', b1='901', b1='961', b1='1021', b1='1081', b1='1141', b1='1201'"
SET MyLoop EVAL("var s='{{!LOOP}}', brh='{{!VAR1}}', brc='{{!VAR2}}'; var x,y,z; x=brh.split(s); y=x[0].split(',').length; z=brc.split(',')[y-1].split('\\'')[1]; z;")
thank you so much
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: if For Chrome

Post by chivracq » Sun Oct 30, 2022 10:55 am

tusiromania wrote:
Sat Oct 29, 2022 8:49 pm
Hi Chivracq

you helped me with a nice solution bellow
that on loop 1 is 1, loop 61 is 2, loop 121 the result is 3 .. and so on.

Code: Select all

SET !ERRORIGNORE YES
SET DS_Line_Mod60 EVAL("var n='{{!LOOP}}'; var z; if((n%60)==1){z=((n-1)/60)+1;} else{z=0;}; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>DS_Line_Mod60:<SP>_{{DS_Line_Mod60}}_
how can make it on reverse like bellow:
loop1 1 is 1, loop 2 is 61, loop 3 is 121 .. and so on.

Code: Select all

SET !VAR1 "a1='1', a1='2', a1='3', a1='4', a1='5', a1='6', a1='7', a1='8', a1='9', a1='10', a1='11', a1='12', a1='13', a1='14', a1='15', a1='16', a1='17', a1='18', a1='19', a1='20'"
SET !VAR2 "b1='1', b1='61', b1='121', b1='181', b1='241', b1='301', b1='361', b1='421', b1='481', b1='541', b1='601', b1='661', b1='721', b1='781', b1='841', b1='901', b1='961', b1='1021', b1='1081', b1='1141', b1='1201'"
SET MyLoop EVAL("var s='{{!LOOP}}', brh='{{!VAR1}}', brc='{{!VAR2}}'; var x,y,z; x=brh.split(s); y=x[0].split(',').length; z=brc.split(',')[y-1].split('\\'')[1]; z;")
thank you so much

Very simple Maths...!: :o
(n-1)x60 +1
- (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...
tusiromania
Posts: 27
Joined: Tue Feb 04, 2020 11:09 pm

Re: if For Chrome

Post by tusiromania » Sun Oct 30, 2022 3:23 pm

thank you

Code: Select all

SET !ERRORIGNORE YES
SET DS_Line_Mod60 EVAL("var n='{{!LOOP}}'; var z; if((n%1)==0){z=((n-1)*60)+1;} else{z=0;}; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>DS_Line_Mod60:<SP>_{{DS_Line_Mod60}}_
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: if For Chrome

Post by chivracq » Sun Oct 30, 2022 3:39 pm

tusiromania wrote:
Sun Oct 30, 2022 3:23 pm
thank you

Code: Select all

SET !ERRORIGNORE YES
SET DS_Line_Mod60 EVAL("var n='{{!LOOP}}'; var z; if((n%1)==0){z=((n-1)*60)+1;} else{z=0;}; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>DS_Line_Mod60:<SP>_{{DS_Line_Mod60}}_

Well, 'Modulo[1]' has no use on an Integer, and 'if(n%1)==0' will always be True, ah-ah...! :P
+ The 'else' Part will never be executed... :P

=> Can simplify as:

Code: Select all

SET !ERRORIGNORE YES
SET DS_Line_Mod60 EVAL("var n='{{!LOOP}}'; var z=((n-1)*60)+1; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>DS_Line_Mod60:<SP>_{{DS_Line_Mod60}}_
- (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...
tusiromania
Posts: 27
Joined: Tue Feb 04, 2020 11:09 pm

Re: if For Chrome

Post by tusiromania » Sun Oct 30, 2022 8:27 pm

How you manage to brighten my day every time. thank you :D
I am intensely focused on my scripts to optimize them. even 1 second if I win or a minus line in the script .. I am super happy.
tusiromania
Posts: 27
Joined: Tue Feb 04, 2020 11:09 pm

Re: if For Chrome

Post by tusiromania » Tue Nov 22, 2022 8:55 pm

Hi there

I have this working code, but from time-to-time return "Undefined" value.
I am doing something wrong? or need to be optimized?

Code: Select all

SET orasteps EVAL("var n='{{!LOOP}}'; var x,y,z; x=n%6; if(x==0){z=6;} else{z=x;}; z;")
SET orasteps1 "_12:15<SP>AM_5:00<SP>AM_10:00<SP>AM_12:15<SP>PM_5:00<SP>PM_10:00<SP>PM_"
SET ora EVAL("var n='{{orasteps}}', x='{{orasteps1}}'; var z=x.split('_'); z[n];")
Prompt {{ora}}

Code: Select all

iMacros for CR v10.1.1 'PE', CR v105.0.5195.102 (_x64), Win10_x64. ('CR' = 'Chrome' / 'PE' = 'Personal Edition')
tusiromania
Posts: 27
Joined: Tue Feb 04, 2020 11:09 pm

Re: if For Chrome

Post by tusiromania » Wed Nov 23, 2022 12:53 am

Hi again
I have this code
that I have for loop 61 -1 , 121 - 2 ..

Code: Select all

SET !ERRORIGNORE YES
SET DS_Line_Mod60 EVAL("var n='{{!LOOP}}'; var z; if((n%60)==1){z=((n-1)/60)+1;} else{z=0;}; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>DS_Line_Mod60:<SP>_{{DS_Line_Mod60}}_
how can I make the formula to have
on loop 60 - 1, loop 120 - 2

thank you
Post Reply