How can I perform calculations in a macro?
Top  Previous  Next

Q: How can I do calculations in a macro?

A: For very simple calculations, iMacros offers the ADD command.

But instead of doing calculations in the macro, you can perform the calculations inside a script (e.g. Visual Basic Scripting, VBS). This allows you to use all kinds of more sophisticated calculations, loops (e.g. for....next loops) or conditional logic (e.g. if/then) for automating your web tasks. You can then use iimSet of the Scripting Interface to send values to a macro and the
EXTRACT command to return values from a macro to the script.

The file
random-numbers.vbs demonstrates how to use a script to generate random numbers and modify the macro based on the outcome. Or, see the file extract-and-fill.vbs on how to extract a value, subtract a number from it and re-submit the new value to the website.

Note that VBS files are not started from within the iMacros Browser. You can locate the file (e.g. via Explorer) and then simply double-click on the VBS file. Windows will then start to process the VBS file. The iMacros Browser is started by the VBS file via the
iimInit command automatically.

More information about VBS files can be found in our online Windows Scripting Host tutorial
or in this manual.



Page URL http://www.iopus.com/imacros/help/faq_calculations.htm