Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2023-06

Enum as an const

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner
to Michael Van Canneyt
Show quoted text 14 lines
On Fri, 23 Jun 2023, Henrique Gottardi Werlang via Pas2js wrote: > It possible to convert an enumerator in a const string? > > For example I declare a enumerator: > > TMyEnumerator = (MyEnum1, MyEnum2, MyEnum3); > > In the generated JS file, it is possible do convert the enumerator > value in a const string, like, "MyEnum1"? The compiler actually generates the strings, see: https://wiki.freepascal.org/Pas2js_Transpiler#Translating_enums

... which can be used with

str(MyEnum1)

or

str(e)

Mattias