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 09-18-2008
Joe Allen Joe Allen is offline
Flexsim User
 
Join Date: Jul 2008
Posts: 80
Downloads: 2
Uploads: 0
Thanks: 34
Thanked 5 Times in 3 Posts
Rep Power: 151
Joe Allen is on a distinguished road
Default Static Variables in Flexscript?

Does anyone know if it is possible to make use of static variables in Flexscript. I'm trying to squeeze every last drop of performance from my model and I thought using a static variable to read/write an integer value during the running of the model would be much more efficient than creating a global variable to handle the same thing. Any ideas?
  #2  
Old 09-18-2008
Martijn van Oostenbrugge's Avatar
Martijn van Oostenbrugge Martijn van Oostenbrugge is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Posts: 71
Downloads: 12
Uploads: 0
Thanks: 44
Thanked 44 Times in 24 Posts
Rep Power: 268
Martijn van Oostenbrugge is a name known to allMartijn van Oostenbrugge is a name known to allMartijn van Oostenbrugge is a name known to allMartijn van Oostenbrugge is a name known to allMartijn van Oostenbrugge is a name known to allMartijn van Oostenbrugge is a name known to all
Default

If speed is an issue to you I would still consider to make your model completely c++ (install the free visual c++ 9.0 express edition) and compile the model. This will definitely increase the speed of your simulation.

**Update**
Just read your other thread in which my collegue already gave you this advice. Maybe you should have put this in the other thread so it's clear to everyone what the track was to this question.

Martijn
  #3  
Old 09-18-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

You can try using #define values. They are defined in the Global Macros section of the Global Variables GUI. I commonly use these to define ranks of Global Tables, Labels, Columns and Rows.

Brandon
__________________
thats not normal.
  #4  
Old 09-18-2008
Joe Allen Joe Allen is offline
Flexsim User
 
Join Date: Jul 2008
Posts: 80
Downloads: 2
Uploads: 0
Thanks: 34
Thanked 5 Times in 3 Posts
Rep Power: 151
Joe Allen is on a distinguished road
Default

I should have only written the first sentence. I would still like to know how (if possible) to use static variables in Flexsim. Can this be done?

**Update**
I didn't see your post Brandon. Thanks... I'll try that suggestion.
  #5  
Old 09-18-2008
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

Yes, you can use static variables in Flexsim if you use C++.

If you toggle the code as C++ and compile, then you can type C++ code into the text instead of Flexscript, including static variables.
  #6  
Old 09-18-2008
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

Your question was answered by Martijn, but you didn't particularly phrase the question to get the answer you wanted.

Your first question asked if you can use static variables in Flexscript, and the answer is "No".

Your next question asked if you can use static variables in Flexsim, and the answer is "Yes. Use C++."

If you want to squeeze every last drop of performance out of your model, use C++ instead of Flexscript. You can access all the features of C++ from Flexsim, including static variables.
The Following User Says Thank You to Phil BoBo For This Useful Post:
Joe Allen (09-18-2008)
  #7  
Old 09-18-2008
Joe Allen Joe Allen is offline
Flexsim User
 
Join Date: Jul 2008
Posts: 80
Downloads: 2
Uploads: 0
Thanks: 34
Thanked 5 Times in 3 Posts
Rep Power: 151
Joe Allen is on a distinguished road
Default #define

I'll be the first to admit that I'm a bit of a newbie to this. I'll try and be more specific about what I'm asking in future posts. I'm trying to keep my code compatible with both C++ and Flexscript but plan to convert ot C++ at the end for the performance boost.

Question on #define:
Once a variable is defined this way, can the value of it be reassigned during runtime or does it function more like a const variable?
  #8  
Old 09-18-2008
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

It functions more like a const variable.

Well, you can #define the same macro within the scope of a function call and it will use that new value for the scope of the function, but it will revert back to the old value once it leaves that function.
The Following 2 Users Say Thank You to Phil BoBo For This Useful Post:
Jörg Vogel (09-19-2008)


Thread Thread Starter Forum Replies Last Post
size of arrays in Flexscript Steven Hamoen Q&A 13 06-23-2008 01:04 PM
Clean Flexscript Steven Hamoen Q&A 1 04-04-2008 07:00 AM
Static can count edgar Q&A 2 09-25-2007 09:25 PM
Adding member eith Flexscript Lars-Olof Leven Q&A 2 08-22-2007 08:00 AM
How to display 3D text/shapes in a static position regardless of the view angle. Regan Blackett Tips and Tricks 0 08-03-2007 10:51 AM


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.