Custom application settings

I’m from the dotnet world and is moving towards Ignition,

In dotnet appsettings.json is used for various types of settings for the application where I can add custom information. Usually there is different versions of it, production and development.

What I would like is to have some general settings saved that are used in the project, some constants or paths to api and such.

I would prefer to use proper way to do things in the Ignition world, so what I am asking is if there is a prefered way to save custom static settings for a perspective application, a good practice.

You can use JSON in a file in the install folder (parent of the data folder) and pull it in at the top level of a project script module, holding it in a top-level variable. These act as constants (or caches). Keeping the file out of the data folder ensures it does not get caught up in a gateway backup.

2 Likes

Another approach, if you don't want to do the file reading/writing yourself (and only have simple string keys to store)

You could use the technique Kevin outlines in this post:

To set up arbitrary system properties (they can have whatever name you want) and then retrieve them in scripting via system.util.getProperty.

I'd use Phil's approach if you need to store anything more complex than a handful of top-level variables that are strings or can be easily type-coerced from string, like booleans/integers.

2 Likes