Enumerations...

Hello,



I have searched but, no joy. It appears scripter does not support enumerations.



type

   TSuit = (Hearts, Diamonds, Clubs, Spades);   // Defines enumeration range

var

   suit : TSuit;                                // Defines enumeration variable

begin

   suit := Clubs;                               // Set to one of the values

end;



Or is it late in the night and I am missing something simple?



Thanks,



Mark

You can't declare an enumerated type in script itself. What you can do is register an existing Delphi enumerated type to be used in script, only.

Thanks for the response.



It was a customer that wanted to declare the enumerated type in his script. No way I could "pre-define" what he wanted to do.



Hello,



I had another customer ask today about support for enumerated types in scripting. Is enumerated type support in the future?



Thanks,



Mark

Type declaration in script, including enumerated types, is not in the roadmap for now. The scripting system is dynamic typing, there isn't much reason for declaring an enumerated type since you won't have type checking for that. It would be the nearly the same as using simply plain strings:



suit := 'Clubs';


note that TMS Scripter supports case statements with strings, so you would still be able to write something like this:


case suit of
  'Clubs': <do something>
  'Hearts': <do something else>
end;

Wagner R. Landgraf2017-07-03 01:48:20

Thanks for the response.



I am not sure why he is wanting an enumeration. I speculate he is using a DLL and trying to port the needed bits directly to make accessing the DLL easier.



Enumerations can make programs easier to read/understand.



It is interesting, to me, that a little over a year ago another customer asked the same question and I know he was not using a DLL.