ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. 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.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 04-10-2011
Chris Moon's Avatar
Chris Moon Chris Moon is offline
Flexsim User
 
Join Date: Feb 2011
Location: Atlanta
Posts: 14
Downloads: 18
Uploads: 0
Thanks: 8
Thanked 0 Times in 0 Posts
Rep Power: 112
Chris Moon is on a distinguished road
Default Change Global Variable Permanently

Hello.
I am trying to find a way to code in GUI changing global variable permanently.
Right now, the GUI code works like below.
If I click the set button, this set button has a trigger "onPress."
Here, onPress, I coded "globalVariable = 1;"
However, the default setting of this globalVariable is 0.

If I open the script window and check this value after I click the set button,
the value is changed.
But if I just open the menu > tool > global variable and see the value of this globalVariable there, the value is still 0.

Is there any way to hard code to change this default setting value of globalVariable so that the change should be set even if I reopen the model?

Thank you.
  #2  
Old 04-10-2011
Kris Geisberger Kris Geisberger is offline
Flexsim Canada, Forum Moderator
 
Join Date: Aug 2007
Location: Canada
Posts: 209
Downloads: 54
Uploads: 1
Thanks: 99
Thanked 389 Times in 133 Posts
Rep Power: 451
Kris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud of
Default set initial value of global variable

To set the initial value of the 4th ranked global variable to a value of 55 you could use:

setnodestr(last(node("/Tools/GlobalVariables/4",model())),"55");

Note that the value is a string, and it will NOT set the current value of the global variable... you know how to do that. However, this will stick if the model is saved and reopened.

Explore the model Tree under Tools/GlobalVariables to understand why this works.

Also, some commands you might want to look into:
refreshglobalvariables()
numtostring()

Also, this post:
/threads/thread729

The Following User Says Thank You to Kris Geisberger For This Useful Post:
Chris Moon (04-11-2011)
  #3  
Old 04-11-2011
Chris Moon's Avatar
Chris Moon Chris Moon is offline
Flexsim User
 
Join Date: Feb 2011
Location: Atlanta
Posts: 14
Downloads: 18
Uploads: 0
Thanks: 8
Thanked 0 Times in 0 Posts
Rep Power: 112
Chris Moon is on a distinguished road
Default Thanks, Kris Geisberger

I really appreciate it.

Kris Geisberger,
I have one more question for you.
I know the code below works for 4th ranked global variable.
setnodestr(last(node("/Tools/GlobalVariables/4",model())),"55");

What if the 5th ranked global variable (AvgNum) is double array and I want to change the 2nd array value of this global variable(AvgNum[2]),
what code should I use?

I look forward to your answer.
  #4  
Old 04-11-2011
Kris Geisberger Kris Geisberger is offline
Flexsim Canada, Forum Moderator
 
Join Date: Aug 2007
Location: Canada
Posts: 209
Downloads: 54
Uploads: 1
Thanks: 99
Thanked 389 Times in 133 Posts
Rep Power: 451
Kris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud of
Default

You will see in the attached screenshot that the Data node is the last (3rd) child node of a given variable. The 2nd variable in this case is a double array of 4, and you can see that the Data node of the 2nd variable has 4 child nodes to hold the initial values of the array.

I'll give examples for setting the 4th initial value of the 2nd variable (a double array).

setnodestr(rank(last(node("/Tools/GlobalVariables/2",model())),1),"55");

setnodestr(node("/Tools/GlobalVariables/2/3/1",model()),"55");
Attached Thumbnails
Click image for larger version
Name:	GlobalVariables tree.jpg
Views:	153
Size:	12.0 KB
ID:	1345  
The Following User Says Thank You to Kris Geisberger For This Useful Post:
Chris Moon (04-11-2011)


Thread Thread Starter Forum Replies Last Post
global variable in DLL (UserFuncs.h) Esther Bennett Q&A 7 09-12-2012 07:02 PM
Global variable & task sequence Chris Moon Q&A 1 03-02-2011 10:46 AM
Show global variable as line graph in Recorder Congshi Wang Q&A 1 12-08-2010 01:22 AM
Global variable as experiment variable Matthias Hofmann Q&A 3 09-08-2009 09:42 AM
Display Global Variable Sung Kim Q&A 4 02-24-2008 11:24 PM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.