
IBM eNetwork Communications Server for Windows NT
Host Publisher Feature, Version 6.01
[Next|Previous|Contents]
Generalizing recorded macros
Once you understand how the macro language
works, you can begin improving the recorded macros from Host Publisher.
Screen recognition
Recorded macros check the screen cursor position to
identify a screen when they wait for a screen.
Using strings is a more flexible way to do this. You
can replace a macro sequence such as
screenDesc.Clear();
screenDesc.AddCursorPos(20,16);
ps.WaitForScreen(screenDesc,10000);
with
screenDesc.Clear();
screenDesc.AddString("USERID");
ps.WaitForScreen(screenDesc,10000);
to create a wait for a USERID prompt that does
not depend on the screen position where the prompt appeared.
The macro syntax section
describes the macro commands you can use for screen recognition.
Modifying input
Recorded macros always send exactly the same input. You
can modify the input based on Web form parameters or session
variables. See the prompt
macro command for more information. Replace
the ps.SendKeys macro command in your recorded macros
with prompt to send something
other than a fixed string to your host application.
Example 1
Suppose you record a macro that moves the cursor
to a field, enters some text, then moves to another field
and enters some more text. Later you decide that the text
placed in the first field should be variable.
The recorded macro looks something like this:
ps.SendKeys("[tab][tab][tab]refrigerator[tab][tab]sink[enter]");
The first [tab] keys move to the first field, the text
refrigerator is entered, more [tab] keys are
used to move to another field, sink is entered, then
the ENTER key is typed.
Begin by separating the text into multiple ps.SendKeys()
commands. The text that is to change should be in a single
command:
ps.SendKeys("[tab][tab][tab]");
ps.SendKeys("refrigerator");
ps.SendKeys("[tab][tab]sink[enter]");
Change the ps.SendKeys() command to a prompt
command. Use row and column positions of 0,0 to place the text
at the current cursor position. This example assumes the input
field from Host Publisher is named appliance, and
that appliance names are no more than 20 characters long.
ps.SendKeys("[tab][tab][tab]");
prompt(0,0,20,":appliance","",true);
ps.SendKeys("[tab][tab]sink[enter]");
When Host Publisher executes this macro, the prompt
command will send the current value of the Web form
parameter named appliance.
Example 2
If the input text will be in the middle of other text, ensure that the
cursor is positioned correctly after prompt places the text
on the screen. The prompt command does not move the cursor.
Suppose the recorded macro is
ps.SendKeys("lookup smith (options[enter]")
Change it to
ps.SendKeys("lookup ");
prompt(0,0,10,":name","",true);
ps.SendKeys("[right][right][right][right][right][right][right][right][right][right]");
ps.SendKeys(" (options[enter]")
This moves the cursor past the text supplied by prompt,
so the text sent by the next ps.SendKeys() does not write
over it.
[Next|Previous|Contents]
IBM eNetwork Communications Server for Windows NT
Host Publisher Feature, Version 6.01