ATTENTIONThis 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 |
#1
|
|||
|
|||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
|||
|
|||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
|||
|
|||
#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
|
||||
|
||||
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 |