1. Script command
The Script command can be used for simple scripting use cases where a linear command list is not sufficient. The script command supports multiple stacks which can be used to store data like file names or user input for use in later commands. Using the if command mode, expressions can be evaluated and different branches can be taken to program the command execution.1.1. Script command modes
Each Script command instance can be configured to operate in one mode. Multiple instances in the command list can be chained together to build a complex command list.The following modes are available:
1.1.1. Nop
The Nop mode is a no operation mode which has no effect.
1.1.2. Push
The Push mode is used to store an arbitrary string onto an stack of strings. The string can be some static, pre-configured string, or can contain flags similar to flags used in Own command to access the selected files or even other stack values.
The value in any stack can be accessed by other Script commands or can be used as a flag replacement in other command like the Own command.
Options:
- Push the output of the command: Instead of just pushing the string as is, the string will be executed in a shell and its output will written to the stack for later use.
- Stack number: Multiple stacks can be used if different data should be stored separately.
- String: This is the string that will be pushed onto the stack. Flags are replaced during execution.
- Run in debug mode: If enabled, the value written to the stack is shown in a dialog box which makes it possible to see which actual value is used.
1.1.3. Pop
The Pop mode removes an entry from a stack and discards its value. If you want to actually use the value, you have to use the flag "{top ...}" or "{pop ...}" in other commands.
1.1.4. Label
The Label mode defines a label that can be used for branching using the Goto mode.
1.1.5. If
The If mode allows to branch to a label conditionally if an expression is evaluated to true.
Options:
- Condition: This is a C-language-like expression that is evaluated
during runtime. The condition can use comparisons of numbers or
strings and strings can utilize flags to access selected file names
or content of stacks. It also allows to execute commands and use
its output for comparison.
- Available flags:
- isEmpty(<stack number>): true if the given stack is empty.
- size(<stack number>): is replaced by the size of the given stack.
- lasterror: This is an error value indicating previously failed commands. A value of zero means no erorr.
- filelistEmpty(<side number>): true if the list of selected files of the selected side is empty. Side 0 is the active panel, Side 1 is the inactive panel.
- true
- false
- ?{command...}: The flag is replaced by the return value of the given command. The command within the curly braces can contain flags for variable arguments to the command.
- ${command...}: The flag is replaced by the output of the given command, using only the first line. The command within the curly braces can contain flags for variable arguments to the command.
- toNum(...): The given string argument is converted to a number.
- toStr(...): The given number argument is converted to a string.
- isLocal(<file name>): The return value is true, if the given file name is a local file instead of virtual file.
- Inside strings ("...") or command flags, any regular flag as described in Own command can be used to access file names and so on.
- Available flags:
- Label: This is the label at which the command execution is continued if the expression is true.
1.1.6. End
This mode immediately stops the command execution.
1.1.7. Settings
Some settings can be configured to modify the behavior of the Script command:
- Recursive: When collected selected files for flag replacement, also consider the content of selected directories. This setting must be set as the first command before any flag is replaced as otherwise it would have no effect.
- Also use dirs for flag replacement: If the recursive mode is chosen, flags like {f} are by default only replaced with each individual file. By enabling this option, each directory which is also scanned recursively, is also part of the flag replacement list.
1.1.8. Change user window
This mode allows to show a simple window for user feedback, showing a progress bar and a text field.
Options:
- Change window visibility: Opens or closes the user window
- Change progress bar: Sets the progress bar to a value between 0 and 100 percent. The value can be a fixed number, can use flag replacement value, or can use the output of the given command.
- Change text: Sets the text shown in the text field. Again, a fixed text can be used, or a variable text using flag replacements, or the output of an external command.
1.1.9. Goto
The Goto mode unconditionally continues command execution at the given label.
1.1.10. Evaluate command
The Evaluate command can be used to access internal commands registered for each list view mode. Such commands are low-level commands which do not require complex configuration and operate directly without any argument or with specific string arguments.
Options:
- Command: enter the command name to execute. The C button allows to select from a list of all available commands. The F button allows to select from the list of available flags for command arguments.