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 11-28-2008
Nico Zahn's Avatar
Nico Zahn Nico Zahn is offline
Flexsim User
 
Join Date: Sep 2007
Location: Bingen am Rhein, Germany
Posts: 179
Downloads: 19
Uploads: 4
Thanks: 66
Thanked 60 Times in 32 Posts
Rep Power: 201
Nico Zahn has a spectacular aura aboutNico Zahn has a spectacular aura about
Default Set datatype of a table cell

Hi,
is there any easy way to set the datatype of a specific table cell?
I have to import Data from a textfile and I want to write the data into a global tabel.So defining a Global table with mixed Datatypes has to be done manually or can I assign a datatype by a command? I could write a usercommand and use the nodeaddata(); to assign the right datatype to the tablecells...but if theres a more easy way?
__________________
kind regards Nico.
  #2  
Old 11-28-2008
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Nico,

Do you know the command gettablecell? That gives you a direct access to a individual cell.

If you want to know more about how Flexsim does it, take a look at the cppfunctions of the ExcelAuto object that can be found in the library. There is an importdata function and you can see how flexsim does the importing and determining what datatype it is.

Steven
  #3  
Old 11-28-2008
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

Also, if you're setting up the table size and format by hand (code) , then using settablesize() will allow you to specify the datatype of new columns by using the optional fourth parameter. By using a numner of settablesize calls, a mixed format table can be created. Each settablesize call is then extending the table by a block of columns with the same datatype.

When you subsequently add rows, the datatypes of the columns are copied to the new rows.
  #4  
Old 11-28-2008
Nico Zahn's Avatar
Nico Zahn Nico Zahn is offline
Flexsim User
 
Join Date: Sep 2007
Location: Bingen am Rhein, Germany
Posts: 179
Downloads: 19
Uploads: 4
Thanks: 66
Thanked 60 Times in 32 Posts
Rep Power: 201
Nico Zahn has a spectacular aura aboutNico Zahn has a spectacular aura about
Default

Hi Jason, hi Steven,
I use the settablesize function now to define the format of the first row, but you have to do it successively (row 1-4 string, row 5 number, row 6 string ...) and set the datatype and overwrite parameter to 0.
So every row is the same. What if I want a different format in another row. Thats what I am looking for. I want to specify the datatype of a tablecell (gettablecell is ok for getting information what datatype is in the cell, but I can not write to table with this command, can I?) explicitly just for that one cell. E.g. all data in the table is string fromat and only one cell in the midle holds a number.
So I guess I write my user-command, because I do not see another easy way, and its not to much effort... I post it when it´s done...
__________________
kind regards Nico.
  #5  
Old 11-28-2008
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

nico,

Did you look up gettablecell in the commandlist? Because it returns a treenode reference to a particular cell. This means that you can do everything with that you want.
So you set the value:
setnodenum( gettablecell( "Mytable", 1, 1), 123);

or set the datatype

nodeadddata( gettablecell("Mytable", 1, 1), DATATYPE_NUMBER);

etc..

So this gives I think exactly what you want,be able to change a single cell in the middle of a table.

Steven

Last edited by Anthony Johnson; 11-29-2008 at 06:07 PM. Reason: changed addnodedata to nodeadddata
The Following User Says Thank You to Steven Hamoen For This Useful Post:
Nico Zahn (11-28-2008)
  #6  
Old 11-28-2008
Nico Zahn's Avatar
Nico Zahn Nico Zahn is offline
Flexsim User
 
Join Date: Sep 2007
Location: Bingen am Rhein, Germany
Posts: 179
Downloads: 19
Uploads: 4
Thanks: 66
Thanked 60 Times in 32 Posts
Rep Power: 201
Nico Zahn has a spectacular aura aboutNico Zahn has a spectacular aura about
Default

Hi Steve,
great thank you, thats what I wanted to do in my usercommand.. but now I can save some time...
I was not aware of the gettablecell-command returning a reference to the tablecell, I though it would only return the value in the tablecell.
Tank you..
__________________
kind regards Nico.
  #7  
Old 11-28-2008
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

Nico, it wasn't clear (to me ) from your first post that you wanted to change the rows.

I guess the standard implementation of tables is kind of like a database, where each row is a record of the same type, with the same number of fields and with the same fiedl types. If we arrange data with this in mind, functions like settablesize do the work nicely.

Another point on this is that you can store the record format as a variable within the table and then copy it into the data node as a new row. This saves having to code up the node changing. Also this row entry can have the column names entered, so if you 'pop' the first row from the table, the headings are maintained when you view the table. Not exactly what you're needing here, but worth mentioning in the same topic (I hope!)

Jason
The Following User Says Thank You to Jason Lightfoot For This Useful Post:
Nico Zahn (11-28-2008)
  #8  
Old 11-28-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

Nico,

If you are willing to put the text file into Excel first then you could use the MTEI with a data distinction row (or column) to define the data types of the columns (or rows). To me this would be the easiest way to do what you are asking. If the data type is changing over both the rows and columns then the easiest thing to do would be to use the automatic data distinction. This requires that any strings start with a-z and any numbes start with 0-9.

To me the second best option would be to set the table to one row and the number of columns that I wanted. Then I would use the gettablecell() command and set the data types of the columns. Now when you increase the table size so that it has the right number of rows they should all be of the same types. However, this may not work for you as you seem to be changing data types over rows.

The third option would be to open up the library and try to look at the code in the Excel Import object. This would show you how that object does it and may give you the best insight in how you could do it. However, I wrote that object before I became converted to the "comment every line" method of coding so it could be a daunting task.

Good Luck,
Brandon
__________________
thats not normal.
The Following User Says Thank You to Brandon Peterson For This Useful Post:
Nico Zahn (11-28-2008)


Thread Thread Starter Forum Replies Last Post
How to change the location of items in a rack cell from y to x direction? Tom David Q&A 3 11-23-2008 10:52 AM
Placing item in respective cell of a rack David Chan Q&A 1 11-13-2008 09:32 AM
Cell Control in a Rack Gavin Douglas Q&A 2 10-22-2008 09:16 AM
Can I make a column of a global table to type table? qin tian Q&A 0 10-01-2008 09:27 PM
School table asid_amin_o Q&A 10 02-25-2008 03:57 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.