The Editor Window

The Editor allows you to edit BASIC code. The gadgetry in the upper part of the window allows you to select a routine to edit, create a new routine, or set a breakpoint in a routine. The white area in the lower part of the window is a text editing window where you may edit a routine's BASIC code.

Choosing an Event Handler or Routine to Edit

If you wish to edit the contents of one of a component's event handler, choose

the component's name from the Editor window's Components list.
the appropriate event name from the Events list.

The appropriate event handler routine will appear in the text editing area. For instance, suppose your program has a button with the name "button1." If you choose button1 from the Editor window's Components list, then choose clicked from the Events list, the button1_pressed() subroutine should appear. Assuming you haven't entered any BASIC code for that handler yet, it will look like

SUB button1_pressed( self AS integer )

END SUB

To edit an existing routine that is not an event handler, select its name in the Editor window's Routines list. You can also select previously edited event handlers from this list.

Creating a New Routine

As discussed in See Organization of BASIC Code , there are two types of routines: functions, which return values; and subroutines, which do not.

To create a new function

Press the Editor window's New Function button. The Editor's text edit area will be updated to show an empty function:

FUNCTION

END FUNCTION

Add the function's name, arguments, and return value to the function declaration.

For example:

FUNCTION Squared( x AS float ) AS float

END FUNCTION

To create a new subroutine

Press the Editor window's New Subroutine button. The Editor's text edit area will be updated to show an empty subroutine:

SUB

END SUB

Add the subroutine's name and arguments to sub declaration:

SUB UpdateButtonCaptions( baseText AS string )

END SUB

Deleting and Renaming Routines

To delete a routine, select its name in the Routines list and press the Delete Routine button.

To rename a routine, complete the following steps:

Select its name in the Routines list and wait for its text to appear in the text window.
Change the routine's name on the top line of the Routine.
Choose another routine's name in the Routines list.
Delete the old routine name.

Setting and Un-setting Breakpoints

Breakpoints are used when debugging; we will not discuss them in depth here. For information about using breakpoints, see See Breakpoints: Pausing in Routines .

Pressing the Toggle Breakpoint button causes the selected line (if any) in the Editor window's text edit area to set a breakpoint on that line, or to un-set an existing breakpoint on that line.

If a line of BASIC code has a breakpoint set upon it, it will appear with a red background (dithered black and white in black-and-white mode) in the Editor window text area.

Editing and Reading a Routine's BASIC Code

Once you've selected (or created) a routine, its BASIC code appears in the Editor window's text edit area.

When you view routines, some lines of BASIC code may be drawn with a colored background.

If you are running your program from the Builder, you won't be able to edit any routines until you stop it by pressing the Stop button. However, you can still look at routines and set breakpoints.

When you edit routines, only the text between the first and last lines of the routine will be preserved; other text will be lost.

SUB button1_pressed( self AS component )
REM User has clicked the "Go!" button.
REM Reset the score value.

number1.value = 0
END SUB
REM This comment will be lost; it's not inside a routine.

Keyboard shortcuts

There are some keyboard shortcuts to quicken some common editing tasks:

Keystroke

Resulting Action

Ctrl+A

Position cursor at stArt of line.

Ctrl+D

Delete the character after cursor.

Ctrl+E

Position cursor at End of line.

Ctrl+K

Kill text between the cursor and the next carriage return.

Ctrl+N

Move cursor down one line (to the Next line).

Ctrl+P

Move cursor up one line (to the Previous line).