Code Snippets

From MiniScript Wiki
Jump to navigation Jump to search

In Mini Micro, code snippets are a feature of the code editor. These are bits of code which can be inserted from the Code button in the toolbar, optionally wrapping any previously selected text.

There are several built-in code snippets ("for loop", "while loop", etc.), and you can add your own. To do so, create a text file on your user disk at the path /usr/data/codeSnippets.txt. This file should look something like this:

===for loop
for _loopVar_ in _range_
	_code_
end for
===while loop
while _condition_
	_code_
end while
===if block
if _condition_ then
	_code_
end if

Each block begins with three equals signs ("==="), and the name of the block as it should appear in the Code menu. The body of the block extends from the next line, to either the next "===" or the end of the file. If the special text "_code_" appears in the body of the block, that will be replaced with the previously selected text when the code block is applied.