N-Dolphin User’s Guide
This document gives a brief overview of the buttons and keystrokes for N-Dolphin, covered roughly in the order you would encounter them during a typical class.
Note that N-Dolphin recognizes the mouse only for pressing buttons. Clicking on, or dragging over, the program text should have no effect. Use the arrow keys to select the part of the program you want to work with, and the buttons to transform the selection.
1 Stepping
When N-Dolphin is showing a complete python program without any un-initialized variables, stepping is usually the simplest way to get to the answer (this is also true for most debuggers, pythontutor, etc.).
1.1 Step in
When the current selection (the red text) is something N-Dolphin considers a single step, such as 7*20 or 5>100, the Step in button converts the selection to a simple value, such as 140 or False.
When Step in is applied to a variable use, the variable name is transformed into the initializing value or expression, if one is present. If the variable is not initialized, Step in has no effect.
When Step in is applied to something that is not a single step, such as a literal value such as 7, or a complex expression such as (3+4)*(28-8), N-Dolphin adjusts the selection to move toward the next single-step that would be executed, e.g., selecting the 3+4 within the (3+4)*(28-8), after which the next clicks of Step in would turn that 3+4 into 7, and then select the 28-8, since that’s what would be computed after the 3+4 in this example.
1.2 Step Over
The Step over button can be used to see the final result of an expression without having to watch every step.
For example, if we click Step over with the expression (3+4)*(28-8) selected, we’ll get right to the result, i.e., 140.
2 Selecting via the Arrow Keys
The four basic arrow keys on a standard keyboard can be used to adjust the current selection, in case you want to depart from the usual execution order.
Note that the current version of N-Dolphin has a few limitations, so some uses of arrow keys can cause the Python code to be replaced by an error message. As discussed in Section Display Bugs below, normally hitting up one or more times can remedy this problem (after that, trying Step in is often useful, or ask your instructor for help).
2.1 Basic code selection
The arrow keys control the selection as follows:
| up |
| select the expression that contains the current selection | |
| down |
| select the first expression within the current selection | |
| left |
| select the expression before current selection, within the same larger structure | |
| right |
| select the expression after the current selection, in the same larger structure |
For example, suppose we start with the code (3+4)*(28-8) already selected, perhaps just by hitting Step in to get there within a larger example, or because it’s the entire program. Hitting the down key would select the 3+4, and hitting down again would select 3; at this point, with the 3 selected, hitting up would go back to 3+4, whereas right would take us to the 4. With the 4 selected, left would take us back to the 3, up would take us to the 3+4, but right does nothing, since there’s nothing after the 4 within that 3+4, and down does nothing, because there’s nothing within the 4.
2.2 Order of execution vs. order in text, e.g., for if
The actions of the arrow keys are defined in terms of the order of parts of the expression, e.g., down taking you to the first sub-expression, and right taking you to the next. This order refers to the usual execution order, not the order you see things on the screen. Those are usually the same, but not always: Python’s if expression, like the if statement, normally runs the middle expression, i.e., the condition to be tested, before running either the true or false option based on that condition.
(9*8) if (4>5) else (6*12) |
if (4>5): |
return (9*8) |
else: |
return (6*12) |
For both of the above codes, the 4>5 is considered the first part, so down would select 4>5 if the entire code were selected, and you would need right to get from the 4>5 to the 9*8 in both forms; from the 9*8, right gets to the 6*12, and left to get from the 4>5.
2.3 Display Bugs
The current implementation of N-Dolphin has trouble displaying some specific sub-parts of some code, e.g., when trying to show only a variable initialization, without the subsequent code that uses the variable. Sometimes clicking arrow keys will cause N-Dolphin to select that un-displayable element, and then produce an error message about "selectionsplit needs update" where the python code would usually be displayed. In this case, try hitting up to select the entire code, and then Step in to let N-Dolphin pick the next part to show you.
3 Context-specific Buttons
The following sections will be filled in when Dave has a bit of time to do so (note that the button names may not even be quite right).