question

Patryk avatar image
0 Likes"
Patryk asked Ben Wilson answered

How to check device name

Is it possible to display or check the device name in FlexSim?

1670961475416.png

FlexSim 22.2.2
scriptusing codefunctions
1670961475416.png (5.8 KiB)
· 2
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·
Because it is a data of system your approach could be to evaluate it by command of net in command console. Or you look into view tree, if it is data of license information in view tree.
0 Likes 0 ·
Andrew O avatar image Andrew O commented ·

Hi @Patryk, was Joerg Vogel's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·
Ben Wilson avatar image
0 Likes"
Ben Wilson answered

I've played a bit with code like the following:

string cmd = programdatadir()+"gethostname.bat";
string hostfile = programdatadir()+"hostname.txt";
fileopen(cmd, "w");
fpt("hostname > \""+hostfile+"\"");
fileclose();
runprogram(cmd);
fileopen(hostfile, "r");
string hostname = filereadline();
fileclose();
return hostname;

It isn't ideal. It works best if FlexSim is running with elevated privileges. If not, sometimes it takes running it twice to actually read the hostname from the written file.

It also flashes a black command prompt window, and sometimes makes FlexSim lose window focus.

If anything, it is a starting point to discover maybe a better way of doing it.

Joerg's C++ suggestion might be the best way. You could encapsulate the functionality you need in a DLL, then call it from FlexSim and get the value directly, rather than the above workaround writing and reading to files and launching a command prompt.

Good luck!

5 |100000

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

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered
5 |100000

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