question

Anutt K avatar image
0 Likes"
Anutt K asked Donald Harkins commented

Use GUI for Create Flow Item by edit field Automatically.

Hello. I'm try to use GUI for create flow item by use edit field. I have question it can be possible to create item for Automatically.

Case 1 :

Type a text in edit field then press "Enter" key on keyboard. Then Flow Item will be create in Queue.

- Exam : Type "Box" in edit field and ENTER. A "Box" will be create in Queue.

Case 2 :

Type a text in edit field then time delay for 1-2 Second. Then Flow Item will be Create in Queue.

- Exam : Type "Box" in edit field then time delay for 1-2 Second. Then "Box" will be Create in Queue. (Automatically)

1659431677764.png


Thank You so much for help me and Knowledge Sharing.


FlexSim 22.1.1
guiflow items
1659431677764.png (263.2 KiB)
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

Felix Möhlmann avatar image
2 Likes"
Felix Möhlmann answered Donald Harkins commented

Add the 'OnKeyDown' event to the edit field (Select 'All Attributes' in the attributes list on the bottom left to see it there). Then add the following code.

'lastkeydown()' returns the number code of the key that was pressed last (13 == "Enter", Lists of these codes can be easily found on the Internet). If that is the case, an item with the same name in the FlowItemBin as the entered text is created in the model and moved into Queue1.

1659439317201.png


1659439317201.png (30.5 KiB)
· 16
5 |100000

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

Anutt K avatar image Anutt K commented ·

Thank You to reply me. I not found the Attribute "enterDown" and "evenfunction" like a picture.

1659668400442.png

But I found "OnKeyDown" and Add to lower of tool tip and test form yourcode and this error.

I think that because it don't have "enterDown" and "evenfunction".

1659668738309.png

It error when I,m try to type the item name such a Box.

1659668784572.png

1659668798960.png

0 Likes 0 ·
1659668400442.png (33.2 KiB)
1659668738309.png (819.4 KiB)
1659668784572.png (443.9 KiB)
1659668798960.png (716.5 KiB)
Felix Möhlmann avatar image Felix Möhlmann Anutt K commented ·
'enterDown' was a node I experimented with, you can ignore that. 'eventfunctions' also seems to be unnecessary, since the code is triggered for you.

The error tells you that the variable type 'String' is unknown. The correct type is 'string' with a small s (Note how the other variable types are bolded in the code, yet 'String' is not)

The case also matters for the Flow Item name you enter into the field. There is no item called 'box', only ' Box'.
1 Like 1 ·
Anutt K avatar image Anutt K Felix Möhlmann commented ·

Excellent it work. Now I can create item by edit flow item name in field and press enter. Thank You very much.

1659715609914.png

And I have a few one more questions.

How can we text in edit field and wait for few second then item will create for automatically.

Exam. Type the "Box" in edit field >> Waiting for 3 second >> After 3 second box will created in Queue.

(I try to upload my model for share it but when I'm upload file it tell me something went wrong. try again)

0 Likes 0 ·
1659715609914.png (454.7 KiB)
Show more comments
Donald Harkins avatar image Donald Harkins commented ·
Hello Felix,


This solution is very cool! I was wondering if it would be possible to get this GUI to create items that aren't from the FlowItem Bin.


For example, I have my source and it has items coming in an arrival schedule. I want to know how to find out what name I put in at line 5 of the code to get my GUI to output my specific items, if it is possible. Let me know!

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Donald Harkins commented ·
What exactly do you mean by "specific items"? A source also just creates copies of objects in the flowitem bin and possibly automatically assigns labels to them.
1 Like 1 ·
Donald Harkins avatar image Donald Harkins Felix Möhlmann commented ·

So for specific items I mean the objects in my Arrival Schedule under the ItemName column. I was just wondering what the code would be to reference these objects in the arrival schedule, for example one of the objects is called PMA, so I want to see if it's possible to just write "PMA" in the GUI and then have create a PMA in the queue.



0 Likes 0 ·
Show more comments