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 > Gripes and Goodies
FAQ Downloads Calendar Search Mark Forums Read

Gripes and Goodies Software problems and suggestions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-25-2013
brett forbes brett forbes is offline
Flexsim User
 
Join Date: Oct 2011
Posts: 34
Downloads: 0
Uploads: 0
Thanks: 27
Thanked 3 Times in 2 Posts
Rep Power: 103
brett forbes is on a distinguished road
Thumbs up Proposal for Flexscript Extensions - OOP Collections and pointers in tabsles

Hi,

I have been using Flexsim for only a short while, and yet am very impressed with the architecture and approach of Flexscript. I offer below some comments which I believe would significantly improve the language, and ease development.

Background
While the underlying model in Flexsim is object oriented, the programming in Flexscript is more procedural. This is not a problem normally as the code is generally concise, although there are some situations where it is not (e.g. table operations).

In general, all of the needed data types are available and nicely integrated, yet Flexscript lacks a key capability common to most OOP languages (e.g. Scheme, Lisp, Delphi etc), in particular the use of collections.

Collections are a critical part of OOP, as they enable the data to be aggregated into objects, which is critical when dealing with complex situations. In particular collections contain different types of data, can be indexed so they point to table rows, and can contain other collections and non-indexed data.

There are many types of collections used in diferent languages, and I offer below some comments on how the most simple collection type, commong to Lsip, Scheme and Delphi, could be used to speed programming and increase performance of the Flexsim models.

The lack of a collection makes dealing with tables (e.g. global tables, database tables) and the many types of data inherent in complex models somewhat clumsy, resulting in somewhat obtuse code. Further the lack of collections makes the handling of large numbers of pointers difficult resulting in the underlying architecture requiring many calls which parse the tree based on text strings, with the attendant performance penalties.

Proposal
I propose below that Flexscript is extended slightly in two dimensions.

Firstly, some additional table commands and capabilities are added so that filling out tables is not as slow or cumbersome (i.e. requiring many, many lines).

Secondly, that Flexscript introduces the simplest collection class, basically a record or a struct (i.e. name depends on the language where you may have used this approach before).

I believe that with these two simple additions, I can demonstrate that you could significantly speed model execution, and make the Flexscrip code even more readable and concise.

1. Enhancements to Existing Table Capabilities
I note that the table structure is the best data structure available in Flexscript, as it is completely dynamic, unlike arrays, enabling you to expand it as necessary. I really like the table and offer some comments on improvements below, in particular the need to add explicit pointer support.

One of the biggest problems in using tables in more complex instances (e.g. setting up section tables for conveyors or pipes) is that each cell in the table must be set individually. Thus if you want to setup a new row in a table with 8 columns, you need at least nine lines of code to achieve it.

This could be improved with some simple additions:
1. A new flag on the AddTable Row command which enables you to copy the values of the last row into the newly added one. This would be very useful with pipes as many of the columns are always the same (e.g. thickness, show joint etc).
2. A CopyTableRow command, enabling you to copy data from one row to another. This has similar functionality to the above command, but is useful in different circumstances.
3. A SetTableRow command, which enables you to set the values for all columns of a single row in a single command
4. Finally, explicit support should be provided for treenodes inside global tables (i.e. select three different data types for any column), and this would enable you to tighten up paramater checking inside the table commands

2. Data Collections
This assumes the four changes listed above are provided.

I propose that the simplest form of a data collection is provided, that of a record or a struct, which can contain multiple basic data types (i.e. double, integer, treenode). I propose that this basic concept is extended as follows:

1. The record can contain multiple data types (ie. integer, double, treenode)
2. The data variables are accessed through the dot nomenclature (i.e. myrecord.datavalue)
3. The records can contain other records ad infinitum
4. The record is setup so that it can use an index, inside square brackets like an array, which enables it to index a row in a table (i.e. myrecord[i].datavalue)
5. The record can contain non-indexed variables (i.e. do not connect to the table)


Proposal Outcomes
If my proposal is adopted, I believe that it would massively change both the efficiency of coding and the efficiency of running the models. Consider the following:
1. By adding explicit support for treenode pointers in the global tables you enable large models to simply and easily keep track of all objects by using tables.
2. By setting up the collection as proposed, all user data can be stored and accessed in object-oriented form
3. By setting up the collection as proposed, the record then becomes the main front end for any table (i.e. global table, database, excel etc), just like in traditional OOP languages (i.e. older than C++)
4. Using the dot nomenclature to access variables inside the collection does not conflict with any current Flexscript standard and is an easy add-on. It is also easy to parse these objects in the script writer and enable people to select the right item from a drop down list once the dot has been pressed.
5. Using the index to the record enables the records to be a simple front end to any table
6. Having variables within the record that do not connect to the table enables the programmer to deal with the situation where some data for an object is a property (i.e. does not change), whereas other data is variable (i.e. needs to be read periodically).
7. A record constructed at the begining of the program could contain the entire tree as a pointer set, enabling one to point at any object without having to do a text string parse (i.e. much faster)

Summary
Essentially, I propose some changes to the table capabilities to enable it to be highly versatile. While it is great at present it lacks explicit support for pointers and is a bit clumsy when adding lost of data. Further I propose that a data collection be designed that would enable OOP data handling to be utilised. There are huge coding and performance benefits to such a scheme, and few downsides (i.e. apart from the programming effort).

Frankly, there are too many benefits of the scheme listed above to enumerate, but I would be happy to enagage in further discussion on this topic.

Thanks

Brett
Reply With Quote
The Following User Says Thank You to brett forbes For This Useful Post:
Anthony Johnson (03-26-2013)
 

Tags
flexscript extensions

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
convert C++ code into flexscript ameen shabeer Q&A 2 12-08-2012 09:52 AM
about flexscript Kang Han Q&A 2 10-03-2008 09:21 AM
Static Variables in Flexscript? Joe Allen Q&A 7 09-18-2008 12:43 PM
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


All times are GMT -6. The time now is 03:38 PM.


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