Remember last input

Hello Forum,
i was wondering, if you make a Grasshopperscript and start it with Grasshopper-Player or make it as a funcion with the scripteditor how is it possible to make the script remember the last input value just like any other Rhino function (for example circle will remeber the last input diameter and you dont need to input it for the next circle you just make a rght click to accept the value, even after a restart of Rhino it is still there).

Hi,

In a script a couple of functions like this would persist a value between Rhino restarts:

// #! csharp
using System;
using Rhino;

const string settingsForPatrik = "patrik_r";

Action<string, string> SetSetting = (k, v) => {
    if (!PersistentSettings.RhinoAppSettings.TryGetChild(settingsForPatrik, out PersistentSettings child))
    {
        child = PersistentSettings.RhinoAppSettings.AddChild(settingsForPatrik);
    }
    child.SetString(k, v);
};

Func<string, string> GetSetting = k => {
    string value = null;
    if (PersistentSettings.RhinoAppSettings.TryGetChild(settingsForPatrik, out PersistentSettings child))
    {
        if (child.TryGetString(k, out string v))
        {
            value = v;
        }
    }
    return value;
};

//SetSetting("myKey", "Hello");
string myValue = GetSetting("myKey");
Console.WriteLine(myValue == null ? "none" : myValue);