Overview
Parameters provide a significant saving of effort in creating note types and their associated fields and card templates. They are similar to variables in computer programming and provide a mechanism to have only one thing to edit when a card template is redesigned or amended.
For instance, a note type for learning all grammatical forms of a Russian pronoun may have 24 card templates of one type and 24 card templates of another, where the only difference is the name of the 6 cases and 4 genders. Making any changes to these using the Anki user interface is painful, and it's easy to miss a change on a card.
With Anki Script when a script is run the parameter is replaced by the values specified meaning that only a single card template definition has to be provided.
Usage
Note when using parameters:
  • parameters are expanded in the order they were added
  • parameterized and non-parameterized field or card template names should not be used in the same sub-command
  • if a field or card template name begins with a parameter the whole name must be put in quotes
  • all fields in the same sub-command should have the same parameters
  • all parameters used in the card template must be part of the card template name
Parameterized expansion
For use with addons like the Multi-column note editor you can control in what order parameterized fields and card templates are generated:
  • all of the names in one sub-command are generated before the next sub-command is processed
  • parameters are expanded in the order that they were defined, not the order that they are used in the name
  • the last parameter defined changes fastest, the first slowest
So for instance, if the following sub-commands are defined:
    with ONE in [a, b];
    with TWO in [x, y];
    add field Field(${TWO},${ONE});
    add field Audio;
fields are generated in this order:
Field(x,a), Field(y,a), Field(x,b), Field(y,b), Audio
If a card template or field name begins with a parameter the whole name must be put in quotes. For example in the following command the card template name must be quoted:
change verb note type and:
    with PERSON in [я, ты, он/она/оно, мы, вы, они];
    add field Russian (${PERSON});
    add card types "${PERSON}", setting default deck to verbs
Card names must be unique so ALL parameters used in the card template must be part of the card template name.
Using in card templates
To use a parameter value within a card template put $NAME or ${NAME} where the value should appear (NAME should be the actual parameter name used in the script).
Within card templates configuration data {} brackets around the parameter name are optional, ie:
{{Russian}}
$PERSON {{type:Russian ($PERSON)}}
produces the same result as:
{{Russian}}
${PERSON} {{type:Russian (${PERSON})}}
Translations
Translation enable an alternative parameter value to be used within card templates. They cannot be used for field or card template names.
The purpose of translations, and the reason for the name, is for situations like language learning where you may need to use parameter values for one language, but also include in the card templates a translation of that value in the other language. For example, that could be for displaying pronouns for the language direction tested by the card template.
Within a card template using $$ will result in the translation value being used - the value is the value for the matching parameter value.
So for instance with the following:
    with PERSON in [я, ты, он/она/оно, мы, вы, они];
    translate PERSON to [I, you, he, us, you, they];
$PERSON in the card template would be replaced by я for the first card and ты for the second card, whereas $$PERSON would be replaced by I for the first card and you for the second one.
Note when using translations:
  • translations can only be used within the front and back of card templates
  • the corresponding parameter sub-command must be before the translation sub-command
  • the corresponding parameter and translation must have the same number of values