Question on getdatastat() ??

Question on getdatastat() ??

bryan_suharik
Not applicable
15 Views
10 Replies
Message 1 of 11

Question on getdatastat() ??

bryan_suharik
Not applicable

[ FlexSim 16.0.6 ]

Hi, I followed the instructions from this link:

https://answers.flexsim.com/articles/14290/getdatastat-4.html

However, i get an error saying parameters 2 and 3 should be nodes and not Num.

Here is my code:

getdatastat(STAT_MEAN, gettablerows("GlobalTable2345"), gettablenum("GlobalTable2345", count, 1));

I basically followed the example. Parameters are clearly Num, but im curious why the example says this is an option if it needs to be a node. What am i Missing?

Any help would be greatly appreciated.

Thanks! Using Version 6

bryan

0 Likes
Accepted solutions (1)
16 Views
10 Replies
Replies (10)
Message 2 of 11

arunTTT2P
Explorer
Explorer

Hi Bryan Suharik,

I am not getting an error using the same code using version 16.

test-getstat.fsm

Regards,

Arun KR

0 Likes
Message 3 of 11

bryan_suharik
Not applicable

Hi Arun,

Your file says "treenode incompatible with my version". I'm using Version 6 (older). Do you have a possible solution to this version? It seems to not want to accept the NUM and prefers the parameter as a NODE.

Thanks in Advance...

bryan

0 Likes
Message 4 of 11

bryan_suharik
Not applicable

I found this link helpful for the average i was looking for...it does a loop, but id like to know how the getdatastat can work so that i can extract mins and maxes as well.

https://answers.flexsim.com/questions/23612/using-getdatastat-with-global-table.html

0 Likes
Message 5 of 11

adrian_haws
Not applicable

@Bryan Suharik I used the same code in version 16.0 with no issues. Could you attach a model that demonstrates the errors you're experiencing?

0 Likes
Message 6 of 11

bryan_suharik
Not applicable

@Adrian Haws I've attached a sample model as my main model is a bit complicated to sort through, but i get the same error during runtime with this one. GlobalTable 7 should show the average of GlobalTable6 on entry of any item. You'll see the code in the entrytrigger of the Queue3.

I get the following error though on reset. and the average of GT7 never changes.

Too few parameters for getdatastat. And the Unknown variable STAT_MEAN. I deleted STAT_MEAN and used 1, which removed that error, but the parameters one still exists.

Thanks!sample-flexsim-getdatastat.fsm

Message 7 of 11

adrian_haws
Not applicable
Accepted solution

@Bryan Suharik This was due to a syntax error. On line 7 of the OnEntry trigger in the Queue you wrote:

double average = getdatastat(STAT_MEAN,gettablerows("GlobalTable6",gettablenum("GlobalTable6",count,1)));

You simply misplaced a parenthesis for gettablerows.

double average = getdatastat(STAT_MEAN,gettablerows("GlobalTable6"),gettablenum("GlobalTable6",count,1));
Message 8 of 11

bryan_suharik
Not applicable

@Adrian Haws Thanks for catching that Adrian. Unfortunately, with the correction, i still get the same error, not recognizing STAT_MEAN and too few parameters for getdatastat.

I think the issue is, i'm using version 6.0.2 . Do you know a similar code for this old version?

Thanks,

bryan

0 Likes
Message 9 of 11

adrian_haws
Not applicable

@Bryan Suharik I opened your model in 16.0. Originally it was giving the errors you described and when I changed the syntax the problem was resolved. Did you double check the syntax in the code window?

0 Likes
Message 10 of 11

bryan_suharik
Not applicable

@Adrian HawsYes, changed the syntax and still get the error. Isn't 16.0 a newer version than 6.0.2? The error says expecting type node, but its type num.

0 Likes
Message 11 of 11

adrian_haws
Not applicable

Specifically I was using version 6.0.1, but the code worked fine for me in newer versions as well. I also don't see any reports of previous bugs with this command.

0 Likes