# Using MMEdit

The main edit window should work as expected. Many of the standard keyboard shortcuts are there as well as a long list of less common shortcuts.

The Code Formatter (Alt+O), indents code to make the code easier to follow.
The Tab can bet set between 2 and 8 spaces and there can be extra indenting to emphasise labels and functions. Try it and see - all indenting is reversible.
Indenting does use some space so there is an option to remove all leading and trailing spaces to save space.
Formatting code also helps draw attention to miss-matched conditional statements and looping structures.

It is strongly recommended that you convert your files to 'without numbers'.
The source code can have Unix or DOS/Windows style line endings.
When a file is loaded, MMEdit checks the first 1k, looking for <CR>. If any <CR>s are found, it is assumed that the file is DOS format and the full file is forced into DOS line endings.
If no <CR>s are found, the file gets force converted into Unix line endings.
You can always change the endings at any time. Unless your device requires Unix <LF> line endings, it is preferable to stick to DOS <CRLF>

The various options in the Edit window are remembered between sessions. Under File/Preferences, you can set options that MM Edit always starts with.
If you have multiple different devices you are programming for, it might be easier to have the important options saved in the code file.
This is done by selecting 'Save config in BAS' in the preferences.
If you don't have settings that change between devices, you can save a little bit of time while loading by not selecting 'Save config in BAS'

Many of the options only affect what you see and are not part of the code.
Saving or sending code to the Maximite will not include these 'features'.

Space characters can be highlighted. A space (or lack of) can cause havoc and can be difficult to see.

Keywords are coloured and converted to uppercase.
You can change that in 'Preferences'
It is important to select the correct syntax file for your device. The syntax colouring is not an issue but setting the syntax also tells MMEdit how to communicate with your device.
Syntax files are stored in the data folder and you can add your own file. Just copy the format used by the supplied files and your file will be included in the list next time MMEdit starts. Currently, 20 different syntax files are allowed.

F1 will give syntax help and Shift_F1 will give you a comprehensive help on the selected keyword.
Just as with the syntax files, users can create their own help files.
The supplied help uses the file 'kw_list.csv' and 'user.csv' is the one you should use. Both files are scanned on startup. There is only one help file for all device variations.
The csv file contains a short one line help hint and a link to a HTML file. If you are adding your own HTML help, the files should be placed in the html sub folder. IF you use a name starting with '_' or similar, your files should be safe from getting overwritten with MMEdit updates.

Physical line numbers are useful for debugging. The MM Basic interpreter will indicate which line gave an error. Having Physical line numbers turned on makes it easy to look at that line. Remember that sometimes the error is actually caused by a problem in a previous line.
If you are moving between two or three sections of the code, such as a subroutine and the code body or the initialisation area, bookmarks are very useful.
You can jump to and from subroutines and user functions by highlighting the name and click - you're there. If you don't have function name selected, you will be given a popup list of functions to choose from.

Indenting lines of code can make it a lot easier to read (and debug).
With auto-indent turned on, the indent used will carry forward to the next line.
Backspace when you want to remove the indent and the new indent setting will carry forward. Indent does affect the final code.
You can also go directly to a physical line number with Ctrl+G
'Format' will reformat you code with indents. This is a fast way to check for incorrect structure in your code. Alt-O is a shortcut for 'Format'

To make it easier to reuse code, you can add your library files using two methods.
In the Edit menu, you can Insert a file at the current location (actually after the current line) or at the end of the file.
The second method requires INCLUDE directives.
In the main code a comment line with either '$INCLUDE:' (Quick Basic style) or '#INCLUDE' (C style) with indicate where the include file is to be placed.
Running 'merge include files' from the 'Program' menu will insert the library files into the main file. A comment line will be inserted at the end of the include file so you know what code was added. The original include directive has another comment (') added to prevent subsequent merges from adding a second copy of the include file.
An include file can have its own includes.
In both cases, the added code is now part of the main file.

Transferring your code to the Maximite can be achieved by three methods.

The fast way is to click on the 'Load and Run' button. This will load the current program onto the Maximite.
In Preferences or the Advanced menu you can set 'Run on Load' to run the program immediately after loading.
'set clock on load' to set the clock to the computer time before loading.
'auto crunch on load' removes all comments before uploading but keeps the blank lines.
'Delete blank lines' causes autocrunch to delete all blank lines. This will result in the line numbers on the Maximite being different to the line numbers in the editor and make fault finding more difficult.
'CLS on load' clears the Terminal window after loading.
On devices with file systems, the file is uploaded as 'temp.bas'. If you hold Shit when selecting 'load and run' or 'load' in the Chat window, the original file name is used instead of 'temp.bas'

Devices without file systems load the file into memory.

Using 'MM File' will transfer the code from the Edit window (or a file on the PC) to a file on the Maximite drive A or B. The MicroMite loads the file into memory.
'load and run' uses XMODEM to transfer, 'Load' from the Chat window uses AUTO or AUTOSAVE.

Last edited: 15 May, 2021