To see the value of position, click on the Evaluate toolbar button, or right-click on the variable and choose the Evaluate variable item from the context-menu - since this is a context-sensitive menu, it will actually read "Evaluate position". In either case, the opens the Evaluate dialog containing two data entry fields. The variable name position should be automatically filled in the Variable Name field, and the content of the variable shown in the Value field. In this case, position is expected to contain 3, and it does. There is no error so far. To return from the pop-up window to the main part of the debugger, click on the Close button or press ESCAPE.
The next few lines are supposed to remove the word from the beginning of the line and put the word into SecondString$. To check if that routine functions correctly, you should examine the values of FirstString$ and SecondString$ before and after the routine alters them. The debugger should display:
To be or not to be; that is the question.
From the appearance of the string, you can see that the first blank should appear in position 3, and that the program has correctly determined that position. The variable SecondString$ ought to contain the last word processed and should have no value yet. You can check that by entering SecondString$ in the Variable Name field; if you do, you will find no error.
Everything seems normal so far. Press ESCAPE to return to the main part of the debugger, then press F8 to step the program one more line. Since you already know position is not 0, you'll find out what you need to know by pressing F8 several more times, stopping when the execution bar is over the final END IF of that routine. At that point, both FirstString$ and SecondString$ have been processed.
Once more, evaluate SecondString$. This time, SecondString$ does contain data: the word "To". This seems correct. When you ask to see the value of FirstString$, though, you get a surprise: FirstString$ has not been changed at all! This explains the lockup for the first line; subroutine GetAWord was correctly supplying the first word, but was not removing that first word from the entry string. Therefore, the first line never actually became shorter, so it was being processed and reprocessed endlessly.
To correct the bug, exit the debugger and insert a routine in the editor that shortens FirstString$ by the length of SecondString$. Insert a line reading something like:
FirstString$ = MID$(FirstString$, position + 1)
…immediately before the END IF in GetAWord. Make this correction, then save it. Click on the Compile and Debug icon in the toolbar and run the program through the debugger again.
Next See: Summary
See Also