question

Kim Jh avatar image
1 Like"
Kim Jh asked Adrian Haws edited

How to save user command's code in text file with FlexScript?

Choose One
flexscriptuser commandstext file
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

The following code will open a new file in your FlexSim projects folder and then loop through all the user commands printing their code to the text file.

  1. treenode commands = node("MODEL:/Tools/UserCommands");
  2.  
  3. fileopen(concat(documentsdir(), "\\commands.txt"), "w");
  4.  
  5. for(int i = 1; i <= content(commands); i++) {
  6. fpt(gets(first(rank(commands, i)))); fpr();
  7. }
  8.  
  9. fileclose();
5 |100000

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