For the complete documentation index, see llms.txt. This page is also available as Markdown.

Counter

With a counter, you maintain a numerical value, for example a production count or sequence number. You can increment, decrement, and reset the count. You must create an instance of the counter to use it. The code class name is Counter.

create

Creates a new counter instance, optionally starting from an initial value.

Parameters

Input
Description
Type

initial

The number to start counting from. Default 0.

integer

Output

Returns the name of the created instance.

Example

# initial
10

delete

Deletes a counter instance.

Parameters

None.

Output

Returns true upon removal.

Irreversible action

increment

Increments the counter's value by one.

Parameters

None.

Output

Returns the new count as an integer.

decrement

Decrements the counter's value by one.

Parameters

None.

Output

Returns the new count as an integer.

reset

Resets the counter back to its initial value. You can optionally provide a new initial value to use for this and all future resets. A value of 0 cannot be set as a new initial value; in that case the counter resets to the previously configured initial value.

Parameters

Input
Description
Type

initial

An optional new initial value.

integer

Output

Returns nothing.

Example

getCount

Retrieves the current value of the counter.

Parameters

None.

Output

Returns the current count as an integer.

Last updated

Was this helpful?