Hot Keyboard

macros for Windows

Automate Windows with macros
Main Download Purchase Support

2.17 Evaluate Expression

<< Previous | Table Of Contents | Next >>

With this macro, you can modify value of a variable.

Let's start with an example: we need to generate links to add them into e-mail messages on a regular basis:

http://www.myshop.com?item=123
http://www.myshop.com?item=124
http://www.myshop.com?item=125
http://www.myshop.com?item=126
http://www.myshop.com?item=127

The problem is that each time the first ID is different and should be defined manually.

Here's the solution

modvar_macro.gif

It contains two Evaluate Expression macros. The first one asks for the new start id and saves it to $startid variable.

modvar_macro_2.gif
Then the loop Links starts, which does the following:
  1. Pastes http://www.myshop.com?item=<ID>
  2. Increments $startid
  3. modvar_macro_3.gif
  4. Delays for 0.2 seconds (to make sure destination application accepts the text insertion)

Action Parameters:

Expression to evaluate - you can put here scripting functions, the whole expression returns the value of the last function or operator. For example:

SetVar($myvar, InputBox("Enter variable:"))
cos($myvar)
returns cosine of entered value.

In Evaluate Expression macro you can use GoTo function, thus making loops, for example:

label:
SetVar($msg, InputBox("Enter Email"))
iif ( (StrFind ($msg, "@") < 0), ( GoTo "label" ), (1) )
MessageBox($msg)

The code above will ask you for the text string unless it contains "@" char.

Iteration limit - limits the number of GoTo jumps while evaluating the expression in order to avoid infinite loop

See also:

<< Previous | Table Of Contents | Next >>

  © 1998-2016 Imposant