Essentially, I think we need to get to separating the menu from the sub-scripts.
We also need user functions.
And it would be nice if we had a less cumbersome way for some vars that are truly global to the entire script file.
Example Structure:
Code: Select all
#! SCRIPT_ENGINE = 2
/* SHEBANG!
To keep backwards compatibility this will be required and specifies
the version of the script engine to use. Eventually the current engine
could be removed, but this allows for a smoother transition to the new one.
We should probably require it be the first line, first column as well.
*/
[GLOBALS]
/* GLOBAL VARS (Script File Level)
We nearly have this, but ideally these variables could be referenced
like normal variables and not require the use of GetKey() or Global().
Using the INI format we should be able to leverage SetKey() to keep
them updated if we want to, otherwise they'd be used for static values.
*/
G_SCRIPT_NAME = "blah blah"
G_DEFAULT_MENUITEM_STATE = 0
def FunctionName (arg1, arg2="") {
/* USER FUNCTIONS
Essentially a normal script with args and returns.
Arg1 is required.
Arg2 is optional with a default value of "".
Required arguments must always preceed optional ones.
Use "return [expression]" to return a value.
If expression or the return command is omitted 1 should be returned.
*/
}- When the file is loaded:
- If a caption is specified and it matches a functionName (or is an index): Execute "caption"
- Else If a function is named "main": Execute "main"
- Else: Execute first function.
- MenuItem "MenuName"[, "Action", "Caption", "Description", "Icon", "State"];
- MenuSub "MenuName", "SubMenu"[, "Caption", "Description", "Icon", "State"];
- DisplayMenu "Menus"[, "Description"];
1. MenuItem "MenuName"[, "FunctionName|SimpleScript", "Caption", "Description", "Icon", "State"];
This adds an item or separator to the menu named "MenuName".
- Required Args:
- MenuName
- This is the name of the menu to add items to.
- MenuName
- Optional Args:
- Action
- This is the function name or a small script to execute when this item is selected.
- If omitted, a separator is inserted.
- Caption
- Text to display in the menu for this item. Using & for accelerators.
- Description
- A brief description of the item for display in the status bar.
- Icon
- Path to an icon to display for this item.
- State
- State of this item.
- Combination of the following OR-ed:
- 1 = Default
- 2 = Checked
- 4 = Disabled
- Action
This adds a submenu to the menu named "MenuName".
- Required Args:
- MenuName
- This is the name of the menu to add a submenu to.
- SubMenu
- This is the name of the menu to add as the submenu.
- You should create the submenu before you add it to another menu.
- MenuName
- Optional Args:
- Caption
- Text to display in the menu for this item. Using & for accelerators.
- Description
- A brief description of the item for display in the status bar.
- Icon
- Path to an icon to display for this item.
- State
- State of this item.
- Combination of the following OR-ed:
- 1 = Default
- 2 = Checked
- 4 = Disabled
- Caption
This displays the specified menu(s).
- Required Args:
- Menus
- This is the name of the menu to display.
- This can be a list of menus separated by "|" to join them into a single menu.
- Menus
- Optional Args:
- Description
- A brief description that is displayed on the status bar, when the menu is displayed, or not item is highlighted.
- Description
EDIT: Corrected DisplayMenu, definition.
XYplorer Beta Club