question

Andreas BH avatar image
0 Likes"
Andreas BH asked Jason Lightfoot commented

lenght of level 1 in rack in group

Hello together,

i want to know how many items are stored in all racks in level 1 in a group of racks. I tried several different formulations but failed.

for (int i = 1; i <= groupnummembers("Bereich_2"); i++)
{
k = Storage.system.queryItems("WHERE slot.storageObject.name==$1 AND slot.levelID == 1",0,groupmember("Bereich_2",i).name).length;
j=j+k;
}

it seems to me that it doesn't matter if you use == or =

Is somebody able to help?

Thank You!


FlexSim 22.1.4
racksgroupssql querylength
· 6
5 |100000

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

Felix Möhlmann avatar image Felix Möhlmann commented ·

I don't see any issues in the code and it works correctly for me in a test model.

level-content-query-test.fsm

What issue are you facing? Are you getting an error message or a wrong result? Have you checked that the racks are assigned to the correct group and that their adressing scheme is set up correctly?

0 Likes 0 ·
Andreas BH avatar image Andreas BH Felix Möhlmann commented ·

Good Morning. Your code works well in Skript-box. But i get the same error in Decide-activity (custom Code) as my code. 2024-02-13-08-07-37-window.jpg

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Andreas BH commented ·
I get the same error, but only if I step through the code in debug mode. When running normally, the code actually works in Process Flow too. Seems to be an issue with the debugger.
0 Likes 0 ·
Show more comments
Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·
In queries the = and == are interchangable tests for equality.
0 Likes 0 ·

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Andreas BH commented

You can do this in one line:

int numLevel1=Storage.system.queryItems("SELECT count(*) WHERE slot.storageObject IN $1 AND slot.levelID=1", 0,Group("Bereich_2").toFlatArray())[1][1]
· 1
5 |100000

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

Andreas BH avatar image Andreas BH commented ·
Thank you! This works without problems.
0 Likes 0 ·