This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.

Go Back   FlexSim Community Forum > FlexSim Software > User Development
FAQ Downloads Calendar Search Mark Forums Read

User Development User developed add-ons to Flexsim

Thread Tools Display Modes
Old 08-04-2012
AlanZhang's Avatar
AlanZhang AlanZhang is offline
Flexsim Super Moderator
Join Date: Aug 2007
Location: CA
Posts: 289
Downloads: 64
Uploads: 0
Thanks: 88
Thanked 91 Times in 47 Posts
Rep Power: 220
AlanZhang is a jewel in the roughAlanZhang is a jewel in the roughAlanZhang is a jewel in the rough
Default Save and Restore Tabs in Code Editor

Hi All,

I thought this might be a good feature for future FlexSim release. So I posted here.

The current Code Editor in FlexSim does not save all tabs. Once you close it. It is gone. I made the piece of code below to save the code tabs and then later you can restore it. Once you have a lot of code tabs, you will find it will be a little bit hard to find the tab that you want. Therefore, I also add a feature that you can choose to sort the tabs when you save it. I found this is very useful in our simulation model development.

You may put the code below into a customized toolbar or a user command. This should work for FlexSim 5 and 6.

Let me know if this helps you a little or you have any comments.

Enjoy FlexSim coding.

// This tool save or restore the code tabs in code editor
// You may put this into your Customize Toolbar under File|Global Preferences, or
// put this into a user command or customized toolbar
#define SAVE 1
#define RESTORE 0
#define CANCEL -1

int saveOrRestore = msg("Code Editor Restore", concat("Yes to save tabs.", strascii(13), 
		"No to restore tabs", strascii(13), "Cancel to do nothing"), 3);

treenode toolsNode = node("/Tools", model());
treenode editorNode = node("/CodeEditor", toolsNode);

// find the current active code editor view
treenode activeViews = node("/active", views());
treenode codeEditorView = NULL;
for(int i=1; i<= content(activeViews); i++) {
	if(stringsearch(getnodename(rank(activeViews, i)), "picklisteditwindows", 0)>=0)
		codeEditorView = rank(activeViews, i);

// Save or restore code tabs according to user's choice
	case SAVE:
			msg("Error", "Could not find Code Editor Window!");
			return 0;
			if(msg("Overwrite?", "Code tabs saved before. Overwrite?", 4))
				return 0;
		} else {
			editorNode = last(toolsNode);
			setnodename(editorNode, "CodeEditor");

		// save code tabs into an array
		treenode tabs = node("/tabcontrol", codeEditorView);
		int numTabs = content(tabs);
		stringarray codePaths = makearray(numTabs);
		for(int i=1;i<=numTabs;i++)
			treenode tab = rank(tabs, i);
			treenode obj = node(">objectfocus", tab);
			string path = nodetopath(tonode(get(obj)), 1);
			codePaths[i] = path;
		if(msg("Sort?", "Do you want to sort code tabs before save?", 4))
			// sort code tabs
			for(int i=1;i<=numTabs-1;i++)
				int m = i;
				for(int j=i+1;j<=numTabs;j++)
					if(stringcompare(codePaths[m], codePaths[j])>0)
						m = j;
					string tmp = codePaths[i];
					codePaths[i] = codePaths[m];
					codePaths[m] = tmp;
		// save code tabs into model/Tools
		for(int i=1;i<=numTabs;i++)
			nodeadddata(last(editorNode), DATATYPE_STRING);
			setnodestr(last(editorNode), codePaths[i]);
	case RESTORE:
			msg("Error", "Could not find saved code tabs!");
			return 0;
		for(int i=1; i<=content(editorNode);i++) {
			string path = getnodestr(rank(editorNode, i));
			createview("VIEW:/standardviews/picklistedit", path, "");
Reply With Quote
The Following 2 Users Say Thank You to AlanZhang For This Useful Post:
Hao Zhou (08-04-2012), Jay Chou (07-21-2013)
Old 08-04-2012
Hao Zhou's Avatar
Hao Zhou Hao Zhou is offline
Flexsim User
Join Date: Sep 2010
Location: Long Beach
Posts: 66
Downloads: 56
Uploads: 0
Thanks: 78
Thanked 43 Times in 25 Posts
Rep Power: 141
Hao Zhou will become famous soon enoughHao Zhou will become famous soon enough

Thank you! This is a cool functionality!
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SAve and restore the state of the model during a simulation run Stephan Seidel Q&A 3 04-16-2012 08:50 AM
problem with recycle and restore item juan alberto Q&A 1 03-09-2011 06:49 AM
Add all open tabbed Trigger editor in V5 JMEngelhart Gripes and Goodies 1 08-14-2009 09:57 AM
Things I like about v4.3 (autocompletion, billboards, shortcuts, relative media paths, code editor) Tom David Gripes and Goodies 1 03-28-2008 02:34 AM

All times are GMT -6. The time now is 02:17 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.