BaseExtensions enables to use variables in commands that would be replaced based on values coming from prompts.
Inside the button, we first execute the command that prompts and allow the user to type the input. Inside this command, we have a <Prompts>
element in which the user's input is integrated, followed by a <Commands>
elements, where the command(s) are placed.
CMD for prompt and input
<Cmd case="BaseExtensions:prompt-input"></Cmd>
This command expects two elements, <Prompts>
and <Commands>
. See the example below.
Parameters
The following three parameters are required in order to build a prompt dialog.
Title
Define the title of the prompt.
Message
Define the message that should be displayed in the prompt above the input field. For line break, write 

. However, too many line breaks will break the prompt window, and the input field will disappear.
ValidInput
Specify what kind of input that is acceptable. This is usually "Az09", which refers to only characters and numbers.
ReadFromDocProp
This parameter is optional. It is possible to define a document property which it should attempt to read from first. Define the name of the document property in this parameter and the functionality will then input the value from this instead of prompting the user to input a value.
RegexResult
This parameter is used for filtering the input inserted from the user. To use the parameter, two prerequisites must be met. First, the parameter ValidInput
must be set to ValidInput="Regex"
, in order to expand the possible input types from the user. Second, RegexValidation
must be used to set a valid input, for example: RegexValidation="^[a-zA-Z0-9/]+$"
, where every input is allowed from the user.
The parameter RegexResult
is used to determine how to filter the users input, using a regular expressions which can be learned how to use at: https://regex101.com/. For example, when filtering an input to output everything before a "/", the expression is the following: RegexResult="^[^/]+"
.
You can differentiate between the filtered input, using Regex, and the actual input in the prompt, when wanting to outputting in the xml. The filtered output is expressed by $PromptText.RegexResult$
and unfiltered output by $PromptText$
.
Example of usage
<Button label="Hide or Show shapes">
<Cmd case="BaseExtensions:prompt-input">
<Prompts>
<PromptText Title="Innput text type" Message="text type" ValidInput="Az09"/>
</Prompts>
<Commands>
<Cmd case="BaseExtensions:show-hide-pp" ShapeNames="$PromptText$"/>
</Commands>
</Cmd>
</Button>
The variable PromptText
in the example above is used to reference the user's input. The name of the element, which in this case is PromptText
, is defined by the user. It is a key that is used in the <Command>
element.
You can use multiple <Prompts>...</Prompts>
for integrating various user inputs as variables in the commands.
Commands will be executed after all prompts are shown to the user and all user inputs have been received.
Example of usage with RegexResult
<Button label="Hide or Show shapes">
<Cmd case="BaseExtensions:prompt-input">
<Prompts>
<PromptText Title="Innput text type" Message="text type" ValidInput="Regex" RegexValidation="^[a-zA-Z0-9/]+$" RegexResult="^[^/]+"/>
</Prompts>
<Commands>
<Cmd case="BaseExtensions:AlertOk" title="Hello, you have inputted:" text="$PromptText$"/>
<Cmd case="BaseExtensions:show-hide-pp" ShapeNames="$PromptText.RegexResult$"/>
</Commands>
</Cmd>
</Button>
$PromptText.RegexResult$
, but the unfiltered input is still being inputted at $PromptText$
. In this way, you can use both versions of the prompt input, without prompting the user multiple times.
Comments
0 comments
Article is closed for comments.