question

mary avatar image
0 Likes"
mary asked Jason Lightfoot edited

Custom code error for reading name from global table

Hi, In this model I'm not able to read from table please do check what is mistake.

I am assigning part name to part_number in my custom code but in next step it is not reading part_number from global table.

model name : globaltablematch.fsm

FlexSim 20.0.10
global tablepart name
· 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.

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·
I don't see a model with that name - could you check you uploaded it?
0 Likes 0 ·
mary avatar image mary Jason Lightfoot ♦♦ commented ·

Due to network it was not uploaded I reuploaded it please do check @Jason Lightfoot

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ mary commented ·
Nothing called 'globaltablematch' in the share folder.
0 Likes 0 ·
Show more comments

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

You're using P and Q as the row ids but your row ids in GlobalTable2 are "Row 1" and "Row 2" change those and it will work. (and you don't need 'cell' you can just use ["P"]["Buffer"])

· 3
5 |100000

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

mary avatar image mary commented ·
Thank you @Jason Lightfoot it worked
0 Likes 0 ·
mary avatar image mary commented ·

@Jason Lightfoot I have same model created without process flow . i am creating inventory in Run start.

1660814215069.png

and on entry reading the object and assigning it to destination. But giving error how i will assign this object in code.

1660814234472.png

for reference model name: post.fsm

0 Likes 0 ·
1660814215069.png (32.9 KiB)
1660814234472.png (19.4 KiB)
Jason Lightfoot avatar image Jason Lightfoot ♦♦ mary commented ·

First of all - this is better code for the run start:

if(Model.time == 0){
    Object Pal_Obj; Object Pal_Obj1;
    treenode flowitem = Model.find("Tools/FlowItemBin/Pallet/1");
    treenode flowitem1 = Model.find("Tools/FlowItemBin/Box/1");
    Object Destination = Model.find("Queue1");
    Table gt1=Table("GlobalTable1");
    for(int i =1; i<=gt1.numRows;i++){
        for(int j=1; j<=gt1[i]["Quantity"]; j++){
            Pal_Obj = createcopy(flowitem, model());
            Pal_Obj.part_num = gt1[i]["Item name"];
            Pal_Obj1 = createcopy(flowitem1, model());
            moveobject(Pal_Obj, Destination);
            moveobject(Pal_Obj1, Pal_Obj);
        }
    }
}

In your entry trigger you declare Pal_Obj but don't assign it anything - so you're trying to fine the label part_num on something that doesn't exist. you probably meant to use item.

0 Likes 0 ·