Templates
Templates provide a way to create a form in Easy Automation that can be used to generate blocks of similar text. The templates have fields in them can either be filled in by automation scripts, or the user of an automation script. You can see templates in action in a number of places in Easy Automation. Most blocks are just templates that generate a script after asking the user for some information.
The test everything script (test.eaf) contains a couple of example of how to use templates, including how to abuse a template in order to ask the user
The basic format for a template is a follows:
<template orderby='' name='' description=''> <![CDATA[ Put the body of the template here ]]> <variable priority='' name='' type='' value='' required='' description='' /> </template>The template tag surrounds the entire definition of the template. It has the following properties:
- name - the name of the template. This is what you will use to reference it later
- description - the description of the template. This will show up at the top of the dialog when the user is prompted to fill in variables.
- orderby - (optional) this tells the template how to order the variables when prompting the user for values. The possible values are "name", "priority". Where "name" will order the variables by name and "priority" will uise the "priority" field on the variables. The default is "name".
- [@var variableName@] - this tag includes the value of a variable at that location in the script. The variable must be defined by a <variable> tag later in the template.
- [@if variableName@] ... [@endif@] - these tags are used to conditionally include a block of text in the script. If the variable "variableName" resolves to false (an empty string, a number that is zero, or a yes no that is set to no) then the block of text between the if and the endif will be omitted when the template is expanded. You can also place a ! before the variableName which reverses the action (false will expand true will not.) The if can also use modifier functions now. There are two currently defined EXISTINGFUNCTION, and SCRIPTNAME. The functions are used like this [@if EXISTINGFUNCTION( variableName )@]. EXISTINGFUNCTION returns true if the variable contains the name of an existing function in the current script, and SCRIPTNAME returns true if the variable is the name of a script.
- [@if variableName = value@] ... [@endif@] - these tags are used to conditionally include a block of text in the script. If the variable "variableName" is not the same as the "value" then the block of text between the if and the endif will be omitted when the template is expanded.
- name - the name of the variable. This is what is referenced in "if" and "var" tags.
- description - the description of the template. This will show up in the information section of the dialog if the user is prompted to fill in the variables.
- priority - (optional) This is a number used to order the variables, but only if the template's orderby field is set to "priority". It must be a number, and it defaults to 0.
- value - (optional) the default value for the variable. It defaults to "".
- required - (optional) set to true if the variable must be filled in. It defaults to false.
-
type - the type of variable. The type of the variables is used to determin how the user
will fill it in. Possible types include:
- alpha - allows only upper and lower case letters
- alphanumspace - allows only upper and lower case letters and spaces and numbers
- alphaspace - allows only upper and lower case letters and spaces
- application - lets the user choose a well known application
- choice a|b|c... - a set of choices you can chosee from
- code - lets the user choose a function in the current script or create a new one
- color - a color
- currency - a dollar amount
- datetime - a date and time
- email - an e-mail address
- file - a file on the computer
- folder - a folder on the computer
- hidden - just like a string but the user will not be prompted for a value
- hotkey - a key combination
- md5 - an md5
- number X.Y unsigned - a number with X and Y digits before and after the decimal. unsigned is either "yes" or "no"
- password - a password
- phone - a phone number
- repeat - a time repeat pattern
- ssn - a social security number
- string - a basic string entry type
- template type - lets the user pick from a template, type is the category of template they can choose from
- time - a time
- timems - a time amount in milliseconds
- url - the url to a website
- version - a version number
- yesno - a yes or no choice
- zip - a zip code
var template = new Template( "Template XML goes here" ); template.setVariable( "name", "value" ); var resultString = template.Expand( false );For another example of see the test script.