<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="PT-BR" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Thanks for the replys!</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I suggested this because I'm implementing an API in Delphi. And in Delphi there is nothing equivalent to JSValue. Of course, you could declare any type with that name, to return, but it's not the idea, because the client and server share
 the same unit that has the contract interface.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And in this interface there is a procedure that does something, which can take time to finish.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So on the client side I need this to return a promise, so the browser doesn't get stuck.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I made a change to the local fonts I have from the compiler, that when the procedure is asynchronous, I make the procedure return a promise.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Of course this in a way violates pascal's concepts, but it got a lot better the implementations made, with this happening.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I'm not going to record any assignments regarding that, unless you think that's interesting.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="border:none;padding:0cm"><b>De: </b><a href="mailto:pas2js-request@lists.freepascal.org">pas2js-request@lists.freepascal.org</a><br>
<b>Enviado:</b>terça-feira, 1 de junho de 2021 08:34<br>
<b>Para: </b><a href="mailto:pas2js@lists.freepascal.org">pas2js@lists.freepascal.org</a><br>
<b>Assunto: </b>Pas2js Digest, Vol 39, Issue 2</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Send Pas2js mailing list submissions to<br>
        pas2js@lists.freepascal.org<br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485925406%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=k2KdbYS2pZ8iFxyrdneatAfY%2BUOqqlSYwTDXYv7VYE4%3D&amp;reserved=0">
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485925406%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=k2KdbYS2pZ8iFxyrdneatAfY%2BUOqqlSYwTDXYv7VYE4%3D&amp;reserved=0</a><br>
or, via email, send a message with subject or body 'help' to<br>
        pas2js-request@lists.freepascal.org<br>
<br>
You can reach the person managing the list at<br>
        pas2js-owner@lists.freepascal.org<br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Pas2js digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. RES: Pas2js Digest, Vol 39, Issue 1 (Henrique Gottardi Werlang)<br>
   2. Re: RES: Pas2js Digest, Vol 39, Issue 1 (Michael Van Canneyt)<br>
   3. Re: RES: Pas2js Digest, Vol 39, Issue 1 (Wagner Landgraf)<br>
   4. Re: RES: Pas2js Digest, Vol 39, Issue 1 (Mattias Gaertner)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Tue, 1 Jun 2021 10:33:08 +0000<br>
From: Henrique Gottardi Werlang <henriquewerlang@hotmail.com><br>
To: "pas2js@lists.freepascal.org" <pas2js@lists.freepascal.org><br>
Subject: [Pas2js] RES: Pas2js Digest, Vol 39, Issue 1<br>
Message-ID:<br>
        <CP4P284MB09943FB37FB51F2D88432CF4B23E9@CP4P284MB0994.BRAP284.PROD.OUTLOOK.COM><br>
        <br>
Content-Type: text/plain; charset="windows-1252"<br>
<br>
Unit MyTest;<br>
<br>
procedure Run; async;<br>
begin<br>
  // do something...<br>
end;<br>
<br>
begin<br>
   run()._then(function (a : jsvalue) : jsvalue<br>
     begin<br>
     end);<br>
end.<br>
<br>
In the line "run()._then(function (a : jsvalue) : jsvalue” give me the error “Error: illegal qualifier "." after " run():Procedure/Function"”<br>
<br>
De: pas2js-request@lists.freepascal.org<mailto:pas2js-request@lists.freepascal.org><br>
Enviado:terça-feira, 1 de junho de 2021 07:00<br>
Para: pas2js@lists.freepascal.org<mailto:pas2js@lists.freepascal.org><br>
Assunto: Pas2js Digest, Vol 39, Issue 1<br>
<br>
Send Pas2js mailing list submissions to<br>
        pas2js@lists.freepascal.org<br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485925406%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=k2KdbYS2pZ8iFxyrdneatAfY%2BUOqqlSYwTDXYv7VYE4%3D&amp;reserved=0">
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485925406%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=k2KdbYS2pZ8iFxyrdneatAfY%2BUOqqlSYwTDXYv7VYE4%3D&amp;reserved=0</a><br>
or, via email, send a message with subject or body 'help' to<br>
        pas2js-request@lists.freepascal.org<br>
<br>
You can reach the person managing the list at<br>
        pas2js-owner@lists.freepascal.org<br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Pas2js digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. Async procedure. (Henrique Gottardi Werlang)<br>
   2. Re: Async procedure. (Michael Van Canneyt)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Mon, 31 May 2021 18:18:34 +0000<br>
From: Henrique Gottardi Werlang <henriquewerlang@hotmail.com><br>
To: "pas2js@lists.freepascal.org" <pas2js@lists.freepascal.org><br>
Subject: [Pas2js] Async procedure.<br>
Message-ID:<br>
        <CP4P284MB0994AF032625620A0E1D1FD2B23F9@CP4P284MB0994.BRAP284.PROD.OUTLOOK.COM><br>
<br>
Content-Type: text/plain; charset="windows-1252"<br>
<br>
I'm making a remote request client and I had a problem.<br>
<br>
I declared an asynchronous procedure, but it doesn't generate a promise.<br>
<br>
This I can't register the "then” event.<br>
<br>
Is it possible to modify this procedure behavior?<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.freepascal.org%2Fpipermail%2Fpas2js%2Fattachments%2F20210531%2F05d3a71c%2Fattachment-0001.htm&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485925406%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=IHXivkgU%2BCOp2lp5hFbwuS5sFO8DuJidF47L%2BFMZl54%3D&amp;reserved=0">https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.freepascal.org%2Fpipermail%2Fpas2js%2Fattachments%2F20210531%2F05d3a71c%2Fattachment-0001.htm&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485925406%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=IHXivkgU%2BCOp2lp5hFbwuS5sFO8DuJidF47L%2BFMZl54%3D&amp;reserved=0</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Mon, 31 May 2021 21:06:32 +0200 (CEST)<br>
From: Michael Van Canneyt <michael@freepascal.org><br>
To: pas2js discussions <pas2js@lists.freepascal.org><br>
Subject: Re: [Pas2js] Async procedure.<br>
Message-ID: <alpine.DEB.2.22.394.2105312102530.1614564@home><br>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"<br>
<br>
<br>
<br>
On Mon, 31 May 2021, Henrique Gottardi Werlang wrote:<br>
<br>
> I'm making a remote request client and I had a problem.<br>
><br>
> I declared an asynchronous procedure, but it doesn't generate a promise.<br>
><br>
> This I can't register the "then” event.<br>
<br>
Works fine here:<br>
<br>
uses JS;<br>
<br>
function Run: word; async;<br>
begin<br>
   Result:=3;<br>
end;<br>
<br>
begin<br>
   run()._then(function (a : jsvalue) : jsvalue<br>
     begin<br>
     end);<br>
end.<br>
<br>
or<br>
<br>
uses JS;<br>
<br>
function Run: word; async;<br>
begin<br>
   Result:=3;<br>
end;<br>
<br>
var<br>
   p: TJSPromise;<br>
begin<br>
   p:=Run(); // calling directly without await() returns a TJSPromise!<br>
   p._then(function (a : jsvalue) : jsvalue<br>
     begin<br>
     end);<br>
end.<br>
<br>
So what does not work for you ?<br>
<br>
Michael.<br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
Pas2js maillist  -  Pas2js@lists.freepascal.org<br>
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485935387%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=wAkv7CB7Fi7dd0KlMFdh0dP4O16ykVOqqB8%2FvzpQsQo%3D&amp;reserved=0">https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485935387%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=wAkv7CB7Fi7dd0KlMFdh0dP4O16ykVOqqB8%2FvzpQsQo%3D&amp;reserved=0</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Pas2js Digest, Vol 39, Issue 1<br>
*************************************<br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.freepascal.org%2Fpipermail%2Fpas2js%2Fattachments%2F20210601%2F0dc77c80%2Fattachment-0001.htm&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485935387%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=SK5kyb5uAU3ljuOJ%2FM8WbN2UojY%2FWtbM5k%2BM2l1aMR8%3D&amp;reserved=0">https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.freepascal.org%2Fpipermail%2Fpas2js%2Fattachments%2F20210601%2F0dc77c80%2Fattachment-0001.htm&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485935387%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=SK5kyb5uAU3ljuOJ%2FM8WbN2UojY%2FWtbM5k%2BM2l1aMR8%3D&amp;reserved=0</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Tue, 1 Jun 2021 13:18:44 +0200 (CEST)<br>
From: Michael Van Canneyt <michael@freepascal.org><br>
To: pas2js discussions <pas2js@lists.freepascal.org><br>
Subject: Re: [Pas2js] RES: Pas2js Digest, Vol 39, Issue 1<br>
Message-ID: <alpine.DEB.2.22.394.2106011318110.1635063@home><br>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"<br>
<br>
<br>
<br>
On Tue, 1 Jun 2021, Henrique Gottardi Werlang wrote:<br>
<br>
> Unit MyTest;<br>
><br>
> procedure Run; async;<br>
> begin<br>
>  // do something...<br>
> end;<br>
><br>
> begin<br>
>   run()._then(function (a : jsvalue) : jsvalue<br>
>     begin<br>
>     end);<br>
> end.<br>
><br>
> In the line "run()._then(function (a : jsvalue) : jsvalue” give me the error “Error: illegal qualifier "." after " run():Procedure/Function"”<br>
<br>
I don't think you can use a procedure, you must use a function.<br>
<br>
Mattias will have to confirm.<br>
<br>
Michael.<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Tue, 1 Jun 2021 08:24:01 -0300<br>
From: Wagner Landgraf <wagner@tmssoftware.com><br>
To: pas2js discussions <pas2js@lists.freepascal.org><br>
Subject: Re: [Pas2js] RES: Pas2js Digest, Vol 39, Issue 1<br>
Message-ID: <FFEF784C-869E-44CD-A3FA-772BDE63BE26@tmssoftware.com><br>
Content-Type: text/plain;       charset=utf-8<br>
<br>
<br>
> <br>
>> Unit MyTest;<br>
>> <br>
>> procedure Run; async;<br>
>> begin<br>
>> // do something...<br>
>> end;<br>
>> <br>
>> begin<br>
>>  run()._then(function (a : jsvalue) : jsvalue<br>
>>    begin<br>
>>    end);<br>
>> end.<br>
>> <br>
>> In the line "run()._then(function (a : jsvalue) : jsvalue” give me the error “Error: illegal qualifier "." after " run():Procedure/Function"”<br>
> <br>
> I don't think you can use a procedure, you must use a function.<br>
> <br>
> Mattias will have to confirm.<br>
<br>
Indeed, I had to create a function that return JSValue even for procedures that are not supposed to return anything:<br>
<br>
function TXDataWebConnection.OpenAsync: JSValue; async;<br>
begin<br>
  Result := TJSPromise.new(<br>
    procedure(resolve, reject: TJSPromiseResolver)<br>
    begin<br>
      DoConnect(<br>
        procedure<br>
        begin<br>
          if Assigned(FOnConnect) then<br>
            FOnConnect(Self);<br>
          resolve(nil);<br>
        end,<br>
        procedure(Error: TXDataWebConnectionError)<br>
        begin<br>
          reject(EXDataWebConnectionException.Create(Error));<br>
        end<br>
      );<br>
    end<br>
  );<br>
end;<br>
<br>
<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Tue, 1 Jun 2021 13:25:27 +0200<br>
From: Mattias Gaertner <nc-gaertnma@netcologne.de><br>
To: pas2js@lists.freepascal.org<br>
Subject: Re: [Pas2js] RES: Pas2js Digest, Vol 39, Issue 1<br>
Message-ID: <20210601132527.66f7af9e@limapholos.matflo.wg><br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
On Tue, 1 Jun 2021 13:18:44 +0200 (CEST)<br>
Michael Van Canneyt <michael@freepascal.org> wrote:<br>
<br>
> On Tue, 1 Jun 2021, Henrique Gottardi Werlang wrote:<br>
> <br>
> > Unit MyTest;<br>
> ><br>
> > procedure Run; async;<br>
> > begin<br>
> >  // do something...<br>
> > end;<br>
> ><br>
> > begin<br>
> >   run()._then(function (a : jsvalue) : jsvalue<br>
> >     begin<br>
> >     end);<br>
> > end.<br>
> ><br>
> > In the line "run()._then(function (a : jsvalue) : jsvalue” give me<br>
> > the error “Error: illegal qualifier "." after "<br>
> > run():Procedure/Function"”  <br>
> <br>
> I don't think you can use a procedure, you must use a function.<br>
> <br>
> Mattias will have to confirm.<br>
<br>
Correct.<br>
<br>
function Run: JSValue; async;<br>
<br>
Mattias<br>
<br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
Pas2js maillist  -  Pas2js@lists.freepascal.org<br>
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485935387%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=wAkv7CB7Fi7dd0KlMFdh0dP4O16ykVOqqB8%2FvzpQsQo%3D&amp;reserved=0">https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freepascal.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fpas2js&amp;data=04%7C01%7C%7Cb70fc2dc548144f7f77408d924f12a9e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637581440485935387%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=wAkv7CB7Fi7dd0KlMFdh0dP4O16ykVOqqB8%2FvzpQsQo%3D&amp;reserved=0</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Pas2js Digest, Vol 39, Issue 2<br>
*************************************<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>