The editor
The editor is the area where you enter and modify your BASIC program.
BASin's editor is where you enter your program.
Program lines are automatically arranged in numerical order, no matter where they are entered.
Keyboard and mouse operations
BASin supports many standard navigation keys.
Like any other Notepad program, you can use the mouse and/or shift keys to make selections and cut/copy them to the windows clipboard. They will be stored in .bas format which can be pasted into any text editor. Pasting is a little different. A single line of text pasted in will be sent directly to the editor, but more than one line will be sent to the Add Code Window - where you can view the lines and change them as you wish. Multiple line pastes must each have a line number, and contain no syntax errors. If an error occurs when pasting the lines in, the offending line will be ignored and will not appear in your program. You can see the status of any errors in pasting by viewing the Log Window. This facility allows you to copy a BASIC program from say, a web page or text document, and paste it directly into BASin.
Right-clicking in the editor produces a context menu with commands relating to the item that was clicked.
How your program is formatted
The darker area at the left-hand side is the gutter, where line numbers are displayed. To aid debugging and make things easier to read, program lines that contain more than one statement are split on the : (colon) character, so that each statement begins on a new line of the display.
How BASin handles program lines
Program lines, as mentioned earlier, are stored in the editor in order, sorted by their line number. This makes the program easier to follow for the programmer.
BASin has a number of features to help you with your programming:
- The Coding Teacher
The coding teacher is a bar that appears at the bottom of the editor window, which tracks your code as you type and offers hints as to what the current codeword actually does, and it's syntax.
If you type an error, it will colour the relevant part of the syntax list red. The syntax that is currently expected is coloured blue, and any return types of codewords is in green. Error messages will appear at the bottom of the helper bar which explains what has gone wrong.
For more information, there is a chapter dedicated to the coding teacher.
- The Character Ruler
This option is available in the View menu, rather than the Options dialog.
The character ruler helps you to make long strings for display on-screen. Due to the nature of the PRINT keyword, a string longer than 32 characters will "wrap" round to the beginning of the next line down. This can be useful for displaying many lines of text with one PRINT. The character ruler will show you at a glance how long your string is, and a red marker will appear at any point where the 32 character boundary is reached. This activity will be activated whenever the cursor enters a string area in the BASIC text.
More information is available in the Character Ruler chapter.
- Line Overwrite Protection
BASin will not allow you to enter a line that contains a syntax error, and when you make one the cursor will move to the error and if you have sounds enabled, will emit a low pitched beep to alert you.
This behaviour is also used by the line-overwrite protection system which you can configure in the Options window, on the BASin tab. This, when enabled, will alert you when you try to enter a line for which a line already exists with the same number. The cursor will turn green, and the same low beep can be heard. In this instance, however, you do not have to correct the line number - pressing Return a second time will accept the new line and replace the old one.
- Auto line numbering
BASin has a shortcut (the "." key) which will create a line number for you. Pressing the "." key at the start of a new line will choose a line number roughly halfway between the previous line number (of the line directly above the current cursor position - Line 0 is assumed if you're at the start of the program) and the next line number if it exists. If no next line is present, then 10 is added to the previous line number. The "." will not be displayed - instead, your new line number will be typed out. This behaviour can be enabled or disabled in the Options window.
- Auto-Bracket completion
Finally, a word about typing expressions of the form
(a+(b/c))*3
Which make use of brackets - BASin has an option which can make counting many brackets easier - BASin can either insert a closing bracket as you type, ahead of the cursor, or can complete any open brackets when you press enter to finish a line.
- Syntax Highlighting
The text of your program can optionally colour in the text according to the type of words displayed.
This is called "syntax highlighting", and can make a program a lot easier to read and follow. Keywords, user defined functions, comments, numbers, symbols, strings, variables (BASin will colour variable names that exist in VARS memory space differently to those that do not, which can quickly show up typing errors where they may occur) and the background/foreground colours can all be altered in appearance, also to be set to bold or italics in style. Be aware that this requires quite a lot more effort to display by your CPU, so may slow the editor down on older PCs.
- Predictive typing
This option will display any keyword or variable name in dark grey to the right of your cursor as you type.
If you continue to type, the search for the correct word will be narrowed down - when you see the correct word displayed, hit the right cursor key, or the "." key to accept it. You can, of course, continue typing over the top. If you do not accept a word and press return, any predicted text will be removed.
- Source Markers
Source markers are a method of moving quickly around a large program. By inserting a source marker, you associate that marker with a particular line or statement. By recalling it later, you can jump instantly to that line. This makes navigation between important sections of code much easier. You can access source markers from the Search menu.
- Mode indicator
The mode indicator is a black strip that appears at the bottom of the editing area. It shows which type of spectrum your program is compatible with, based on commands that your program uses. It shows "48 BASIC" by default, until you use a 128k command, at which point it will show "128 BASIC". The Mode Indicator is visible at all times, and cannot be turned off.
Editor features