The renewal maintenance has officially ended for Progress iMacros effective November 30, 2023.
This Wiki site will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely, The Progress Team
EVAL
Jump to navigation
Jump to search
This command allows you to evaluate values, and trigger macro errors if certain conditions are met. It can can also be used to convert and modify extracted content. Inside EVAL, you have the full power of Javascript available!
Example uses:
- Detect if e. g. date is "older than 40 days"
- Detect if a number, e. g. exchange rate is above/below a certain value
- Make small clean-up operations. If the extracted text is "US$33.33" you might remove the "US$" part before saving it via SAVE TYPE=EXTRACT
Syntax
SET !VAR1 EVAL("[javascript statements]")
Parameters
None
Examples
Wait for a random time (1 to 10 seconds) after a page is loaded:
SET !VAR1 EVAL("var randomnumber=Math.floor(Math.random()*10 + 1);") URL GOTO=http://www.iopus.com ' waits 1 to 10 seconds WAIT SECONDS={{!VAR1}}
Save EUR rates in USD only if it is above a certain threshold (1.35 USD). If it is below, stop the macro and give an error:
VERSION BUILD=7501678 TAB T=1 TAB CLOSEALLOTHERS URL GOTO=http://www.xe.com/ucc/convert/?Amount=1&From=EUR&To=USD SET !EXTRACT_TEST_POPUP NO TAG POS=1 TYPE=TD ATTR=TXT:*<SP>USD&&WIDTH:46%&&ALIGN:left EXTRACT=TXT SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; s.replace(\"USD\",\"\"); var d=parseFloat(s); if(d < 1.3){MacroError(\"Euro is below 1.3 USD.\");} else d;") SET !EXTRACT NULL SET !EXTRACT {{!VAR1}} SAVEAS TYPE=EXTRACT FOLDER=* FILE=EuroRate.csv