IF THEN ELSE commands
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
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
IF THEN ELSE commands
i've tried to find a solution for my current macro, I have a csv with some information I want to use if command based on value of the csv file.
FIREFOX 44.0.2
OS Windows 10
IMACRO VERSION BUILD=8961227
'URL GOTO=https://website.com/asp.aspx
SET !DATASOURCE "MY CSV FILE LOCATION"
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
IF {{!COL6}} = C
THEN
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_cbCancel CONTENT=YES
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_ddlCancelReasons CONTENT=%55
ELSE
IF {{!COL6}} = N
THEN
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_cbCancel CONTENT=YES
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_ddlCancelReasons CONTENT=%1
ELSE
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbConfirm CONTENT=YES
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtVehicleID CONTENT={{!COL6}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtDriverID CONTENT={{!COL7}}
FIREFOX 44.0.2
OS Windows 10
IMACRO VERSION BUILD=8961227
'URL GOTO=https://website.com/asp.aspx
SET !DATASOURCE "MY CSV FILE LOCATION"
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
IF {{!COL6}} = C
THEN
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_cbCancel CONTENT=YES
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_ddlCancelReasons CONTENT=%55
ELSE
IF {{!COL6}} = N
THEN
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_cbCancel CONTENT=YES
TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_ddlCancelReasons CONTENT=%1
ELSE
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbConfirm CONTENT=YES
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtVehicleID CONTENT={{!COL6}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtDriverID CONTENT={{!COL7}}
Last edited by dcaba79 on Fri Mar 18, 2016 1:34 pm, edited 3 times in total.
Re: IF THEN ELSE commands
FCIM...! (Always mention your FCI when you open a Thread...)dcaba79 wrote:i've tried to find a solution for my current macro, I have a csv with some information I want to use if command based on value of the csv file.
Code: Select all
VERSION BUILD=8940826 RECORDER=FX 'URL GOTO=https://website.com/asp.aspx SET !DATASOURCE "MY CSV FILE LOCATION" SET !LOOP 2 SET !DATASOURCE_LINE {{!LOOP}} IF {{!COL6}} = C THEN TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_cbCancel CONTENT=YES TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_ddlCancelReasons CONTENT=%55 ELSE IF {{!COL6}} = N THEN TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_cbCancel CONTENT=YES TAG POS=1 TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_{{!COL14}}_ddlCancelReasons CONTENT=%1 ELSE TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbConfirm CONTENT=YES TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtVehicleID CONTENT={{!COL6}} TAG POS=1 TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtDriverID CONTENT={{!COL7}}
Many-many Threads on the Forum about 'IF THEN ELSE'...
Normal way to achieve some Conditional Behaviour with iMacros is to put the Conditional Logic in a (main) '.js' Script...
But in your Case, but only 2-3 Statements per Condition and they are relatively similar, you could easily use 'EVAL()' (+ 'case' or 'if else') to spit out a "1" / "0" to use for 'POS=n' per Block/Condition and/or the '_cbCancel'/'_cbConfirm' etc Strings to use for the 'TAG' Statements. (+ '!ERRORIGNORE' and a short '!TIMEOUT_STEP'.)
Search my Posts on 'Conditional Behaviour" for more Info and Examples if you want to go this way... (You have a Thread called "Decision making... etc" in the 'Howto's: Useful Macros' Sub-Forum where I explained the Technique and maintain a List of useful Threads with interesting Examples...)
- (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...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: IF THEN ELSE commands
I will give this a try, got a idea of what you are saying, I will create something with eval to activate only the lines need according to the results .
Re: IF THEN ELSE commands
Well, good luck and post your final Script once you've got it working or if you get stuck somewhere and I will probably be able to improve/tune it a bit... Well, if you mention your FCI, I won't follow up otherwise... Read my Sig...dcaba79 wrote:I will give this a try, got a idea of what you are saying, I will create something with eval to activate only the lines need according to the results .
Because I see that you've tried to comply a bit with "FCIM", but your FCI is still not complete and actually a bit unclear:
You don't mention your FF Version at all...Browser is firefox
OS Windows 10
VERSION BUILD=8940826 RECORDER=FX
Your Script mentions v8.9.4 but I would actually be a bit surprised if you are really (still) using this Version as it is already a few months old and only works/worked until FF42, while we are currently at FF44/45...
- (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...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: IF THEN ELSE commands
Thank you chivracq I figured it out had to do a bit of working modifing the script as javascipt is a language I'm not to familiar with this is my final code , i would like a way not to have to write p on the csv that if the C OR N isn't found do the last part of the script
'CANCELS
SET !VAR1 EVAL("if (\"{{!COL13}}\" == \"C\") {var x=1}; x;")
TAG POS={{!VAR1}} TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbCancel CONTENT=YES
TAG POS={{!VAR1}} TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_ddlCancelReasons CONTENT=%55
'NO SHOWS
SET !VAR2 EVAL("if (\"{{!COL13}}\" == \"N\") {var x=1}; x;")
TAG POS={{!VAR2}} TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbCancel CONTENT=YES
TAG POS={{!VAR2}} TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_ddlCancelReasons CONTENT=%1
'PICKUPS
SET !VAR3 EVAL("if (\"{{!COL13}}\" == \"P\") {var x=1}; x;")
TAG POS={{!VAR3}} TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbConfirm CONTENT=YES
TAG POS={{!VAR3}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtVehicleID CONTENT={{!COL6}}
TAG POS={{!VAR3}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtDriverID CONTENT={{!COL7}}
'CANCELS
SET !VAR1 EVAL("if (\"{{!COL13}}\" == \"C\") {var x=1}; x;")
TAG POS={{!VAR1}} TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbCancel CONTENT=YES
TAG POS={{!VAR1}} TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_ddlCancelReasons CONTENT=%55
'NO SHOWS
SET !VAR2 EVAL("if (\"{{!COL13}}\" == \"N\") {var x=1}; x;")
TAG POS={{!VAR2}} TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbCancel CONTENT=YES
TAG POS={{!VAR2}} TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_ddlCancelReasons CONTENT=%1
'PICKUPS
SET !VAR3 EVAL("if (\"{{!COL13}}\" == \"P\") {var x=1}; x;")
TAG POS={{!VAR3}} TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbConfirm CONTENT=YES
TAG POS={{!VAR3}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtVehicleID CONTENT={{!COL6}}
TAG POS={{!VAR3}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtDriverID CONTENT={{!COL7}}
Re: IF THEN ELSE commands
dcaba79 wrote:Thank you chivracq I figured it out had to do a bit of working modifing the script as javascipt is a language I'm not to familiar with this is my final code , i would like a way not to have to write p on the csv that if the C OR N isn't found do the last part of the script
Code: Select all
'CANCELS SET !VAR1 EVAL("if (\"{{!COL13}}\" == \"C\") {var x=1}; x;") TAG POS={{!VAR1}} TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbCancel CONTENT=YES TAG POS={{!VAR1}} TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_ddlCancelReasons CONTENT=%55 'NO SHOWS SET !VAR2 EVAL("if (\"{{!COL13}}\" == \"N\") {var x=1}; x;") TAG POS={{!VAR2}} TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbCancel CONTENT=YES TAG POS={{!VAR2}} TYPE=SELECT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_ddlCancelReasons CONTENT=%1 'PICKUPS SET !VAR3 EVAL("if (\"{{!COL13}}\" == \"P\") {var x=1}; x;") TAG POS={{!VAR3}} TYPE=INPUT:CHECKBOX FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_cbConfirm CONTENT=YES TAG POS={{!VAR3}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtVehicleID CONTENT={{!COL6}} TAG POS={{!VAR3}} TYPE=INPUT:TEXT FORM=ID:aspnetForm ATTR=ID:ctl00_cphMainContent_rpAttestation_ctl{{!COL14}}_txtDriverID CONTENT={{!COL7}}
Code: Select all
FIREFOX 44.0.2
OS Windows 10
IMACRO VERSION BUILD=8961227
Your Script looks good, I'm impressed...! And you are nearly the first one to understand my Technique a bit directly...!
About your 'P' Condition, simply use:
Code: Select all
SET !VAR3 EVAL("if ('{{!COL13}}' != ('C'||'N')) {var x=1}; x;")
- (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...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: IF THEN ELSE commands
Yeah the your script idea briliant , thank you for you help .
Took some trial and error. I found it helpful to run it without the SET !ERRORIGNORE to see where it was failing once everything was correct I activated the SET !ERRORIGNORE and we are we at no. It works flawless. Thanks again
Took some trial and error. I found it helpful to run it without the SET !ERRORIGNORE to see where it was failing once everything was correct I activated the SET !ERRORIGNORE and we are we at no. It works flawless. Thanks again
Re: IF THEN ELSE commands
Yep, always deactivate '!ERRORIGNORE' and use 'PROMPT' when trying to debug your Script, I've got some 'PROMPT''S that are 3 Screens large, well the Statement, not the Content of the Prompt, ah-ah...!dcaba79 wrote:Yeah the your script idea briliant , thank you for you help .
Took some trial and error. I found it helpful to run it without the SET !ERRORIGNORE to see where it was failing once everything was correct I activated the SET !ERRORIGNORE and we are we at no. It works flawless. Thanks again
Yep, don't worry, all my Ideas are "Brilliant", that's why I'm answering so many Threads, but it's just a Question of a little bit of Creativity, and I have the Feeling you are picking up very quickly and are soon going to help me...
(Meant as a Compliment, as I said, I think it's the first time in 3 years that I've been a bit active on this Forum and sometimes giving Solutions using my Method, which is not the "Standard' Method, even if TechSup copied my Main Thread where I explained it recently to some 'Howto' Sub-Forum which is finally some kind of Recognition..., that sbd understands it so quickly..., so...,well, glad to welcome you...!)
>>>
Oh..., but you should post your Final Script, to finish your Thread a bit neatly, for other Users to see what was the original Script and what is the Final (better working) 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...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...