question

Alessio Merlo avatar image
3 Likes"
Alessio Merlo asked Phil BoBo edited

return type of user command

Hi,

does somebody help me with a compiler error? I am updating an old model to the last version of Flexsim (17.0.2), but I surprised when the compiler console return some error due to return type of my user command.

I can't attach the model, but I replicated the issue in a simple model. I created an user command "sum" which return an "int" value ("double" is the same). When I use the command and I save the return value in an int variables, the compiler returns an error with this reason "Command sum does not return the required type". Why?

I can fix the problem changing the return type of command in num or variant or saving the return value in a variant, but I don't understand the reason of this change. Sometimes I would like to force the return type with a specifc type.

Does somebody help me to understand what is changed in FlexSim 17.0.2?

Thanks in advance.

FlexSim 17.0.2
user commandscompilerreturn type
parsererror.png (49.3 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Matt Long avatar image
2 Likes"
Matt Long answered Phil BoBo edited

Valid return types currently (for 17.0) are:

  • node
  • obj
  • string
  • str
  • num
  • int
  • double
  • var
  • array

(You can also leave return type empty if returning nothing)

It looks like there is a bug with using int. In the mean time use num instead.

· 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.

Alessio Merlo avatar image Alessio Merlo commented ·

Hi Matt,

probably I don't understand your answer, for this reason I attached the model.

I created a command which return an int, but the compiler gives me an error if I save the return value in a int variable. Do you confirm?

1 Like 1 ·
parseerror.fsm (12.5 KiB)
Phil BoBo avatar image Phil BoBo ♦♦ Alessio Merlo commented ·

The Return Type field has never accepted "int" or "double" as valid options. You should use "num" instead.

In previous versions, it displayed a warning: "Warning line 1 Invalid type for assignment operation on val. Expecting type num. Type is none."

In 17.0, that warning is now a compile error instead of a warning, as the compiler is more strict in proper typing now.

I'll add a note to the dev list to either fix the documentation or change it so that it accepts "int" and "double" as valid Return Types.

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.