Libraries

Sometimes you create a model, or a part of a model, that you know you will need again in the future. For example, a tax calculation, check for an insurance or a set of questions about someone can all be used in several models. In such a case, you can turn your model into a library, thereby allowing you and others to use it in another model. This will save copy-paste errors, reduce maintenance time and offers a better overview of your models. We advise you to look up model flow if you have not done yet.

To analyze your libraries and check for problems, please see analyze your models.

An introduction to libraries

A libraries is, in principle, nothing more than (a part of a) model that is reusable. Think of it as a storage place with useful (parts of) models that you can put into any model you like with a couple of clicks. Furthermore, if you change the library, all models that use it will be updated as well!

A library is made from a graph that you created. You can then save that graph as a library, after which it becomes usable in all your models. Simply refer to it in a model, and you library will be called to whenever you want! In the next sections, we will show you how to create your own library and how to use it.

Creating your own library

Imagine you created a graph with a node personal_information, that has some questions in it for the end user. Now suppose, for the sake of this example, that you need these questions in a lot of models and are tired of creating them in each model every time. So, you decide to make a library of it.

the example node
the example node

Creating the actual library is really easy! Just right-click somewhere in the graph menu and select Save graph to library.

Creating the library
Creating the library

You will be presented with the screen shown below. For now, select Local library - we will explain the difference later. Select [OK], after which you will be asked to replace graph calls with library calls. This is only relevant if the model you use already uses the graph you are turning into a library. In most cases, Yes is the best option.

Naming the library
Naming the library

That’s it! You just created your very own library. In the next section, we’ll discuss how to use it, and in the last section we’ll explain the difference between local and central libraries.

Using libraries

Using libraries is also really easy. You can find the library button under [Graph > Libraries]. This will open up a screen with all central and local libraries.

Using a library in a model
Using a library in a model

In the window that pops up, you can now select the library you want to use. For now, select the personal_information library you just created.

Selecting the right library
Selecting the right library

Now you’ll see a library node added to your model with a green ribbon on it. You can now run the model and check whether everything works alright! To do so, the data inspector is quite useful. Furthermore, make sure that your library settings are set to the correct folder. An example screenshot with is shown below:

Library folder settings
Library folder settings

Now, every time you change the library model, the changes will also happen in any model that uses the library. This saves you a lot of time and you can quickly change numbers and add questions without having to change all models!

Local and central libraries

Libraries can be saved either on your own computer (local) or on a server (central, global). The main advantage of saving it globally is that others can use and update your library as well. This is especially useful if the libraries are used by more than one person. The problem is that it requires a bit of a technical setup. If you are interested in setting up your own library folder on a server, please contact us for more information.

The libgraph nodes

A library model communicates via the node libgraphin and libgraphout, which are automatically made when you create a library. The libgraphin node can be used to retrieve values with the function getvaluefromcallingnode() in the model that calls the library. While adding a library, the variables that are expected by the library, are already retrieved for you in the node where the library is called. Furthermore, values could also be retrieved from a library model and used in the main model again. This can be done by using getvaluefromlib().

The node libgraphout can be used to give results or present data to the user of the library in a similar fashion to the libgraphin node.