question

Axel Kohonen avatar image
1 Like"
Axel Kohonen asked Adrian Haws edited

What do the searchfornode parameters mean?

Hi,

Could I get a better explanation of what the third and fourth parameter of the searchfornode command actually do? It seems that the findnr parameter could be if we take the first/second/etc. hit and the searchobjects parameter if the code searches through the internals (everything that is accessible in the tree with the > sign and not the +) of an object node. Is this correct?

Thank you!

Kind regards,

Axel

FlexSim 16.1.0
commandsearchfornode
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

Matthew Gillespie avatar image
3 Likes"
Matthew Gillespie answered Adrian Haws edited

The 3rd parameter, findnr, is where you specify which result you want if there are multiple nodes in the search that match the string you're searching for. For example:

searchfornode("command", node("MODEL:/Tools/UserCommands"), 1)

Searching the User Commands node for the word command would give me 4 nodes with the string "command" in it. The first result would be the UserCommands node itself. The second result would be command1 and I would have to pass in a 2 for the 3rd parameter to get it. This can also be useful for looping through all the results.

The 4th parameter tells the command whether or not it should search the object's data nodes (as you said, nodes accessible with the > sign).


commands.png (1.7 KiB)
· 1
5 |100000

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

Axel Kohonen avatar image Axel Kohonen commented ·

Hi @Matthew Gillespie,

Thank you! That makes sense. Would it be possible to get the information added to the commands reference in the next release as well as the help page for the command here on answers.flexsim.com i.e.

https://answers.flexsim.com/articles/14758/searchfornode-2.html?

Axel

0 Likes 0 ·