There are some syntax changes in FlexSim 2017. Here’s a quick summary of the important stuff:
- We’ve made an enormous, comprehensive update to our FlexScript language.
- All FlexScript in models created prior to FlexSim 2017 will still execute just fine… as long as your script was correct in the first place!
Now that you’re aware of the update—and that fact that your pre-FlexSim 2017 models will still work—let’s dig a little deeper into the FlexScript syntax, something we refer to internally as “dot syntax.” We’ll cover how it works and the reasons why the change was made in the first place.
Dot syntax? What’s that?
In FlexSim 2017, scripting is more object-oriented than in previous versions, which makes the code more streamlined and intuitive. You used to define logic in FlexScript using a library of global commands; here’s what it looked like to get a label from a token in Process Flow:
getlabel(getlabel(token, “item”), “weight”);
Here’s what that looks like using dot syntax:
Little more streamlined, isn’t it? Dot syntax is focused on entities—most commonly 목, 토큰, and “current”—and they all have three important characteristics:
- 등록, which is the data that controls aspects such as location, size, and color. Dot syntax lets you access this data.
- 행동 양식, which are commands that do something or change a property value (set speed, change location, etc.).
- 레이블, those dynamic, custom properties we all know and love.
So, when you see an expression written in FlexSim’s new dot syntax, it’s easy to interpret what it’s saying. The dot always means “access,” which allows you to access properties and methods associated with objects and variables. Take the following line as an example:
In this example, “current” is a reference to a 3D object we’re currently working with. A dot signifies a property we’re trying to access: the object’s name. Another dot calls a method to check if that name starts with the string “Processor.”
So why make syntax changes in FlexSim now? There are actually three critical benefits as a result of the dot syntax update.
Better, simpler scripting
As you saw in the above example, dot syntax expressions have a logical structure that’s easier to follow. It also carries a few other benefits that should improve scripting in the future. One is that dot syntax is more 동적. Labels, which change or may not even exist during portions of a model run, used to require special treatment. Now, dynamic properties like labels work just like methods and static properties.
다음과 같은 표현
token.SomeLabel.AnotherLabel? They’re possible now.
The other benefit is that the management of properties and methods (versus the old commands) just got a lot less complicated. This could empower our amazing developers to add new methods more frequently, and methods overall will require less parameters.
Simulation speed boost
That’s right, simulation runs have the potential to go much faster, and it’s a direct result of the scripting update in FlexSim 2017.
The reason? All FlexScript is now compiled to machine code and executed directly—avoiding needless interpretation makes things more efficient, leading to faster processing of simulation events.
The smartest Autocomplete yet
Finally, this change has enabled us to make some huge improvements to our built-in Autocomplete, which now provides you with a list of properties and methods to access as soon as you type a dot. You’ll also be happy to know that the Autocomplete is a little more forgiving these days—even when you misspell or are just trying to get close to a name that’s on the tip of your tongue, the closest possible matches will still appear.
It’s also smarter than ever before. Have you already declared some labels? Autocomplete will show those if they come up in the context of what you’re trying to do.
We truly believe that this update is a big step forward to helping FlexSim become the best simulation software it can possible be. Remember that if you ever need help getting familiar with dot syntax, our support team and worldwide user base can be found on FlexSim 답변 and would be more than happy to help.