question

Raul V avatar image
0 Likes"
Raul V asked Raul V commented

Adjust Query to user commands


Hi team!

Im doing one query that give a sum of cycle time depending the item.type. I need to use the code several times and i need to add another variables so i need to create a "user command" and only copy and paste in each process where i need it, i tried to do it but without success.

Could you please help me and explain me a little bit the parameters and how interact in the usser command please?

Attached model for reference

Code below that i need to make a "user command":


Object current = ownerobject(c);
Object item = param(1);

int value=item.Type;

Table resultsArray=Table.query("SELECT SUM ([CT]) AS total FROM GlobalTable1 WHERE [Type]=="+value+"");
setlabel(item,"CT",resultsArray[1][1]);
return resultsArray[1][1];


thanks a lot

customcodeandquery.fsm


FlexSim 23.1.1
sqlglobaltableusercommand
5 |100000

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

1 Answer

·
Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Raul V commented

Since you're not using 'current' you can use exactly that code without the first line.

Set up the user command like this:

1682066865337.png

Which tells FlexSim it will return a numeric value and requires a treenode or object as a single parameter.


1682066865337.png (3.4 KiB)
· 2
5 |100000

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

Raul V avatar image Raul V commented ·

Thanks a lot, I need to use current due the colum header in the table that im going to refer is based of a label in the current (processor), I didnt add that in the example.

Could you please let me know? Thx

0 Likes 0 ·
Raul V avatar image Raul V Raul V commented ·
I just did, thanks a lot :)
0 Likes 0 ·

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.