How do I create an instance of a singleton?

Title says it all, really. I want to get hold of com.sun.star.util.thePathSettings which is defined as a singleton. But the documentation (either on the LO or AOO sites) doesn’t seem to have anything about how to use singletons. How do I get hold of it so I can look at the various paths?

Just writing com.sun.star.util.thePathSettings.Template doesn’t work, so I obviously have to create the instance before I can get hold of the attribute.

createUNOservice(“com.sun.star.util.thePathSettings”) doesn’t work either.

I’m using LO Basic.

I’m certainly missing something simple, but what is it?

a similar request for another singleton: tdf#97447

Hello @ptoye,

Please try the following:

Dim oPS Object
oPS=  GetDefaultContext().getByName( "/singletons/com.sun.star.util.thePathSettings" )

Brilliant. Thanks. Shame it doesn’t seem to be documented anywhere, at least on the LibO or AOO sites.

com.sun.star.util.PathSettings is an ordinary service.

pathSettings = createUnoService("com.sun.star.util.PathSettings")
MsgBox pathSettings.getPropertyValue("Template")

Thanks. Agreed. But I’m afraid that it doesn’t answer the question I asked. PathSettings is deprecated - see LibreOffice: PathSettings Service Reference

That’s why I asked about thePathSettings LibreOffice: thePathSettings Singleton Reference

The question is really about how to create a singleton, not necessarily about this particular one. Hence the title of the thread.

Good to know, but next time please include this kind of information in the original question. It’s important to describe what you’ve already discovered while researching the problem. See guidelines for asking.