ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 03-26-2013
FlorianK's Avatar
FlorianK FlorianK is offline
Flexsim User
 
Join Date: Jan 2011
Location: Erfurt, Germany
Posts: 27
Downloads: 10
Uploads: 0
Thanks: 16
Thanked 3 Times in 3 Posts
Rep Power: 115
FlorianK is on a distinguished road
Default Interpreting System Console

Hello everybody,

I have a model where I'm creating Items with the OnMessage-Trigger, just like this:

treenodecurrent = ownerobject(c);
int nNumitems =
2;
int nFlowitemrank =
6;
treenode pDestination =
current;
int nLoadingPosition =
1;
closeoutput(current);
for (int nIndex =
0; nIndex < nNumitems; nIndex++)
{
insertcopy(first(rank(node("/Tools/FlowItemBin",model()),nFlowitemrank)), pDestination);
setitemtype(rank(current,content(current)),msgparam(1));
setlabelnum(item,"Loading_Position",nLoadingPosition);
nLoadingPosition = nLoadingPosition +
1;
}
openoutput(current);

The System console tells me following:

The label named "Loading_Position" was referenced but does not exist on (null)

The Label is defined at the FlowItemBin, the spelling is also right.

Is it right that the label can't be setted because the item isn't actual created? Could ypu please give me tipps that I can solve the problem?

Thank you.

Greetings,
FlorianK
  #2  
Old 03-26-2013
Kris Geisberger Kris Geisberger is offline
Flexsim Canada, Forum Moderator
 
Join Date: Aug 2007
Location: Canada
Posts: 209
Downloads: 54
Uploads: 1
Thanks: 99
Thanked 389 Times in 133 Posts
Rep Power: 451
Kris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud of
Default

insertcopy() returns a reference to the item that is created

treenode newitem = insertcopy(...);

Take a look at the code behind the OnMessage pick option called "Create Flowitems"
The Following User Says Thank You to Kris Geisberger For This Useful Post:
FlorianK (03-26-2013)
  #3  
Old 03-26-2013
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

Quote:
Originally Posted by FlorianK View Post
Code:
setlabelnum(item,"Loading_Position",nLoadingPosition);
You never defined "item" so it is null. You are trying to set the "Loading_Position" label on null.

You should use:
Code:
insertcopy(first(rank(node("/Tools/FlowItemBin",model()),nFlowitemrank)), pDestination);
setitemtype(rank(current,content(current)),msgparam(1));
setlabelnum(rank(current,content(current)),"Loading_Position",nLoadingPosition);
nLoadingPosition = nLoadingPosition +1;
or
Code:
treenode newitem = insertcopy(first(rank(node("/Tools/FlowItemBin",model()),nFlowitemrank)), pDestination);
setitemtype(newitem,msgparam(1));
setlabelnum(newitem,"Loading_Position",nLoadingPosition);
nLoadingPosition = nLoadingPosition +1;
The Following User Says Thank You to Phil BoBo For This Useful Post:
FlorianK (03-26-2013)
  #4  
Old 03-26-2013
FlorianK's Avatar
FlorianK FlorianK is offline
Flexsim User
 
Join Date: Jan 2011
Location: Erfurt, Germany
Posts: 27
Downloads: 10
Uploads: 0
Thanks: 16
Thanked 3 Times in 3 Posts
Rep Power: 115
FlorianK is on a distinguished road
Thumbs up

Hello Chris,

thanks for your hint with the treenod.

While Phil wrote athe example codes, I was able to understand it and made it the same way

=> treenode newitem = insertcopy(first(rank(node("/Tools/FlowItemBin",model()),nFlowitemrank)), pDestination);

Thank you both for your help.


Thread Thread Starter Forum Replies Last Post
disable system console juan alberto Q&A 3 11-07-2011 05:52 AM
what is the problem ,the system console print ? LINWEIXU Q&A 5 08-23-2010 08:38 AM
Suppressing "FULL PARTNER in-out" in System Console david_white Q&A 1 07-30-2010 12:52 PM
system console problem ? LINWEIXU Q&A 16 06-18-2010 03:25 AM
Can I write to the system console? Steven Hamoen Q&A 2 11-26-2008 06:37 AM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.