File MIES_PackageSettings.ipf

LOG Routines for dealing with JSON log files

PS Routines for dealing with JSON settings

See https://jsonlines.org and Line-delimited JSON for background.

In short the log will contain a complete JSON document in each line. The lines are separated by \n.

Functions

variable PS_Initialize(string package)

Initialize the PackageFolder symbolic path.

variable PS_GenerateSettingsDefaults()

This functions should return a JSON ID with the default settings.

variable PS_ReadSettings(string package, PS_GenerateSettingsDefaults generateDefaults)

Return a JSON ID with an opened JSON settings file.

Caller is responsible for releasing the document.

variable PS_WriteSettings(string package, variable JSONid)

Write the settings from JSONid for package to disc.

Call this function in BeforeExperimentSaveHook to write the settings to disc

string PS_GetSettingsFolder_TS(string package)

Return the absolute path to the settings folder for package

   Threadsafe variant which requires the symbolic path `PackageFolder` created by
   PS_Initialize() to exist.

   The returned folder location includes a trailing colon (":")
string PS_GetSettingsFolder(string package)

Return the absolute path to the settings folder for package creating it when necessary.

The returned folder location includes a trailing colon (“:”)

static string PS_GetSettingsFile(string package)

Return the absolute path to the JSON settings file for package

static variable PS_ApplyStoredWindowCoordinate(variable JSONid, string win)

Move the window to the stored location.

static variable PS_RegisterForCoordinateSaving(string win, string name)

Add user data to mark the window as using coordinate saving.

variable PS_RemoveCoordinateSaving(string win)

Remove user data related to coordinate saving.

static variable PS_StoreWindowCoordinates(variable JSONid)

Store the coordinates of all registered windows in the JSON settings file.

The windows must have been registered beforehand with PS_InitCoordinates().

variable PS_StoreWindowCoordinate(variable JSONid, string win)

Store the window coordinates of win in the JSON settings file.

The window must have been registered beforehand with PS_InitCoordinates().

variable PS_InitCoordinates(variable JSONid, string win, string name, variable addHook = defaultValue)

Add support for window coordinate storing and loading.

Takes care of:

  • Marking the window as using it with the given name

  • Adding a hook to store the coordinates on window killing

  • Read the current coordinates from the JSON settings file and applying them

Parameters:
  • JSONid – JSON document with settings

  • win – window name

  • name – name to store the window under (especially useful for windows which are renamed to their locked device)

  • addHook – [optional, defaults to true] Add a window hook to store the coordinates on window killing. Users with their own kill event handling must pass addHook=0.

variable PS_SerializeSettings(string package, variable JSONid)

Write the current JSON settings to disc.

Caller must invalidate JSONid after return.

variable PS_OpenNotebook(string package, variable JSONid)

Caller must invalidate JSONid after return.

variable PS_FixPackageLocation(string package)

Fixup the settings and log file location for Igor Pro prior to 0855279d (Fix package folder location on disk, 2021-04-01).

Package JSON:

  • Incorrect is moved to the correct location

JSONL logfile:

  • Incorrect is moved to the correct location only if the correct does not exists

  • If the correct does exist as well, the incorrect is read and appened to to the correct one

Variables

static const string PS_STORE_COORDINATES = "JSONSettings_StoreCoordinates"
static const string PS_WINDOW_NAME = "JSONSettings_WindowName"
static const string PS_COORDINATE_SAVING_HOOK = "windowCoordinateSaving"