int newitem([name] [text] [type|template] [trigger] [folder] [flags])
name - item name. Also can be id (integer) of existing item (for example, when deleting or replacing). Error if contains invalid filename characters or is invalid name for function or member function. Can be "".
text - item text. For file link item - file path.
type - one of: "Macro", "Function", "Menu", "Toolbar", "T.S. Menu", "Member", "Folder", "File Link". Default: "" (macro).
template - name or id of an existing item. It must not be folder.
trigger - encoded trigger string.
folder - name or id of folder where new item must be created. If folder does not exist, it is created. It also can be full path that begins with \ (e.g., "\Folder\Subfolder").
flags - combination of values listed below. Default: 0.
| 0 | If item with name exists, create new item with unique name, e.g., "Macro" -> "Macro2". Flags 0 - 3 cannot be used together. |
| 1 | If item with name exists, replace it. |
| 2 | If item with name exists, error. |
| 3 | If item with name exists, replace its text (with possibility to undo). This does not replace other properties. Alternatively, you can use str.setmacro. |
| 4 | Select new item. |
| 8 | After creating new item, let user edit its name (if flag 4 is used and QM window is active). |
| 16 | Create item as last (bottom) item in list or folder. |
| 32 | Delete item. Other flags (except 64), text and trigger are not used. If item not found, the function succeeds but returns -1. |
| 64 | Confirm (with flag 32). Error if user clicks Cancel. |
| 128 (QM 2.3.0) | Temporary. |
Default value for string arguments is "", which means that this property is not used.
Creates new QM item, or replaces/modifies/deletes existing item. Returns item id of new item (when creating new item), or existing item (in other cases).
Cannot create/replace/modify/delete items in read-only folders. Cannot replace (flag 1) folders. Cannot replace (flag 1), modify (flag 3) or delete (flag 32) existing item if it is in other folder or has other type, unless item id is used.
QM 2.2.0. Can be used encrypted templates. Then the new item also will be encrypted. Also can replace (flag 1), replace text (flag 3) and delete (flag 32) encrypted items. If flag 3 used, and the item already exists, it also must be encrypted.
Execute QM macro code that is stored in file "test.txt". This will create temporary macro with text of file and execute it: str s.getfile("$desktop$\test.txt") mac newitem("temp_file_text" s "" "" "\Temp\files" 1)