question

oleg avatar image
0 Likes"
oleg asked Arun Kr edited

Variable to message

How to attach a variable to the message that will increase each time the message is sent to count the message?

FlexSim 24.1.0
labellabel valuemessages
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·

@oleg, this seems to be very similar to your question here, where you want to know how many times a message has been sent.

0 Likes 0 ·
oleg avatar image oleg Joerg Vogel commented ·

Well, I've created and incremented a variable, now how do I output it?

Object current = ownerobject(c);

Object item = param(1);

int port = param(2);

{ // ************* PickOption Start ************* //

/***popup:SendMessage*/

/**Send Message*/

int NoDelay = -1;

double delaytime = /** \nDelay Time: *//***tag:delaytime*//**/0/**list:NoDelay~0~10~current.messageDelay*/;

treenode toobject = /** \nTo: *//***tag:to*//**/current/**/;

treenode fromobject = /** \nFrom: *//***tag:from*//**/current/**/;

double param1 = /** \nParam1: *//***tag:par1*//**/1/**/;

double param2 = /** \nParam2: *//***tag:par2*//**/0/**/;

double param3 = /** \nParam3: *//***tag:par3*//**/0/**/;

/**\n\nDelay Time:\nNoDelay: message sent immediately within trigger context\n0: delayed message sent in 0 time*/

if (/** \nCondition: *//***tag:condition*//**/content(current) == 1/**/) {

if (delaytime == NoDelay)

sendmessage(toobject,fromobject,param1,param2,param3);

else senddelayedmessage(toobject, max(0,delaytime), fromobject,param1,param2,param3);

}


} // ******* PickOption End ******* //

{ // ************* PickOption Start ************* //

/***popup:SetTrackedVariable*/

/***tag:title*//**Set Tracked Variable*/

string trackedvar = /** \nVariable: *//***tag:trackedvariable*//**/"TrackedVariable1"/**/;

double initial = /** \nInitial: *//***tag:initial*//**/TrackedVariable(trackedvar).value/**/;

double val = /** \nValue: *//***tag:value*//**/1/**/;

if (/** \nCondition: *//***tag:condition*//**/1/**/)

TrackedVariable(trackedvar).value = initial + val;

} // ******* PickOption End ******* //

0 Likes 0 ·

0 Answers