question

Patrick Zweekhorst avatar image
1 Like"
Patrick Zweekhorst asked Jason Lightfoot edited

How to use the license function to check which license the user has?

For a module we are developing we want to check the license of the user. I would expect that the function license() returns one of the five macro values: 0 (LICENSE_TYPE_NONE), 1( LICENSE_TYPE_STANDARD ), 2 (LICENSE_TYPE_RUNTIME ), 3 ( LICENSE_TYPE_EDUCATIONAL ) or 4 ( LICENSE_TYPE_CUSTOM ). But this is not the case. The function returns some large six digit number. How can I check which type of license the user has?

Thanks in advance

FlexSim 17.0.0
licensedeveloper use
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
3 Likes"
Phil BoBo answered Jason Lightfoot edited

Use the licensehasfeature() command. Rather than trying to do it based on the license type (none, standard, runtime, etc.), you should focus on the particular feature (stochastics, commercialuse, createobjects, etc.) that is required for what you are doing.

Runtime doesn't have the createobjects feature:

licensehasfeature(CLF_CREATE_OBJECTS)

Educational doesn't have the commercialuse feature:

licensehasfeature(CLF_COMMERCIAL_USE)

Express doesn't have the stochastics feature:

licensehasfeature(CLF_STOCHASTICS)

The license() command returns a bit field of the various features that are available. The licensehasfeature() command does a bitwise-AND to determine whether a specific feature is available.

· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Patrick Zweekhorst avatar image Patrick Zweekhorst commented ·

Thanks for your answer

0 Likes 0 ·
andyru avatar image andyru commented ·
Is this still the correct way to check the license features? I don't see the `licensehasfeature` command in the command reference.
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ andyru commented ·

It's still in the command help, so should still be the supported method:

1690897283341.png

0 Likes 0 ·
1690897283341.png (9.2 KiB)