Dr. Java

Record/Playback of Sequences of Interactive Steps

 

One of the most compelling features of Dr. Java as a development environment is the Interactions Pane and through that, the ability to execute any valid sequence of Java statements as well as evaluation of Java expressions.  You can use the interactions pane to develop sequences of Java statements to accomplish some task.  PDF documentation specific to the interactions pane is available here, and the user’s guide for all of Dr. Java is available here.

 

The Interactions Pane may also be used as a sort of macro facility, with the ability to record the sequence of Java statements entered into the Interactions Pane and then the ability to replay those Java statements at a later point in time.  Also helpful is the ability to bring the recorded sequence of statements into the Definitions Pane for inclusion in method definitions.

 

To Record

 

First note that Dr. Java is always recoding the sequence of Java statements and expressions entered into the Interactions Pane.  This recoding does not carry over between activations of the Dr. Java application, so each time the application is launched, the recording buffer and the set of variable and object definitions associated with the Interactions Pane is empty.  Consider this the start point of the recording.

 

If, however, the Dr. Java application has already been launched and the user has been executing statements in the Interactions Pane, the user may wish to “start fresh” and define a new start point for a recording.  This is done with two steps. 

 

  1. Select Reset Interactions from the Tools menu to clear all definitions of variables and objects in the Interactions Pane, and then
  2. Select Clear Interactions History to wipe the recording buffer of statements and expressions.

 

You may then begin executing the sequence of Java statements that you want to record.

 

To save/record to a file all interactions between the start point and the current point in time, simply select “Save Interactions History …” from the Tools menu.  This will give you the opportunity to edit the set of Java statements prior to the save to a file.  Answering “No” in this dialog box will bring up the save dialog, while “Yes” will bring up a simple editor window, whereby you can modify the statements to be saved.  The saved history file has a “.hist” extension, and is simply a text file.

 

To Playback

 

The playback of a sequence of steps is accomplished by selecting “Execute Interactions History …” from the Tools menu.  A couple of cautions, however. 

 

  1. First, the statements will be executed from start to finish, without interruption.  If you desire a manually controlled step-by-step replay, you can instead select the “Load Interactions History as Script …” item from the Tools menu.  This will add buttons to the Interactions Pane to allow stepping through the sequence of statements.
  2. Second, the replay of statements is executed in the current context, with whatever variables and object definitions are currently in effect.  This means that if a variable is declared and assigned as part of the interactions history, it should not already have a definition in the Interactions Pane.

 

My recommendation to avoid problems is to include all declarations and definitions as part of the recorded sequence, but then to select “Reset Interactions” from the Tools menu prior to playback or to restart the application before playback.