IF THEN ELSE to input varying Data from .CSV list

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

IF THEN ELSE to input varying Data from .CSV list

by Thrilling on Wed Sep 06, 2017 7:40 am

Hello,

I'm using iMacros 8.9.7 on FIrefox 45.9.0 ESR on Solaris 11.3 (x64, german)

I'd like to, if possible, input this data
Route Excel.jpg


into this setup
Route Webseite.jpg
Route Webseite.jpg (8.33 KIB) Viewed 404 times


I'd like iMacros to recognize the route number (field marked yellow, manually input by user before running macro), then input the corresponding route into the fields, one city name per field.
On the website you can add as many Text-fields as needed by pressing the "Hinzufügen" (add) button.

For reference, this is what recording manually inputting bogus data and adding more field looks like:
Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName1_TextBox CONTENT=123
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName2_TextBox CONTENT=234
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName3_TextBox CONTENT=345


My idea is to use IF THEN ELSE:
IF the route selection field value = 1
THEN input SAINT-PETERSBURG from route 1 into the text field
IF the route value = 2
THEN
VAR1 EVAL: split Route 2 using ", " as seperator, select first segment
input VAR1 into textfield 1
open next textfield
VAR2 EVAL: split Route 2 using ", " as seperator, select second segment
input VAR2 into textfield 2
IF
((continue for all routes))
ELSE
Do nothing

Problems:
1. I dont know if IF THEN ELSE works outside EVAL. if it doesnt, then I'm not sure how to approach a solution
2. I don't know the Syntax of IF THEN ELSE, in or outside of EVAL

Any help would be greatly appreciated
Thrilling
 
Posts: 20
Joined: Fri Aug 11, 2017 7:02 am

Re: IF THEN ELSE to input varying Data from .CSV list

by chivracq on Thu Sep 07, 2017 10:39 am

Thrilling wrote:Hello,

I'm using
Code: Select all
iMacros 8.9.7 on FIrefox 45.9.0 ESR on Solaris 11.3 (x64, german)


I'd like to, if possible, input this data
Route Excel.jpg


into this setup
Route Webseite.jpg


I'd like iMacros to recognize the route number (field marked yellow, manually input by user before running macro), then input the corresponding route into the fields, one city name per field.
On the website you can add as many Text-fields as needed by pressing the "Hinzufügen" (add) button.

For reference, this is what recording manually inputting bogus data and adding more field looks like:
Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName1_TextBox CONTENT=123
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName2_TextBox CONTENT=234
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName3_TextBox CONTENT=345


My idea is to use IF THEN ELSE:
IF the route selection field value = 1
THEN input SAINT-PETERSBURG from route 1 into the text field
IF the route value = 2
THEN
VAR1 EVAL: split Route 2 using ", " as seperator, select first segment
input VAR1 into textfield 1
open next textfield
VAR2 EVAL: split Route 2 using ", " as seperator, select second segment
input VAR2 into textfield 2
IF
((continue for all routes))
ELSE
Do nothing

Problems:
1. I dont know if IF THEN ELSE works outside EVAL. if it doesnt, then I'm not sure how to approach a solution
2. I don't know the Syntax of IF THEN ELSE, in or outside of EVAL

Any help would be greatly appreciated

Yep, interesting Scenario... And not very difficult to implement...

Not sure what you mean by "inside/outside 'EVAL()'", 'IF/THEN/ELSE' (euh, there is no 'THEN' actually but it's implicit) is a JavaScript Command that runs "inside" 'EVAL()' yep..., or from a '.js' Script as you are on FF. But it's easy to write in pure '.iim', with say 9 Blocks repeated for the 'Add City' if you expect/know that a Route may contain Max 10 Cities:

1- You first compute the corresponding Value for '!DATASOURCE_LINE' from the Route_Nb input by the User with 'ADD' or 'EVAL()' to fetch the corresponding City/Cities in your '!COL12'.
2- 'EVAL()' + 'split(', ')' and the Length of the Array will tell you the Number of Cities.
3- With 'EVAL()' + 'split()', you return 'z[0]' for the 1st City.
4- You fill in that 1st City on the Page.

Now for each Block, you repeat 9 times:
5a- With 'EVAL()', based on the Nb of Cities, you return 'z[1]' for the 2nd City if it exists.
5b- With 'EVAL()', based on the Nb of Cities, you spit out a "1"/"0" to reuse in '5c':
5c- ... to reuse in '5c' for the 'TAG POS=n' on the 'AddRowButton'. ('TAG POS=0' won't do anything.)
5d- Using 'ADD' or 'EVAL()', you increment a Var (originally set to "1") with '5b' to reuse in 'ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{Var_5d}}_TextBox'.
5e- You reuse the same '5b' for 'TAG POS=n' on the '..._CityName{{Var_5d}}_TextBox'.

And you repeat [5a-5e] 8 times with 'z[2]' / 'z[3]' / etc... with of course '!ERRORIGNORE' and a short '!TIMEOUT_STEP' (=0).

That's it......! Nice Project, perfect Usecase indeed for using iMacros...! 8)
Post your final Script, I'll probably be able to improve/tune it a bit, or if you get stuck, but it's not very complicated... :wink:
Last edited by chivracq on Fri Sep 08, 2017 9:47 am, edited 1 time in total.
- (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...
chivracq
 
Posts: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: IF THEN ELSE to input varying Data from .CSV list

by Thrilling on Fri Sep 08, 2017 8:25 am

Works like a charm. Allow me to express my gratitude towards your continuous and kind help, from myself and from my team (who admittedly are watching me progress with more of a slight skepticism, rather than an understanding of the comfort and speed using macros means for our future work :roll: they'll know soon enough ).

Also: I don't think I'd have ever have thought of your line of solution. Amazing. Im still having a hard time wrapping my head around it, even after writing the code and understanding each individual step!

Code: Select all
VERSION BUILD=8970419 RECORDER=FX
TAB T=1
SET !DATASOURCE_DELIMITER ;
SET !DATASOURCE Russland.csv

SET !DATASOURCE_LINE 5
SET !VAR1 EVAL("var UserInput = \"{{!col10}}\"; UserInput")
ADD !Var1 1
SET !DATASOURCE_LINE {{!var1}}
SET !var2 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x.length; z;")
SET !var3 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[0]; z;")
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName1_TextBox CONTENT={{!var3}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[1]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>1){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>1){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
SET !var7 EVAL("var x = 1; x;")
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[2]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>2){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>2){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[3]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>3){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>3){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[4]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>4){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>4){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[5]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>5){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>5){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[6]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>6){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>6){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[7]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>7){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>7){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[8]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>8){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>8){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[9]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>9){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>9){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}
Thrilling
 
Posts: 20
Joined: Fri Aug 11, 2017 7:02 am

Re: IF THEN ELSE to input varying Data from .CSV list

by chivracq on Tue Sep 12, 2017 3:52 pm

Thrilling wrote:Works like a charm. Allow me to express my gratitude towards your continuous and kind help, from myself and from my team (who admittedly are watching me progress with more of a slight skepticism, rather than an understanding of the comfort and speed using macros means for our future work :roll: they'll know soon enough ).

Also: I don't think I'd have ever have thought of your line of solution. Amazing. Im still having a hard time wrapping my head around it, even after writing the code and understanding each individual step!

Code: Select all
VERSION BUILD=8970419 RECORDER=FX
TAB T=1
SET !DATASOURCE_DELIMITER ;
SET !DATASOURCE Russland.csv

SET !DATASOURCE_LINE 5
SET !VAR1 EVAL("var UserInput = \"{{!col10}}\"; UserInput")
ADD !Var1 1
SET !DATASOURCE_LINE {{!var1}}
SET !var2 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x.length; z;")
SET !var3 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[0]; z;")
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName1_TextBox CONTENT={{!var3}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[1]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>1){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>1){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
SET !var7 EVAL("var x = 1; x;")
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[2]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>2){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>2){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[3]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>3){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>3){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[4]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>4){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>4){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[5]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>5){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>5){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[6]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>6){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>6){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[7]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>7){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>7){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[8]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>8){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>8){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

SET !var4 EVAL("var Route = \"{{!col12}}\"; var x=Route.split(', '); var z=x[9]; z;")
SET !var5 EVAL("var x = \"{{!var2}}\"; if(x>9){x=\"{{!var4}}\";} else{x=0;}; x;")
SET !var6 EVAL("var x = \"{{!var2}}\"; if(x>9){x=1;} else{x=0;}; x;")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS={{!var6}} TYPE=INPUT:BUTTON FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_AddRowButton
SET !TIMEOUT_STEP 0
ADD !var7 {{!var6}}
TAG POS={{!var6}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_phBody_StepViewMVisitDetailsStep_Route_CityName{{!var7}}_TextBox CONTENT={{!var4}}

Yep, saw your Post before the WE but I think it was 17h30 for me (Amsterdam - NL) and I was a bit busy at that time preparing some DJ-Set (yep, I'm a DJ IRL, and WE's are usually a bit busy for me, ah-ah...!), and I think a few new Threads needed to be "moderated" at that time...

Woaw-woaw-woaw...!!, a wonderful BIG Compliment for your Script...!!
One Reply from me with some Guidelines and Ideas, and yep..., you manage to write the full working Script....!! Excellent...! :D :D
Good Learner, ah-ah...! :D

There are (of course) several "Things" that could be "improved" in your Script, but hum, you are such a quick Learner that I actually prefer not to say anything, you will discover the "Improvements" by yourself I would think, like I did myself, I never had anybody checking/improving my Scripts..., hum, because I never posted on the Forum for Advice/Pb I guess, or only once to report a REAL-BIG-BLOCKING-FUCKING Bug, reason why I joined the Forum (about 4 years ago), for which I only found a Workaround about 1 year ago...
=> And maybe post again in a few weeks your improved Version of your Script, as you discover "Things", and if you still keep working/improving (on) it... :idea:
But hum, I still have old Scripts that I made about 8 or 10 years ago (and that still work because I still use them once or twice a year), and I still love them, nearly mainly because of the "cute" Mistakes I made then, but if they still work...!? 8)

And about "... my gratitude towards your continuous and kind help...", ah-ah!, glad to help of course, but sbd like you who is able to write a Full Script with just a few "Indications" is very-very Rewarding for me as well, Thanks for the Feedback...!
And don't worry, you'll laugh at our Colleagues very soon (when they come to you to ask you to help them for a Script), believe me, ah-ah...! :wink:

Funnily enough, some new User today on the Forum only registered to be able to "fustigate" me (hum, Spellchecker doesn't like it...?, is normal English I would think...!?) => Spellchecker prefers "fumigate" (?) me (OK, why not...!? :shock: ) for my "Style for helping Users" on the Forum, ah-ah...! (I guess I can't please all the clever Souls in this World I'm afraid...! :wink: )
- (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...
chivracq
 
Posts: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: IF THEN ELSE to input varying Data from .CSV list

by Thrilling on Fri Sep 15, 2017 11:36 am

Thanks for the kind words :D I'm rather surprised myself that i managed to write that code with no hickups.

I came here with 0 knowledge of writing macros, as you know, and you really helped me jumpstart learning the basics. Don't listen to insultive people, they apparently don't appreaciate the virtue of patience and lack the insight to acknowledge the worth of outside help.

Wishing you all the best
Thrilling
 
Posts: 20
Joined: Fri Aug 11, 2017 7:02 am

Re: IF THEN ELSE to input varying Data from .CSV list

by chivracq on Fri Sep 15, 2017 2:07 pm

Thrilling wrote:Thanks for the kind words :D I'm rather surprised myself that i managed to write that code with no hickups.

I came here with 0 knowledge of writing macros, as you know, and you really helped me jumpstart learning the basics. Don't listen to insultive people, they apparently don't appreaciate the virtue of patience and lack the insight to acknowledge the worth of outside help.

Wishing you all the best

iMacros is probably the easiest Programming Language I have ever come across, you only need the Recorder which does already 80% of the "Job", a few Examples and the Demos and/or the Forum are perfect for that, the Documentation from the Wiki which is perfect as well (well, for 99%, ah-ah...!), and a little bit of "Creativity" and "Motivation" and you can do great Things with your Scripts... :wink:

The first time I discovered iMacros was for some funny Halloween Game and it took me maybe half an hour to write that fairly simple Macro while I sometimes see some Users struggling for 1 week for a similar Functionality in their Script... And that Script of mine still works, as I reuse it once a year for the same Game, even if I've improved/tuned it a little bit over the years... Hum, Halloween coming soon btw, ah-ah...!! :twisted:

Yep, I like helping Users who make Progress and try first to get their Script working but really get stuck... And I'm not sure I'm always "patient", ah-ah...!, especially with Users for whom mentioning 3 Versions about their Env. seems to be the most difficult Task they ever encountered in their Life, even after asking 3 times, grrr...! But OK, I usually give up then...

OK, I'm already curious what will be your next Thread, ah-ah...!
- (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...
chivracq
 
Posts: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to General Support & Discussions

Who is online

Users browsing this forum: Google [Bot] and 9 guests

-->