## How to use parameter buffer for polygons?

Parameter buffer can come in handy when you have to deal with “almost” alike polygons in your object.
You can read more about parameter buffer in the GDL Reference Guide.

If you use it to store the parameters of the command, you can add and remove points conditionally, without having to repeat the whole command with all variations.

Example:
Switch between simple rectangle and rectangle with semi-circle extension, depending on “bDrawArcSide” parameter. The number of polygon input parameters are different in the 2 cases (5 or 6).

Duplicating the polygon command (differences in line 2, 5, 6, 10 and 13):

```if bDrawArcSide then
poly2_B 6, 1+2+4, fillPenFg, fillPenBg,
0, 0, 1,
A, 0, 1,
A, B/2, 900,	! set centerpoint for arc
0, 180, 4000+1,	! set angle for arc
0, B, 1,
0, 0, -1
else
poly2_B 5, 1+2+4, fillPenFg, fillPenBg,
0, 0, 1,
A, 0, 1,
A, B, 1,
0, B, 1,
0, 0, -1
endif
```

Using parameter stack (no duplicate code parts):

```put	0, 0, 1,
A, 0, 1

if bDrawArcSide then
put	A, B/2, 900,	! set centerpoint for arc
0, 180, 4000+1	! set angle for arc
else
put	A, B, 1		! draw straight line
endif

put	0, B, 1,
0, 0, -1

poly2_B nsp/3, 1+2+4, fillPenFg, fillPenBg,
get (nsp)

```

This may be more useful with larger polygons.

Command and function pool:
POLY2_B
PUT
GET