![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 4 of 4 total |
![]() |
Fri, Jul 8 2016 7:03 PM | Permanent Link |
erickengelke | Hi, I am calling a JavaScript library. IJavaScript looks like this: hello.init({ google: '5770808.apps.googleusercontent.com' }, { redirect_uri: 'https://dark.uwaterloo.ca/oauth2/redirect.html', scope: 'basic'}); Which I tried translating to: External TGlobHelloArgs = class public property google : string read write; end; external TGlobHelloRedirect = class public property redirect_uri : string read write ; property scope : string read write; end; external THello emit hello = class public property services : array of variant read write; procedure init( args : TGlobHelloArgs ; arg2 : TGlobHelloRedirect ); procedure on( arg : string ; fn : TOnFn ); function api( what : string ):TApi; end; And this works, but only if I include a small JavaScript file that says: var myargs = {}; var myargs2 = {}; Obviously I'd like to declare the variables in EWB Objective Pascall. - - - - If I tried the alternative and create THelloArg THelloArgs = class public google : string ; end; THelloRedirect = class public redirect_uri : string; scope : string ; end; Then call Init() with these two parameters, it keeps getting stack overflows when they try to add properties, as the THelloArg is fixed in size. Is there a way to declare a variable of {} in EWB? I tried Variants and casting but didn't have any luck Thanks |
Sat, Jul 9 2016 3:50 PM | Permanent Link |
erickengelke | erickengelke wrote:
> Obviously I'd like to declare the variables in EWB Objective Pascall. >Is there a way to declare a variable of {} in EWB? I tried Variants and casting but didn't have any luck I solved it by declaring external function eval( s : string): TGlobHelloRedirect; var HelloRedirect : TGlobHelloRedirect; begin HelloRedirect = eval( 'new Object();') ... end; And it works. I don't know if you have a preferred solution that's better than this. Thanks Erick |
Sat, Jul 9 2016 4:39 PM | Permanent Link |
erickengelke | erickengelke wrote:
erickengelke wrote: >I solved it by declaring >external function eval( s : string): TGlobHelloRedirect; Small problem, external function eval( s : string) does not support overloading. Only the first registered type is supported (In 2.05 beta) so I declaree eval(s: string) of type object and cast it to the appropriate type. Done. |
Mon, Jul 11 2016 8:41 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | << Is there a way to declare a variable of {} in EWB? I tried Variants and casting but didn't have any luck >> There is, but it's undocumented: function CreateObject(const ObjectLiteral: String): TObject; Just cast the result to the desired class type, and you'll be all set. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Thursday, March 30, 2023 at 10:19 AM | Privacy Policy![]() © 2023 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |