Cutting, Copying, and Pasting
Every text editor worthy of the name enables you to select text blocks and manipulate them in various ways. QBasic's editor also provides you with these handy functions. You can find the text-editing functions in the Edit menu, shown in Figure 3.10.
Figure 3.10 QBasic's Edit menu text.
Point of Interest
You can access edit functions directly from the keyboard, without using the Edit menu, by pressing the keys shown in the Edit menu. For example, to cut a block of text, press Shift+Del. To Paste the cut text back into your program, press Shift+Ins. Once you learn these shortcut keys, you can select editing functions quickly and conveniently.
Before you can use editing functions, you must select the text that those functions will manipulate. Figure 3.11 shows what a selected block of text looks like.
Figure 3.11 Selected text.
As with most functions, you can select text using either your keyboard or your mouse. You can also select text by pointing to it with your little finger and saying "Select this text," followed immediately by the magic words "Please," "Thank you," and "Shala-bama-dingo." Unfortunately, this latter method rarely works.
To select text from the keyboard, first use the arrow keys to place the blinking text cursor anywhere on the first line of the text block. Then hold down the Shift key and press the down-arrow key to highlight the lines in the block. Each time you press the down arrow, you highlight another line of text.
To select text with your mouse, place the mouse pointer on the first line you want to select, hold down the left mouse button, and drag the mouse pointer to the last line in the block.
Try selecting some text now. Using either the keyboard or mouse technique, select the middle three lines of your program's text. After selecting the text, open the Edit menu. The Cut, Copy, and Clear menu commands are now enabled. The Cut command removes the highlighted text from the screen and places it into QBasic's clipboard (a special text buffer from which you can later paste the text back into a different location in your program). The Copy command also places the selected text into the clipboard, but it does so without removing the text from the screen. Finally, the Clear command removes the selected text from the screen but does not place it into the clipboard.
Danger Ahead!
When you select the Clear entry of the Edit menu, any text you have highlighted is deleted foreverso use this command with care.
For now, select the Copy command. When you do, the Edit menu closes, and you're back at QBasic's edit window. Everything looks the same, except a copy of the highlighted text is now stored in QBasic's clipboard.
To use the clipboard, first deselect the selected text block by pressing any arrow key on your keyboard or by clicking your left mouse button. (Actually, you should click your mouse's left mouse button. If you have a left mouse button, consult a surgeon immediately and have it removed.) Look at the Edit menu again. Because there is no longer a text block selected, the Cut, Copy, and Clear entries are no longer enabled. However, the Paste entry is enabled. This tells you that there is text in the clipboard. In this case, it's the text you just copied. Close the Edit menu, place the blinking text cursor on the first blank line below your program, and select the Paste command. The text you copied is pasted into your program at the text cursor's location, as text shown in Figure 3.12.
Figure 3.12 After pasting text into your program.
Cool Stuff
If you select the Paste command when you have a text block highlighted onscreen, the text in the clipboard replaces the highlighted text. Similarly, if you start typing when you have a text block highlighted, whatever you type replaces any and all of the highlighted text.
Before moving on to the next section, restore your program to its original state; you can do this either by deleting the extra lines you just pasted into it or by reloading the PROG1.BAS file. To delete a line, place the text cursor on the line and press Ctrl+Y text.