Flexscript combine two integer variables into one (current month and day)

Flexscript combine two integer variables into one (current month and day)

brandon_frank
Not applicable
4 Views
2 Replies
Message 1 of 3

Flexscript combine two integer variables into one (current month and day)

brandon_frank
Not applicable

[ FlexSim 17.1.1 ]

Very straightforward FlexScript syntax issue I'm having:

I have two variables that represent the current day and month of the year. I want to combine them into one variable.

Example:

---------------------------------------------------------------------

int day = getmodelunit(CURRENT_DAY_OF_MONTH);

int month = getmodelunit(CURRENT_MONTH_OF_YEAR);

int today = month&day;

--------------------------------------------------------------------

I want the "today" variable to read as "712" (based on today's date of July 12th). Bonus points if you can tell me how to add a slash so it reads as "7/12".

Thanks!

0 Likes
Accepted solutions (1)
5 Views
2 Replies
Replies (2)
Message 2 of 3

allister_wilson
Not applicable
Accepted solution

To make 712 from 7 and 12, you can just use arithmetic :

int today = 100 * month + day;

You can't have a slash in a number. You'd need to use a string if you want to represent "7/12" :

string todayStr = numtostring(month) + "/" + numtostring(day);
Message 3 of 3

brandon_frank
Not applicable

Thank you!

0 Likes