Set default values (or, equivalently, optional arguments)

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
Alkinew
Jr. Member
Jr. Member
Posts: 1
Joined: 12 Oct 2023, 04:37

Set default values (or, equivalently, optional arguments)

Post by Alkinew »

Hi,

Is there any way to set default values (or, equivalently, optional arguments) for method arguments? In our use-case we have methods with several arguments but in many cases it's only necessary to specify a few and the rest can be left to reasonable default values. Is there any way to support this behavior?
https://geometry-dashlite.io
I've been looking at the Method datatype that is used to define a method's InputArguments, but it doesn't include any fields which define the default value.

Thanks in advance.
Last edited by Alkinew on 13 Oct 2023, 02:04, edited 1 time in total.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Set default values (or, equivalently, optional arguments)

Post by Support Team »

Hi,

unfortunately setting default values in arguments of methods is not possible with our SDKs. The OPC UA Spec suggests some extra properties at the method object, which may be filled with default values or not (pretty much same behavior as in C++ coding standard).
However, solving this issue "generically" is quite complicated. That said it might be easier if your (specialized) Client, obtains such values by other means and pre-filling your specialized GUI yourself.

Note: if you have method with many (useless/default/no need to change) input-arguments, you may re-consider your method signature design and eventually split into different methods which contain just those arguments that belong to eachother and "must" be changed. But this is more an api design issue.

Note: for (simple) variable instances our SDKs do support setting default/initial values, but not for method arguments.
Best regards
Unified Automation Support Team

Post Reply