Parameterized Snippets

Created: 2026-05-30 · Updated: 2026-05-30

Parameterized snippets contain @param declarations in the script header. When inserted from the gallery, a dialog appears where the user can adjust the values — before the shape is created on the slide.


How it works

  1. The script declares parameters with // @param lines at the top
  2. When run from the gallery, PPPTools detects the parameters automatically
  3. A dialog is shown — the user adjusts the values
  4. The script runs with the entered values, accessed via the Params variable

In the Advanced Snippet Editor, snippets can also be tested without the dialog — the @param lines contain default values that are used directly.


@param Syntax

// @param <type> <name> "<label>" [attribute=value ...]

Required fields:

Part Description
<type> Data type: int, float, string, bool, color, enum
<name> Variable name in the script (no spaces, CamelCase recommended)
"<label>" Display name in the dialog (in quotes)

Optional attributes:

Attribute Description Example
default= Default value default=200
min= Minimum value (int/float) min=10
max= Maximum value (int/float) max=500
options= Selection options (enum only, separated by \|) options="Small\|Medium\|Large"
tooltip= Hint text in the dialog tooltip="Width in pt"

Types

int — Integer

// @param int Teeth "Number of teeth" default=12 min=4 max=32

In the script:

int teeth = Params.GetInt("Teeth");

float — Decimal number

// @param float Size "Size (pt)" default=200 min=50 max=600

In the script:

double size = Params.GetFloat("Size");

string — Text

// @param string Title "Label" default="Phase 1"

In the script:

string title = Params.GetString("Title");

bool — Yes/No

// @param bool WithShadow "Show shadow" default=false

In the script:

bool withShadow = Params.GetBool("WithShadow");

color — Color

// @param color FillColor "Fill color" default=#4A90D9

In the script:

var color = Params.GetColor("FillColor");
int rgb = System.Drawing.ColorTranslator.ToOle(color);

Color default as #RRGGBB or color name (Red, Blue, White …).

enum — Selection from list

// @param enum Style "Style" options="Simple|Double|Dashed" default=Simple

In the script:

string style = Params.GetString("Style");
// Comparison:
if (style == "Double") { ... }

Full Example

// @param int    Teeth     "Number of teeth"  default=12 min=4 max=32
// @param float  Size      "Size (pt)"        default=200 min=50 max=500
// @param float  Left      "Left (pt)"        default=100 min=0
// @param float  Top       "Top (pt)"         default=80  min=0
// @param color  Fill      "Fill color"       default=#8264C8
// @param color  Line      "Line color"       default=#5A3CB4
// @param bool   WithHole  "With center hole" default=true
// @help https://docs.ppptools.ch/en/helper-example-gearwheel

int    teeth    = Params.GetInt("Teeth");
double size     = Params.GetFloat("Size");
double left     = Params.GetFloat("Left");
double top      = Params.GetFloat("Top");
var    fillC    = Params.GetColor("Fill");
var    lineC    = Params.GetColor("Line");
bool   withHole = Params.GetBool("WithHole");

int fillRgb = System.Drawing.ColorTranslator.ToOle(fillC);
int lineRgb = System.Drawing.ColorTranslator.ToOle(lineC);

// ... shape code ...

With // @help <url>, a link to the snippet's documentation page can be stored. In the @param dialog, a ? button will then appear that opens the URL in the browser.

// @help https://docs.ppptools.ch/en/helper-example-gearwheel

Params in the Script

The Params accessor is always available in the script. If a name is called that was not filled in the dialog, the method returns the default value.

Method Return type Description
Params.GetInt("name") int Integer parameter
Params.GetFloat("name") double Decimal parameter
Params.GetString("name") string Text parameter
Params.GetBool("name") bool Boolean parameter
Params.GetColor("name") System.Drawing.Color Color parameter

All methods accept an optional second argument as a fallback:

int teeth = Params.GetInt("Teeth", 8);   // fallback = 8

Testing in the Advanced Snippet Editor

In the Advanced Snippet Editor, clicking ▶ Run does not show a dialog — the default values from the @param lines are used directly. This allows snippets to be developed and tested quickly.

Use 🔍 Analyse → Analyse Code to see all recognized @param parameters and check for syntax errors.

Advanced Snippet Editor


Parameterized Example Snippets

Snippet Parameters
Gear Wheel Number of teeth, size, position, fill and line color
Post-it Size, position, colors, text
Persona Size, position, skin color, hair color