With Rocket TE Scripts, you can create variables that can be utilized in a Rocket TE
script.
Rocket TE Scripts supports the ability to create up to four variables. If you define more than
four variables, the fifth variable will override the first, the sixth will override the second,
and so on. For example, given the variables InputStr1, InputStr2, InputStr3, InputStr4, and
InputStr5, the value of InputStr1 will be overridden by InputStr5. To create more than four
variables, you can structure the script to prompt for input when needed, rather than prompting
for all input at the beginning of the script. Alternatively, you can use the more modern
Rocket TE Basic script type (recommended).
There can be many uses for variables. For example, if
you want to create a Rocket TE script (.bzs) to
automate the log on process for several host systems, or log on to
several sessions on the same host, you can create a Rocket TE script
with a variable for user name (InputStr1) and a variable
for password (InputStr2) by using the Rocket TE "Input"
script event. Then the script passes the values of InputStr1 and InputStr2 to
additional host sessions through the Rocket TE command line switch
feature and uses the stored values to automatically log on to additional
hosts.
Rocket TE script exercise
The following Rocket TE
scripting exercise assumes that you are already familiar with Rocket TE
and somewhat familiar with Rocket TE scripting.
This exercise
creates a Rocket TE script that prompts the end user for user name
and password, then uses the values of user name and password to log
onto an iSeries host. Then, the script automatically launches a second
iSeries host session and passes the values of user name and password
to the second iSeries host session. A script automatically runs on
the second iSeries host which uses the values of user name and password
to log onto the second host.
By using this technique, the
end user is prompted to enter their user name and password only once,
at the very beginning of the script, and the script inserts the user
name and password values at the correct point for each host.
Preparing two Rocket TE iSeries Display sessions
- Launch two Rocket TE iSeries display sessions.
- Configure the sessions to connect to the same or two different
iSeries hosts.
- Save the first session to a file called session1.zad.
- Save the second session to a file called session2.zad..
Creating the first Rocket TE script
- Launch the Rocket TE Script Editor and start creating a new script
as follows.
- In the Script Events list, double-click the Input event.
The Input dialog opens.
- Type InputStr1 in the Title field, followed
by the text that you want to appear when the end user is prompted.
For example, type Enter your user name.
- Click OK to enter this event into the script.
- Repeat the process to create an input box for the end users password
as shown here. For the password event, check the Hide
Input as User Types check box.
- Click OK. So far, your script looks like this:
- In order to send the value of InputStr1 to
the host, use the Type event. In the Script Events list,
double-click the Type event.
The
Type dialog displays.
- Type InputStr1 and click OK to
add it to the script as shown above.
- The next step in the log on process is to send a Tab function.
This advances the cursor to the Password field.
- To add a Tab to the script, in the LU Functions list,
double-click the Tab / Field Advance function.
This adds the Tab / Field Advance function to the script.
- The next event is to pass the value of the end user's password.
This is accomplished by sending a Type InputStr2 to
the host, in the same way we sent the value of user name above.
- In the Script Events list, double-click
the Type event.
The Type
dialog displays.
- Type InputStr2.
- Check the Encrypt and Hide check box.
- Click OK to add it to the script.
- The final step in the log on process is to send an Enter function.
This completes the log on sequence:
- In the LU Functions list, double-click
the Enter function.
The
Enter function is added to the script.
- Launch a second iSeries display session. This is accomplished
by using the Run event. We will create a Run
event that calls the correct program, and uses command line switches
to set the configuration file to use, and to pass along the InputStr1
and InputStr2 values to the second iSeries session.
- In the Script Events list, double-click
the Run event.
The Run
dialog displays.
- Type the following in the command line:
C:\Program Files\BlueZone\BZAD.EXE /Fsession2.zad /1InputStr1 /2InputStr2
- Click OK to enter this event into the script.
This command line launches a Rocket TE iSeries display
session, use the configuration file named session2.zad,
and send the values of InputStr1 and InputStr2 to the new iSeries
session.
- Click OK.
- Save the script and name it script1.bzs.
So far, we have created a script that prompts the end user
for user name and password, automatically logs on to an iSeries session
using the stored values of user name and password, and automatically
launches a second iSeries session.
The next step is to create
a second Rocket TE script that uses the values of InputStr1 and InputStr2 from
the first script, to automatically log on to the second iSeries host.
Creating the second Rocket TE script
- Create a second Rocket TE script by selecting New from
the Rocket TE Script Editor menu.
You now have
a blank screen in which you can create a new script.
- It is recommended to start with a Wait event in order to give
the new session some time to bring up the main log in screen.
- In the Script Events list, double-click the Wait event.
- Type the number of seconds to wait. For example, 2.
- Click OK.
- Add a Type event:
- In the Script Events list, double-click the Type event.
The Type dialog displays.
- Type Var1.
- Click OK to add this to the script.
So far, your script looks like this:
- In the LU Functions list, double-click the Tab / Field
Advance function.
- Add a Type event:
- In the Script Events list, double-click the Type event.
- Type Var2.
- Click OK.
- In the LU Functions list, double-click the Enter function.
Your script now looks like this:
- Save this script and name it script2.bzs.
You must now configure the second iSeries session to automatically
launch this script upon connection to the host, which uses the value
of
Var1 for the user name, and the value of
Var2 for
the password.
Note: Var1 relates to the \1InputStr1 and Var2 relates
to the \2InputStr2 that is used in the command line switch that launched
the second iSeries display session.
Configuring the second iSeries session to automatically
launch Scritpt2.bzs
- Launch the second iSeries display session.
- Click from the Rocket TE menu bar.
- Check the Auto-Play Script on Connect check
box.
- Click Browse.
- Select the script2.bzs file and click Open.
- Click OK to exit this dialog.
- Save the iSeries configuration. Make sure you save it as session2.zad.
Testing the script
At this point you are
ready to test the completed script.
- To test the script, start the first iSeries session and connect
to the host.
- Click from the Rocket TE menu bar.
- Select the script1.bzs file and click Open.
The script immediately starts running. The Enter
Username dialog opens:
- Type your user name and press the Enter key.
The
Enter Password dialog opens:
- Type your password and press the Enter key.
The
script continues to run and you are logged onto the host. Then the
second iSeries session launches and you are logged onto the second
host.
Tips: You can assign the script1
to a Rocket TE power key which makes it much easier for the end user
to launch a script. Refer to Mapping scripts to power pads for
more information.
You can adjust the speed of the script playback.
When you are developing a script, sometimes it's helpful if the script
runs at a slow speed so you can see exactly what is happening.
Speed
up the script and turn off the Script Status Window. Once the script
is completely debugged and working properly, you may want to speed
up the script execution speed and also turn off the Script Status
Window. This is done by selecting from the Rocket TE
menu bar and making any desired changes. Refer to Script properties for more information.