Sign in Join

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

Mailing lists / pas2js / 2023-06

RES: Pas2js Digest, Vol 59, Issue 2

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Henrique Gottardi Werlang

Thanks!

And to revert the string in the enumerator, exists a function?

De: <mailto:>
Enviado:s?bado, 24 de junho de 2023 07:00
Para: <mailto:>
Assunto: Pas2js Digest, Vol 59, Issue 2

Send Pas2js mailing list submissions to

To subscribe or unsubscribe via the World Wide Web, visit https://bra01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&data=05%7C01%7C%7C64a6c1cdfdb341236ecf08db7499c825%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638231976088750515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oTom8QwwBLBsG9IwEwnL3TV5%2B7RJIEBMkarwnpJ44CA%3D&reserved=0<https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js> or, via email, send a message with subject or body 'help' to

You can reach the person managing the list at

When replying, please edit your Subject line so it is more specific than "Re: Contents of Pas2js digest..."

Today's Topics:

1. Enum as an const (Henrique Gottardi Werlang)
2. Re: Enum as an const (Michael Van Canneyt)
3. Re: Enum as an const (Mattias Gaertner)

----------------------------------------------------------------------

Message: 1
Date: Fri, 23 Jun 2023 17:54:53 +0000
From: Henrique Gottardi Werlang
To: ""
Subject: [Pas2js] Enum as an const
Message-ID:

Content-Type: text/plain; charset="iso-8859-1"

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"?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://bra01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.freepascal.org%2Fpipermail%2Fpas2js%2Fattachments%2F20230623%2Fb9d94fd7%2Fattachment-0001.htm&data=05%7C01%7C%7C64a6c1cdfdb341236ecf08db7499c825%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638231976088750515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=jh1V1ilFq7uauh8%2FcbfVCG4j5bP73TZ%2BQKuocp5Ndbk%3D&reserved=0<http://lists.freepascal.org/pipermail/pas2js/attachments/20230623/b9d94fd7/attachment-0001.htm>>

------------------------------

Message: 2
Date: Fri, 23 Jun 2023 20:04:45 +0200 (CEST)
From: Michael Van Canneyt
To: Henrique Gottardi Werlang via Pas2js
Subject: Re: [Pas2js] Enum as an const
Message-ID: <alpine.DEB.2.22.394.2306232004170.215464 at home> Content-Type: text/plain; charset=US-ASCII; format=flowed

Henrique Gottardi Werlang wrote 7 lines
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://bra01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.freepascal.org%2FPas2js_Transpiler%23Translating_enums&data=05%7C01%7C%7C64a6c1cdfdb341236ecf08db7499c825%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638231976088750515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CjdxFIpEpKDWsb9hOUShwrOwkcVVMMG20L7veGI63YU%3D&reserved=0<https://wiki.freepascal.org/Pas2js_Transpiler#Translating_enums>

Michael.

------------------------------

Message: 3
Date: Sat, 24 Jun 2023 08:59:17 +0200
From: Mattias Gaertner
To:
Subject: Re: [Pas2js] Enum as an const
Message-ID: <20230624085917.5ce5fa1d at limapholos> Content-Type: text/plain; charset=US-ASCII

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://bra01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.freepascal.org%2FPas2js_Transpiler%23Translating_enums&data=05%7C01%7C%7C64a6c1cdfdb341236ecf08db7499c825%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638231976088750515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CjdxFIpEpKDWsb9hOUShwrOwkcVVMMG20L7veGI63YU%3D&reserved=0<https://wiki.freepascal.org/Pas2js_Transpiler#Translating_enums>

... which can be used with

str(MyEnum1)

or

str(e)

Mattias

------------------------------

Subject: Digest Footer

Mattias Gaertner
to Henrique Gottardi Werlang

On Sat, 24 Jun 2023 23:45:50 +0000
Henrique Gottardi Werlang via Pas2js

Thanks! And to revert the string in the enumerator, exists a function?
var Code: integer;

val(YourString,YourEnum,Code)

Mattias

Show quoted text 141 lines
De: <mailto:> Enviado:s?bado, 24 de junho de 2023 07:00 Para: <mailto:> Assunto: Pas2js Digest, Vol 59, Issue 2 Send Pas2js mailing list submissions to To subscribe or unsubscribe via the World Wide Web, visit https://bra01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&data=05%7C01%7C%7C64a6c1cdfdb341236ecf08db7499c825%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638231976088750515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oTom8QwwBLBsG9IwEwnL3TV5%2B7RJIEBMkarwnpJ44CA%3D&reserved=0<https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js> or, via email, send a message with subject or body 'help' to You can reach the person managing the list at When replying, please edit your Subject line so it is more specific than "Re: Contents of Pas2js digest..." Today's Topics: 1. Enum as an const (Henrique Gottardi Werlang) 2. Re: Enum as an const (Michael Van Canneyt) 3. Re: Enum as an const (Mattias Gaertner) ---------------------------------------------------------------------- Message: 1 Date: Fri, 23 Jun 2023 17:54:53 +0000 From: Henrique Gottardi Werlang To: "" Subject: [Pas2js] Enum as an const Message-ID: Content-Type: text/plain; charset="iso-8859-1" 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"? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://bra01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.freepascal.org%2Fpipermail%2Fpas2js%2Fattachments%2F20230623%2Fb9d94fd7%2Fattachment-0001.htm&data=05%7C01%7C%7C64a6c1cdfdb341236ecf08db7499c825%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638231976088750515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=jh1V1ilFq7uauh8%2FcbfVCG4j5bP73TZ%2BQKuocp5Ndbk%3D&reserved=0<http://lists.freepascal.org/pipermail/pas2js/attachments/20230623/b9d94fd7/attachment-0001.htm>> ------------------------------ Message: 2 Date: Fri, 23 Jun 2023 20:04:45 +0200 (CEST) From: Michael Van Canneyt To: Henrique Gottardi Werlang via Pas2js Subject: Re: [Pas2js] Enum as an const Message-ID: <alpine.DEB.2.22.394.2306232004170.215464 at home> Content-Type: text/plain; charset=US-ASCII; format=flowed 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://bra01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.freepascal.org%2FPas2js_Transpiler%23Translating_enums&data=05%7C01%7C%7C64a6c1cdfdb341236ecf08db7499c825%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638231976088750515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CjdxFIpEpKDWsb9hOUShwrOwkcVVMMG20L7veGI63YU%3D&reserved=0<https://wiki.freepascal.org/Pas2js_Transpiler#Translating_enums> Michael. ------------------------------ Message: 3 Date: Sat, 24 Jun 2023 08:59:17 +0200 From: Mattias Gaertner To: Subject: Re: [Pas2js] Enum as an const Message-ID: <20230624085917.5ce5fa1d at limapholos> Content-Type: text/plain; charset=US-ASCII On Fri, 23 Jun 2023 20:04:45 +0200 (CEST) Michael Van Canneyt via Pas2js 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://bra01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.freepascal.org%2FPas2js_Transpiler%23Translating_enums&data=05%7C01%7C%7C64a6c1cdfdb341236ecf08db7499c825%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638231976088750515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CjdxFIpEpKDWsb9hOUShwrOwkcVVMMG20L7veGI63YU%3D&reserved=0<https://wiki.freepascal.org/Pas2js_Transpiler#Translating_enums> > ... which can be used with str(MyEnum1) or str(e) Mattias ------------------------------ Subject: Digest Footer _______________________________________________ Pas2js maillist - https://bra01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&data=05%7C01%7C%7C64a6c1cdfdb341236ecf08db7499c825%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638231976088750515%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oTom8QwwBLBsG9IwEwnL3TV5%2B7RJIEBMkarwnpJ44CA%3D&reserved=0<https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js> ------------------------------ End of Pas2js Digest, Vol 59, Issue 2 *************************************