www.riscos.com Technical Support: |
|
Under RISC OS 3 Edit can be used as a BASIC program editor. It automatically converts BASIC programs into text format for editing, and then converts them back again when they are saved.
For full details of editing files using Edit see The RISC OS Applications Guide.
Edit can convert Text files produced in Edit to tokenised BASIC files.
To write a new program, click Menu over the Edit icon on the icon bar and from the Create menu choose BASIC. You can now type your program directly into an Edit window. There is no need to include line numbers, as Edit will insert them for you when you save the file. Press Return at the end of the last line of the program.
To use Edit for working on an existing BASIC program, simply drag the program's icon from its directory onto the Edit icon on the icon bar.
Pressing Menu on the Edit icon bar icon displays a menu containing the Edit options. Moving to the BASIC Options submenu displays the following options:
Converting a text file to a tokenised file is usually quite straightforward. If there are no line numbers, Edit will start at 10 and increment by 10. If line numbers are supplied, these are used as a basis for any lines without line numbers.
Warnings
If there are line numbers, Edit will not sort them into ascending sequence and the resulting BASIC program may behave very strangely.
If your code is incomplete, Edit will warn you about the following problems:
In all cases Edit will also quote the offending line number. After you have clicked on OK, the tokenising continues.
Attempts to tokenise a crunched program (e.g. one with the spaces removed) will generally result in a non-functioning program.
If you have Edit running, you can print a BASIC program on paper by dragging its icon onto a printer driver icon. Edit will perform the conversion to allow the program to be printed.
The BASIC screen editor allows you to move around and change any part of a program currently loaded in the computer.
The editor is supplied as a module with the RISC OS 2 Applications suite. Before you can use it, first insert the App2 disc into drive 0, then load it by double-clicking its icon from the desktop. This only has to be done once, unless you switch the machine off or press Ctrl-Break. You can also load the editor from the command line, by typing the following:
*RMLOAD adfs::0.$.Modules.BasicEdit
To enter the screen editor from BASIC type
and press Return.
This command enters the editor with the current BASIC program displayed.
If you have previously been editing the program, and you type
EDIT .
the editor tries to re-enter it at the point at which you left it. If you have changed the program from within BASIC, it may not be possible to maintain the position, in which case editing starts from the top of the program.
If you wish to enter the editor at a particular point, such as line 100, type
EDIT 100
The editor starts with line 100 displayed at the top of the screen. If line 100 does not exist, the editor chooses either the next line or the end of the program, whichever comes first.
You may wish to enter the editor with the first occurrence of a particular piece of text at the top of the screen. For example:
EDIT three
The editor displays the program starting with the first occurrence of the word three at the top of the screen. If the string cannot be found, the computer 'beeps' and editing starts at the top of the program.
If you want to save anything you have done before you leave the BASIC editor, follow the instructions in the Saving a program. When you are ready to leave the editor and return to BASIC, press Shift-F4.
Once in the editor, your program is displayed with the line numbers at the lefthand side. If you enter the editor with no program loaded the screen is nearly blank, with just the number 10 at the top left.
The cursor is at the beginning of the top line on the screen, just to the right of the line number. Note that the editor automatically puts a line number on the beginning of each line: there is no need for you to type them in.
The status line is at the bottom of the screen, displayed in reversed colours in order to make it stand out from your program text. It contains various useful pieces of information such as the size of your program, its name, and whether it has been modified since you entered the editor.
The status line displays the following information (if it will fit):
In addition, the status line is used for prompts such as Replace? (Y/N) which appear in the SELECTIVE REPLACE facility. See the section entitled Searching and replacing for details.
The cursor can be moved around using the four arrow keys. Note, however, that you cannot move the cursor into that area of the screen containing the line numbers. This is because in general you need never be concerned with providing line numbers for your BASIC statements. As a result, cursor movement is restricted to the area of the screen which contains program text.
To change a line, use the cursor keys to position the cursor on the correct line. You can then delete part or all of the line and type new text in place of the old.
Now, assume that the program looks like this:
10 FOR X = 2 TO 30
20 PRINT X+X
30 NEXT X
and that it needs to be changed to look like this:
10 FOR X = 2 TO 20
11 PRINT X*X
20 PRINT X+X
30 NEXT X
To achieve this you must change line 10 and add a new line: line 11.
Position the cursor on the 0 of 30 on line 10, press Delete and type 2. The 30 is replaced by 20.
To create a new line in the middle of the program move the cursor to the line above the place where you want the new line and press Return.
In the example above, move the cursor to line 10 and press Return.
Line 11 is now created.
To complete the above program type
PRINT X*X
The program should now be complete. You may like to experiment with the Return and cursor keys to create a larger program.
There are two function keys which, no matter where you are in the program, create a new line at the top or end of the program and move you there directly. These keys are Ctrl-F9 (INSERT AT START) and Ctrl-F10 (INSERT AT END).
There are two ways to delete single characters. The Delete key removes the character to the left of the cursor and moves the characters to the right of the cursor back one space.
To delete the character on which the cursor is placed, hold the Shift key down and press the Delete key. Delete and Shift-Delete both move the following text back a space, but Shift-Delete leaves the cursor in the same position.
To delete all the characters from the cursor position to the end of the line, press the F11 key.
If a statement is too long to fit on one line of the screen, it wraps around to the next line. To see this, try typing more text after one of the lines in the program. As in a BASIC program, the length of a line is limited by the BASIC editor to 251 characters.
To save a program which you have created or changed press F3 (SAVE).
A window appears into which you should type the name of the program. Once you are sure that you have typed the correct name for the program press Return or F12 (EXECUTE) to perform the save operation.
The program name need not be enclosed within quotation marks.
If you wish to save only a portion of a program you may do this by setting limits. See the chapter entitled Line command for details of how to do this.
You may now wish to load in one of your own programs to experiment with before moving on to the next section. To do this press F2 (LOAD).
A window appears ready to accept the filename.
Type in the name of the program and press Return or F12 (EXECUTE).
If the current program has been modified but not saved a warning message is given.
You can also join one program onto the end of the current one.
To do this press Shift-F2 (APPEND) and then proceed in the same manner as for loading.
Several commands are provided to help you move quickly around when you are editing a large program, such as one which is too large to be displayed on the screen at one time.
If you move the cursor to the top screen line and keep pressing the KEY_ PREVIOUS STATEMENTS ARE BROUGHT ONTO THE SCREEN ONE AT A TIME UNTIL YOU REACH THE BEGINNING OF THE PROGRAM. SIMILARLY_ PRESSING from the bottom screen line brings the following statements onto the screen one at a time until you reach the end of the program.
To move directly to the top of your program, press Ctrl WHICH MOVES THE CURSOR TO THE FIRST LINE OF THE PROGRAM. PRESSING CTRL moves to the last line.
If you press Shift _ THE NEXT SCREENFUL OF YOUR PROGRAM IS DISPLAYED. IN THIS WAY_ YOU CAN MOVE QUICKLY AROUND YOUR PROGRAM FROM BEGINNING TO END. SIMILARLY_ IF YOU PRESS SHIFT , you can see the previous screenful. These functions are duplicated by the Page Up and Page Down keys.
If you press Ctrl-Shift OR CTRL-SHIFT you can move to the first or last statement on the current screen. In addition, if the cursor starts n characters along a statement, it remains n characters along. It does not go to the beginning of the statement.
Pressing the Shift AND SHIFT enables you to move sideways across the screen at twice the normal speed.
Pressing Ctrl TAKES YOU TO THE BEGINNING OF THE CURRENT STATEMENT AND CTRL TAKES YOU TO THE END OF THE CURRENT LINE. PRESSING CTRL-SHIFT TAKES YOU TO THE BEGINNING OF THE NEXT STATEMENT. PRESSING CTRL-SHIFT takes you to the beginning of the previous statement.
You can split the screen into two windows, which lets you look at two portions of your program at the same time (this is called split window mode). To do this, press Ctrl-F4. This saves you scrolling through the program many times. To place the cursor in the other window, press Ctrl-F2 (which acts as a toggle between the two windows).
When you want to return to a single window, press Ctrl-F4 again. Note that while you are using the split window mode, the Copy key will not work.
If new lines are created in the middle of a program, the editor automatically adjusts the numbering where necessary. If this happens in a program containing a GOTO or a GOSUB to a line number as yet non-existent, then that line number is replaced by the characters @@@@.
You may at any time renumber the program yourself by pressing F8 (RENUMBER). This renumbers the program starting at line 10 with an increment of 10.
If you have typed in some text in either upper or lower case and you want to change it to the opposite case, move to the area to be changed and press F10 (SWAP). This converts one alphabetic character at a time from lower case to upper case and vice versa.
If you want to abandon any changes you have made to a statement before you have left it, press Shift-F10 (UNDO). This restores the statement to the way it was before you made the changes. This only works if you have not moved the cursor off the line.
Occasionally, you may want to split one statement into two or more. You can do this by positioning the cursor on the character which is to be at the start of the new statement and pressing Shift-F1 (SPLIT). You can only split a statement from somewhere in the middle. As you are creating a new statement, this may cause renumbering to take place.
There may also be occasions when you want to join two statements together. To do this, move the cursor to the first of the two statements and press Ctrl-F1 (JOIN). The editor automatically puts a colon between the two statements. If the combined length of the two statements would exceed the maximum space available, the join is not carried out and an error message is displayed.
To create an exact copy of any statement immediately after it, move to the statement you wish to copy and press Shift-F8 (REPEAT). As in the case of SPLIT, this may cause renumbering to be carried out.
As you move about your program, there may be a statement which you wish to come back to later on. The editor provides a way of marking a statement so that you can go back to it with a single key-stroke. To mark a statement, first move to it and press F6 (TOGGLE MARK). Pressing the same key again removes the marker. A full stop appears on the screen between the line number and the start of the text, indicating that this statement has been marked. Up to four marks may be set at any time.
Wherever you are in the program, pressing Shift-F6 (GOTO MARK) brings the marked statement to the top of the screen and positions the cursor there. If there is no marked line, pressing GOTO MARK displays an error; pressing Esc then allows you to continue.
These are commands which allow you to delete, move and copy either a single line or a block of lines. They can be inserted into the lefthand margin and are not executed until F12 (EXECUTE) is pressed.
For example, to delete a single line, move the cursor onto that statement, hold down the Ctrl-key and press D. The line number is removed and replaced by the letter D. To delete the line from your program, press F12 (EXECUTE). The line is removed from the screen and the cursor positioned on the previous line.
If there is a block of lines which you want to delete, move to the first line in the block and press Ctrl-D twice. The line number disappears and is replaced by the letters DD. Now move to the last line in the block and press Ctrl-D twice more. Finally, press F12 (EXECUTE) to remove this block of lines from your program.
You may wish to delete from the current line to the end of the program. In this case, press Ctrl-D twice on the current line and then press Ctrl-E. The line number is replaced by DDE and the block from there to the end of the program can be removed by pressing F12 (EXECUTE).
In a similar way, you can delete from the current line to the top of the program by using Ctrl-T instead of Ctrl-E and then pressing F12 (EXECUTE).
Ctrl-E and Ctrl-T are examples of destinations and we shall encounter more of these later.
To move a single statement from its current position to the end of the program, move to it and press Ctrl-M followed by Ctrl-E. The line number is replaced by ME and pressing F12 (EXECUTE) moves that line to the end of the program.
Ctrl-T can be used likewise to move a statement to the top of a program.
Instead of using Ctrl-T or Ctrl-E to specify the destination as the top or the end of the program you can specify that the destination is before or after a certain line.
To move text to a position after a particular line, move to the destination and press Ctrl-A.
Alternatively you can use Ctrl-B to move text to a position before a particular line.
Blocks of lines can be moved as easily as a single line by putting MM around the block to be moved, choosing your destination, and pressing F12 (EXECUTE).
Whereas moving text removes it from its original position, copying text leaves the original unchanged and duplicates it elsewhere. The command to copy text is Ctrl-C instead of Ctrl-M, but otherwise the move and copy commands are the same.
Naturally, for both the move and copy commands the destination must not be within the block being moved or copied.
You can limit the effect of certain operations either to one line or to a block of lines. These operations are:
To limit the operation to a single line, move the cursor to that line and press Ctrl-L. To limit the operation to a block of lines, press Ctrl-L twice each on the first and last line of the block.
To limit the operation from a particular line to the top (or end) of the program, move the cursor to that line and press Ctrl-L Ctrl-L T (or Ctrl-L Ctrl-L E).
When a limit is set up, the functions which take account of it display the limit in their window.
The editor can indent all or part of a program automatically. To reformat a part of the program, move to the first line of the block you want to justify and press Ctrl-J twice. Then move to the last line of the block and press Ctrl-J twice. Pressing F12 (EXECUTE) justifies the block so that the indentation of each line is identical to that of the first line.
To remove a line command, move to the line in question and press Ctrl-R. This deletes the line command from the screen and replaces the line number. Pressing Ctrl-R on a line which does not contain any line commands removes all line commands no matter where they are. You do not, however, have to remove a line command in order to change it: to replace the old command simply overtype it with a new one.
Ctrl-R can also be used to remove the line marker set by F6 (TOGGLE MARK); but unlike the line commands, the marker can only be removed when you are on the marked statement.
Line commands are not stored as part of your program text but are only held internally in the editor. There is no need, therefore, to remove line commands or the marker before saving your program.
Note that copying or moving statements causes renumbering to take place automatically.
To search for the first occurrence of a particular piece of text, press F4 (SEARCH & EDIT). A window appears where you should enter the text to be found. When you have done this press F12 (EXECUTE) and the search is carried out. The cursor reappears on the first match within the program.
As an alternative to SEARCH & EDIT you can find all occurrences of a given string and have them displayed. To do this press F7 (SEARCH) and enter the string which is to be located. Then press F12 (EXECUTE) to perform the search. Any line on which a match is found is displayed. You may then move up and down the list, choose one to look at and press Home. This line is then placed at the top of the full edit screen and you can edit it.
To change one string for another throughout your entire program press F5 (GLOBAL REPLACE) and enter the text to be changed. You must then enter the new text, and when you are happy with it press F12 (EXECUTE) to carry out the change.
It is possible to perform a replace operation selectively. To do so press Shift F5 (SELECTIVE REPLACE). You must then enter both the text to be changed and the new text. Press F12 (EXECUTE) to start the search. Each match is displayed and you are prompted for either Y or N to indicate whether the replacement is to be performed or not.
It is possible to move on to the next occurrence of the text searched for in the last search operation or back to the previous one. To do this press either Shift-F7 (NEXT MATCH) or Ctrl-F7 (PREVIOUS MATCH).
Pressing Shift-F3 brings up a window which allows you to select various options. This is called the Options Window. The options are displayed in three groups described below. Pressing Return allows you to cycle through the groups.
This enables you to move more quickly across the screen. It moves the cursor to every third character position. At the end of a line, it takes the cursor to the beginning of the next line.
Pressing Shift-Tab moves the cursor in the opposite direction.
The options can be used to set the width of the tab movement to any value (number of characters) in the range 0 to 63.
The editor can automatically line up text in a program so that each line starts beneath the first position of the line above which is not blank. This is known as auto-indentation. It can be turned on or off using the Options Window: Auto-indent (on/off)
There will be times when you want to overtype existing text rather than insert before what is already there. To do this, press Insert and you will see that the cursor has changed to an underline. This indicates that you are in overtype mode, and that text which you type in will replace existing text. To return to insert mode, press Insert again, and you will be able to insert text as before. In insert mode, a block cursor is used. In overtype mode, a line cursor is used.
When you enter the editor, the default setting (insert or overtype) is used. You can change this default using the Options Window. Your choice is retained in non-volatile memory.
There are four wildcards, each of which may be customised using the options available.
Wildcards can be changed to any punctuation character, or can be disabled by using the Space Bar. Different wildcards must not use the same character.
The editor works in 40-, 80- or 132-column modes. You can choose the default mode using the Options Window. The value is held between sessions in non-volatile memory.
Note that 256-colour modes and modes with 20-column text are not allowed. You can also set up your default choice of foreground and background colours.
The editor makes extensive use of the normal function keys, but you can still program your own in the usual way via the *KEY command. To access them you must press Ctrl Shift together with the function key, and not just the function key on its own.
Windows are displayed whenever input is required or information is shown.
Valid keys and their actions are:
Keys | Effect |
---|---|
Tab / Return / | Moves cursor to next field |
Shift-Tab / | Moves cursor to previous field |
Esc | Cancels window, returns to editing |
F12 (EXECUTE) | Validates input & executes command |
Insert | Toggles insert/overtype for this window only |
Delete | Deletes character to left of cursor |
Shift-Delete | Deletes character above cursor |
F11 | Deletes characters from cursor to end of field |
Shift-F11 | Deletes all characters before cursor |
Ctrl-F11 | Deletes all text in this field |
/ SHIFT | Moves cursor left 1 or 2 positions |
/ SHIFT | Moves cursor right 1 or 2 positions |
Ctrl | Moves cursor to beginning of field |
Ctrl | Moves cursor to end of field |
Esc Removes window and returns to editing.
Data can be entered in one of three ways:
Pressing another function key whilst a window is present usually executes its function. The exceptions are those functions which manipulate the program text (eg SPLIT and JOIN).
The following actions are performed directly via key presses:
Moves right | |
Moves left | |
Moves up | |
Moves down | |
Shift | Moves right two characters |
Shift | Moves left two characters |
Shift | Moves cursor up a screenful |
Shift | Moves cursor down a screenful |
Ctrl | Moves to the end of the statement |
Ctrl | Moves to the beginning of the statement |
Ctrl | Moves to the beginning of the program |
Ctrl | Moves to the end of the program |
Ctrl-Shift | Moves to beginning of next statement |
Ctrl-Shift | Moves to beginning of previous statement |
Ctrl-Shift | Moves to top of current screen |
Ctrl-Shift | Moves to bottom of current screen |
Page Up | Moves cursor up a screenful |
Page Down | Moves cursor down a screenful |
Tab | Moves right to next tab position |
Shift-Tab | Moves left to previous tab position |
Home | Brings statement to top of screen |
Copy | Enters copy mode |
Enter | Ends copy mode |
Insert | Toggles insert/overtype mode |
Delete | Deletes character to left of cursor |
Shift-Delete | Deletes character at cursor position |
Enter | Creates a new statement after the current one |
F1 | (* COMMAND) | Perform OS command |
F2 | (LOAD) | Load a program |
F3 | (SAVE) | Save a program |
F4 | (SEARCH & EDIT) | Find string and edit from it |
F5 | (GLOBAL REPLACE) | Global search and replace |
F6 | (TOGGLE MARK) | Set or remove a marker. Up to four markers allowed |
F7 | (SEARCH) | Find all occurrences of a string |
F8 | (RENUMBER) | Renumber the entire program |
F9 | (OLD) | Same as BASIC OLD |
F10 | (SWAP) | Swap case of alphabetic characters |
F11 | (DEL TO END OF LINE) | Delete from cursor to end of line |
F12 | (EXECUTE) | Execute line commands |
Shift-F1 | (SPLIT) | Split statement at the cursor |
Shift-F2 | (APPEND) | Append a program |
Shift-F3 | (OPTIONS) | Present the Options Window |
Shift-F4 | (EXIT) | Return to BASIC. Variables will be lost if changes were made |
Shift-F5 | (SELECTIVE REPLACE) | Selective replace. When prompted, only Y,N,Escape and Home are valid |
Shift-F6 | (GOTO MARK) | Go to next marker, with program wraparound |
Shift-F7 | (NEXT MATCH) | Go to next occurrence of search string |
Shift-F8 | (REPEAT) | Copy current statement |
Shift-F9 | (NEW) | Same as BASIC NEW. Prompts if program has been modified |
Shift-F10 | (UNDO) | Undo changes to current statement |
Shift-F11 | (DELETE TO START OF LINE) | Delete all characters before the cursor |
Shift-F12 | (GOTO LINE COMMAND) | Go to next line command, with program wraparound |
Ctrl-F1 | (JOIN) | Join two statements, with a colon separator |
Ctrl-F2 | (SWAP WINDOW) | Toggle between windows |
Ctrl-F3 | Reserved | |
Ctrl-F4 | (SPLIT/JOIN WINDOW) | Split or join window(s) |
Ctrl-F5 | (HELP) | Display help window |
Ctrl-F6 | (INFO) | Display program information |
Ctrl-F7 | (PREV. MATCH) | Go to previous occurrence of search string |
Ctrl-F8 | (EXTEND) | Add a line to current statement |
Ctrl-F9 | (INSERT START) | Add a statement at beginning of program |
Ctrl-F10 | (INSERT END) | Add a statement at end of program |
Ctrl-F11 | (DELETE LINE) | Delete all text from current statement |
Ctrl-F12 | (GO TO LINE) | Go to selected line number |
Function keys are used with Ctrl and Shift for user-defined strings.
The editor displays the following messages. In each case, an explanation is given below the message.
Limit is xxxx to xxxx/Limit is xxxx only
A range has been set using the L or LL line commands, and this function will only operate within the range.
Line xxxx is too long to be edited
The program already contains a line which is too long.
Not enough room in RMA for The BASIC Editor
RMA initialisation failed to acquire workspace.
Replace? (Y/N)
Displayed on the status line when prompting during the SELECTIVE REPLACE operation.
Tab must be between 0 and 63
Displayed by OPTIONS.
The combined length of these statements would be too big
The two statements cannot be joined.
The destination must be outside the block being moved or copied
Raised by EXECUTE.
The first statement in the block to be justified must not be blank
Raised by EXECUTE.
The maximum line is 65279
Raised by GOTO LINE.
The name has been truncated
On saving, the program name following REM > in the first line of the program is longer than can be displayed in the window.
The named program is invalid
The user appended a program which was invalid. The editor restored the original.
The named program is too big
The user tried to load or append a program for which there was not enough room in memory.
The renumber has failed.Unmatched line numbers have been replaced by @@@@
When trying to renumber the program one or more line number references could not be resolved.
The search string has no text
The search string must not be blank, and must not contain only wildcards.
The string could not be found
The search string could not be found.
There is not enough memory to update the program
All available memory has been used up.
This is not a valid mode
An invalid screen mode was specified in OPTIONS.
This is not a valid program
OLD was pressed with no valid BASIC program in memory, or the user tried to load an invalid program.
This program could not be found
The named program on a load or append was not in the directory.
This program has not been saved
The user is warned on a load if the program has been modified and not saved.
This program has not been saved
Press NEW again to confirm.
Press ESCAPE to cancel
The user pressed NEW but the program had been modified and not saved.
This statement is too long
The statement is too long, and needs to be shortened.
This statement is too long to be changed
Replacing or justifying would make the statement too long.
This statement is too long to be split
Even after splitting, both parts of the statement would still be too long.
Wildcards must not be the same
Raised by OPTIONS.
You cannot load a directory
The filename specified in load or append is a directory.
You do not need to enter a destination for this command
Raised by EXECUTE.
You do not need to enter a repetition factor for this
command
Raised by EXECUTE.
You have entered a destination but no command
Raised by EXECUTE.
You have entered too many commands
Raised by EXECUTE.
You have not entered any line commands
Raised by GOTO LINE COMMAND when there are no line commands.
You have not entered any markers
Raised by GOTO MARKER when no markers are set.
You have not yet entered a search string
Raised by NEXT MATCH or PREVIOUS MATCH when no find string has been entered.
You have used the maximum number of statements. No more can be added
The program already contains the maximum number of statements allowed by BASIC (65279) and the user tried to add another.
You must enter a destination for this command
Raised by EXECUTE.
You must enter a mode
No screen mode was specified within OPTIONS.
You must enter a program name
The program name was not entered for load, append or save.
You must enter a search string
The search string was not entered.
You must enter a tab value
No tab value was specified in OPTIONS.
You need to specify both ends of the range for this command
Raised by EXECUTE.
You should not enter two different commands
Raised by EXECUTE.
*ARMBE is only valid from BASIC