Assign string array to token label

Assign string array to token label

michal_klodawski
Not applicable
177 Views
10 Replies
Message 1 of 11

Assign string array to token label

michal_klodawski
Not applicable

Hi,

Is there way to assign string array to token label? I have:

stringarray TabID= makearray(10);
intarray TabIle= makearray(10);

//here I filled array with string and integer values
//and now I try to assign arrays to labels

setlabel(token,"CoUzupelnic",TabID); // is error

setlabel(token,"IleUzupelnic",TabIle); // is ok

thanks in advance for advices
0 Likes
Accepted solutions (1)
178 Views
10 Replies
Replies (10)
Message 2 of 11

sam_stubbsYXX86
Community Manager
Community Manager

I'm not sure which version you are using, that will make a difference. For example, in the most recent version of FlexSim (2017) the "intarray" and "stringarray" types are no longer used as such. Instead there is just an Array object type, that can be filled with other object type values (including other Array types).

But either way, you should be able to make any label on a token an array of values using the Assign Labels activity: (IN the value field under the picklist option Array > you will find all of the options for different ways to assign array values to your label.)

5034-stringarray.png

0 Likes
Message 3 of 11

michal_klodawski
Not applicable

Hi, thanks for reply, I have FLexSim 2016 update 2. Array type is not available yet. I've tried to create new label with array of string as you said but I have still the same exception as earlier. It is appearing when I click on token to see its labels after assigning string array to label:

exception: Exception caught in TreeNode::callMemberFunction() c++/dll execution. Throwing... VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties/TableView>eventfunctions/setFocus c: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties/TableView thisClass: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties/TableView
exception: Exception caught in flexscript execution of VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties>eventfunctions/onSelObjChange line 7 instruction 22. Discontinuing execution.
exception: Exception caught in TreeNode::callMemberFunction() flexscript execution VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties>eventfunctions/onSelObjChange c: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties theclass: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties
exception: treewin__OnPaint
ex: OnPaint
exception: Exception caught in TreeNode::callMemberFunction() c++/dll execution. Throwing... VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties/TableView>eventfunctions/setFocus c: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties/TableView thisClass: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties/TableView
exception: Exception caught in flexscript execution of VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties>eventfunctions/onSelObjChange line 7 instruction 22. Discontinuing execution.
exception: Exception caught in TreeNode::callMemberFunction() flexscript execution VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties>eventfunctions/onSelObjChange c: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties theclass: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties
exception: treewin__OnPaint
ex: OnPaint
exception: treewin__OnPaint
ex: OnPaint
exception: treewin__OnPaint
ex: OnPaint
exception: treewin__OnPaint
ex: OnPaint
exception: treewin__OnPaint
ex: OnPaint
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: size_t treewin__OnMouseMoveXX(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TreeWin * t, int mx, int my)
ex: t->mousemove(hWnd,mx,my);exception: treewin__OnMouseMove
ex: OnMouseMove
exception: treewin__OnLeftDoubleClick
ex: OnLeftDoubleClick
exception: treewin__OnLeftDoubleClick
ex: OnLeftDoubleClick
exception: Exception caught in TreeNode::callMemberFunction() c++/dll execution. Throwing... VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties/TableView>eventfunctions/setFocus c: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties/TableView thisClass: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties/TableView
exception: Exception caught in flexscript execution of VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties>eventfunctions/onSelObjChange line 7 instruction 22. Discontinuing execution.
exception: Exception caught in TreeNode::callMemberFunction() flexscript execution VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties>eventfunctions/onSelObjChange c: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties theclass: VIEW:/active/MainPanel/BackPanel/SplitterXPane/SplitterYPane~2/ToolTabPane/TabControl/QuickProperties/ToolPanel/TokenProperties/Token Properties
exception: treewin__OnPaint
ex: OnPaint
0 Likes
Message 4 of 11

sam_stubbsYXX86
Community Manager
Community Manager

This error is unrelated to your array. If you save and quit and reopen the file, this error message should stop firing.

0 Likes
Message 5 of 11

michal_klodawski
Not applicable

It didn't help 😞 On string still doesn't work, I will try to do this on int because with integers it works.

Thanks for reply

0 Likes
Message 6 of 11

sam_stubbsYXX86
Community Manager
Community Manager

If you can, I'd assign the string values of the array using an Assign Labels activity, rather than just initiating it via code.

0 Likes
Message 7 of 11

michal_klodawski
Not applicable

I'm still trying with integers 🙂 Besides I don't know how to pull array from code to Assign Labels activity

0 Likes
Message 8 of 11

matt_long
Not applicable
Accepted solution

My guess is that you're not filling every element of the string array with data. If I designate a token as so() and execute the following code in a script window it works just fine:

stringarray TabID= makearray(10);

TabID[1] = "A";
TabID[2] = "B";
TabID[3] = "C";
TabID[4] = "D";
TabID[5] = "E";
TabID[6] = "F";
TabID[7] = "G";
TabID[8] = "H";
TabID[9] = "I";
TabID[10] = "J";

setlabel(so(),"CoUzupelnic",TabID);

If however, one of those lines were to be removed, the value would not be visible in the quick properties. This appears to be a bug in 2016 Update 2 where it won't display if the values are not valid.

Message 9 of 11

michal_klodawski
Not applicable

thanks, that's true, it was such situation that not always all elements of array had string data. thank you for reply 🙂

Michał

0 Likes
Message 10 of 11

logan_gold
Community Manager
Community Manager

The error is pointing to part of the code that is executed when the Quick Properties window tries to display a table view, which I believe is the Labels section in this case. I think it is a bug with how the Quick Properties window tries to display a string array in that Labels section when one or more of the array's slots in the string array are not initialized. I can't tell you for sure unless you include the code you used to fill the array for TabID or include the model so we can open it and take a look.

However, I was able to use your code and fill in all 10 values of the TabID array with a random strings and the Quick Properties window displays all strings in the token's CoUzupelnic label. But if I only fill in the first 9 values and don't put anything in the 10 slot, Quick Properties will not display the Labels field of the token correctly and I sometimes get the same error you have posted in the comments.

I also tested this in FlexSim 2017 and did not get the same error. Instead, the array slots that I did not fill in would show up as NULL in the Quick Properties window, which I believe is what is supposed to happen.

It's also possible that the Quick Properties window doesn't know how to display a symbol in one or more of the strings if there are any unusual characters in your strings. Again, I can't be sure until I was able to look at the code you are using to fill the arrays.

Message 11 of 11

michal_klodawski
Not applicable

thank you for reply, indeed the problem was in array with some null values,

0 Likes