param_persistent()

Marks a global parameter as persistent or non-persistent.

Global parameters whose names start with an underscore (_) can be made persistent.

This function takes a parameter name and an bool flag indicating whether to add or remove the parameter from the persistent storage.

If the parameter name does not start with an underscore or is empty, the function returns False (indicating it is not persistent).

Syntax

planetcnc.param_persistent(name, add)

Parameters

Parameter Type Description
name str The name of the global parameter.
add bool If add is True and the parameter is not already in the list, the parameter is added.
If add is False and the parameter is found in the list, it is removed.

Return Value

Examples

#! /usr/bin/env python 
 
import planetcnc
 
# Mark a parameter as persistent.
result = planetcnc.param_persistent("_machine_speed", 1)
if result:
    print("Parameter '_machine_speed' is now persistent.")
else:
    print("Failed to mark parameter as persistent.")
 
# Later, remove the persistence.
result = planetcnc.param_persistent("_machine_speed", 0)
if result:
    print("Parameter '_machine_speed' persistence removed.")
else:
    print("Parameter was not persistent.");

See also

param_get
param_set
param_remove
param_persistent