question

Bryan Suharik avatar image
0 Likes"
Bryan Suharik asked Adrian Haws commented

Question on getdatastat() ??

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

FlexSim 16.0.6
codegetdatastat
· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Arun Kr avatar image Arun Kr commented ·

Hi Bryan Suharik,

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

test-getstat.fsm

Regards,

Arun KR

0 Likes 0 ·
test-getstat.fsm (12.8 KiB)
Bryan Suharik avatar image Bryan Suharik Arun Kr commented ·

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 0 ·
Bryan Suharik avatar image Bryan Suharik commented ·

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 0 ·
Adrian Haws avatar image Adrian Haws commented ·

@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 0 ·
Bryan Suharik avatar image Bryan Suharik Adrian Haws commented ·

@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

1 Like 1 ·

1 Answer

·
Adrian Haws avatar image
1 Like"
Adrian Haws answered Adrian Haws commented

@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));
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Bryan Suharik avatar image Bryan Suharik commented ·

@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 0 ·
Adrian Haws avatar image Adrian Haws Bryan Suharik commented ·

@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 0 ·
Bryan Suharik avatar image Bryan Suharik Adrian Haws commented ·

@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 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.