[Pas2js] Enum as an const

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Jun 24 08:59:17 CEST 2023


On Fri, 23 Jun 2023 20:04:45 +0200 (CEST)
Michael Van Canneyt via Pas2js <pas2js at lists.freepascal.org> wrote:

> 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


More information about the Pas2js mailing list