Flexscript Error: syntax error, unexpected ':', expecting end of code

Flexscript Error: syntax error, unexpected ':', expecting end of code

maryamh11
Collaborator Collaborator
755 Views
4 Replies
Message 1 of 5

Flexscript Error: syntax error, unexpected ':', expecting end of code

maryamh11
Collaborator
Collaborator

[ FlexSim 21.2.4 ]

Beta 2022

Model_global_table_times.fsmVersion Beta 2022

Hello,

I've set a global table to be able to read specific times from there and do a calculation. The type of the cells are set as string in that column, but I am constantly getting this error:

syntax error, unexpected ':', expecting end of code

Could not finish parsing because of previous errors.

Can anyone help to solve this?

A snippet of the model is attached.


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

moehlmann_fe
Collaborator
Collaborator
Accepted solution

"executeCell()" interprets the content of the cell as FlexScript, leading to the error. And in your custom code you are trying to subtract two strings from each other (third column value). That is not a valid operation.

If you want to get a difference between two times of day, I'd suggest to use the Model.dateTime class.

https://docs.flexsim.com/en/21.2/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/DateTime.html

The properties "hour", "minute", "second" and "millisecond" allow you convert the current time of day into a decimal number that can then be compared to a given time in the table.

For example, instead of 08:00:00, you simply write 8 (as a number) into the table.

Model.dateTime.hour + Model.dateTime.minute/60 + Model.dateTime.second/3600

will give you the current time of day (for example 8.607 for 08:36:25). Then you can get the time difference as 0.607 hours.

Message 3 of 5

maryamh11
Collaborator
Collaborator
@Felix Möhlmann Thanks for the answer!


If the time difference value leads to a negative value and I use that value in the "Delay" activity does the Delay activity take into account the negative values as 0?

0 Likes
Message 4 of 5

moehlmann_fe
Collaborator
Collaborator

Yes, negative values will be treated as 0 in a delay activity. In other places (for example the quantity field of a "Create Tokens" activity) a negative value might lead to errors. To be save you can use "Math.max(value, 0)" to return 0 if the value is negative.

Message 5 of 5

maryamh11
Collaborator
Collaborator
Got it, thanks!
0 Likes