Jump to content

warleyalex

Members
  • Content Count

    514
  • Joined

  • Last visited

  • Days Won

    7

warleyalex last won the day on January 6

warleyalex had the most liked content!

About warleyalex

  • Rank

Profile Information

  • Location
    Brazil, Seven Lakes

Smart Mobile Studio

  • Edition
    Basic

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. warleyalex

    ecma.promise

    The unit ECMA.Promise is broken. I use this definition Using Promises in SMS unit uPromises; interface uses W3C.Console, W3C.DOM, W3C.XMLHttpRequest; type TVariantDynArray = array of Variant; JDeferred = class; TJPromiseCallback = procedure(Value: Variant); TJDeferredObject_fn = function(d: TJPromiseCallback): Variant; TJDeferredObject = procedure(resolve: TJPromiseCallback; reject: TJPromiseCallback); TJPromiseCallback_fn = function(Value: Variant): Variant; TJDeferredEventHandler = function(event: Variant): Variant; JPromise = class external 'Promise' constructor Create(fn: TJDeferredObject_fn { = nil}); overload; constructor Create(resolve: TJDeferredObject_fn; reject: TJDeferredObject_fn); overload; constructor Create(fn: TJDeferredObject); overload; function always(alwaysCallbacks: TVariantDynArray): JPromise; function done(doneCallbacks: TVariantDynArray): JPromise; overload; function done(doneCallbacks: Variant): JPromise; overload; function fail(failCallbacks: TVariantDynArray): JPromise; function progress(progressCallbacks: TVariantDynArray): JPromise; function state(): string; function &then(doneCallbacks: Variant; failCallbacks: Variant{ = undefined}; progressCallbacks: Variant { = undefined}): JPromise; external 'then'; function &then(onFulfilled: TJPromiseCallback_fn = nil): JPromise; overload; external 'then'; function &then(onFulfilled: TJPromiseCallback_fn; onRejected: TJPromiseCallback_fn): JPromise; overload; external 'then'; function &then(onFulfilled: TJPromiseCallback; onRejected: TJPromiseCallback): JPromise; overload; external 'then'; function catch(rejecTJPromiseCallback: Variant = nil): JPromise; overload; function catch(rejecTJPromiseCallback: TJPromiseCallback_fn): JPromise; overload; class function promise(target: Variant): JPromise; end; type JDeferred = class external 'Promise'(JPromise) function notify(args: TVariantDynArray): JDeferred; function notifyWith(context: Variant; args: TVariantDynArray): JDeferred; function reject(args: TVariantDynArray): JDeferred; overload; function reject(args: Variant): JDeferred; overload; function reject(args: TJDeferredEventHandler): JDeferred; overload; function rejectWith(context: Variant; args: TVariantDynArray): JDeferred; function resolve(args: TVariantDynArray): JDeferred; overload; function resolve(value: Variant = nil): JPromise; overload; function resolveWith(context: Variant; args: TVariantDynArray): JDeferred; function all(iterable: TVariantDynArray): JPromise; overload; function race(iterable: TVariantDynArray): JPromise; end; { global external functions } function Promise : JDeferred; external 'Promise' property; function queue: JPromise; external 'Promise.resolve()'; function Error(message: variant): variant; external 'Error'; function document: variant; external "document" property; function window : Variant; external 'window' property; function &typeof(obj:variant): variant; overload; external "typeof"; function wait(ms: Integer): JPromise; function getURI(url: string): Variant; function getFile(url: string): variant; //function myRequire(url: string): Variant; implementation function wait(ms: Integer): JPromise; function setTimeout(ahandler : TJPromiseCallback; aTimeout : Integer): Integer; external 'window.setTimeout'; begin result := JPromise.Create( procedure (resolve, reject: TJPromiseCallback) begin setTimeout(resolve, ms); end); end; function getURI(url: string): Variant; var request: JXMLHttpRequest; procedure p(resolve: TJPromiseCallback; reject: TJPromiseCallback); // Standard XHR to load an image procedure doOnLoad; begin // This is called even on 404 etc // so check the status if (request.status = 200) then begin // If successful, resolve the promise by passing back the request response resolve(request.response); end else begin // Otherwise reject with the status text // which will hopefully be a meaningful error reject(Error('File didn''t load successfully; error code: ' + request.statusText)); end; end; procedure doOnError; begin // Also deal with the case when the entire request fails to begin with // This is probably a network error, so reject the promise with an appropriate message reject(Error('There was a network error.')); end; Begin request := JXMLHttpRequest.Create; request.open('GET', url); // When the request loads, check whether it was successful request.addEventListener('load', @doOnLoad); // Handle network errors request.addEventListener('abort', @doOnError); // Send the request request.send(); End; begin // Create new promise with the Promise() constructor; // This has as its argument a function // with two parameters, resolve and reject Result := JPromise.Create(@p); end; function getFile(url: string): variant; begin // Create new promise with the Promise() constructor; // This has as its argument a function // with two parameters, resolve and reject Result := JPromise.create( procedure(resolve: TJPromiseCallback; reject: TJPromiseCallback) // Standard XHR to load an image var request: JXMLHttpRequest; begin request := new JXMLHttpRequest(); request.open('GET', url); // When the request loads, check whether it was successful request.onload := lambda begin // This is called even on 404 etc // so check the status if (request.status = 200) then begin // If successful, resolve the promise by passing back the request response resolve(request.response); end else begin // Otherwise reject with the status text // which will hopefully be a meaningful error reject(Error("File didn't load successfully; error code: " + request.statusText)); end; end; end; // Handle network errors request.onerror := lambda // Also deal with the case when the entire request fails to begin with // This is probably a network error, so reject the promise with an appropriate message reject(Error('There was a network error.')); end; // Send the request request.send(); end); end; /* function myRequire( url: string): Variant; function ev(win: Variant; arr: array of Variant): Variant; external 'eval.apply'; var ajax: JXMLHttpRequest; function onReady(event: JEvent): Variant; var script: Variant; begin script := ajax.response; // ?? ajax.responseText; if (ajax.readyState = 4) then begin case( (ajax.status)) of 200: begin //eval.apply( window, [script] ); ev( window, [script] ); console.log('script loaded: '+ url); end else console.log('ERROR: script not loaded: '+ url); end; end; end; begin ajax := JXMLHttpRequest.Create; ajax.open( 'GET', url, false ); // <-- the 'false' makes it synchronous ajax.onreadystatechange := @onReady; ajax.send(null); end;*/ end.
  2. warleyalex

    stable x unstable IDE

    I don't want to interrupt your holidays. I thought I was going crazy. Crazy about smart. I have SMS 2.2.2 (last winXP), SMS 3.0.2 (stable release) and SMS 3.1.0.80 (development) installed. It was exactly the same project, same source, but I forgot to copy the SynCrossPlatform units ( SynCrossPlatformCrypto.pas | SynCrossPlatformREST.pas | SynCrossPlatformSpecific.pas ) into SMS3.0.20/Libraries folder and the issue has vanished, the designer worked as expected in SMS 3.0.2.20 - without any error.
  3. warleyalex

    mORMot with SMS

    In fact, there is an bug on older SMS versions 1.2 | 2.0 | 2.0.1 | 2.2 and 2.2.2 - the TObject::Destroy method would just delete the property named "prop" rather than the actually all the properties of the object itself. For instance, obj.Free is doing nothing because the method Destroy was buggy // old SMS version var TObject={ (...) Destroy: function (s) { for (var prop in s) if (s.hasOwnProperty(prop)) delete s.prop }, Destroy$: function(s) { return s.ClassType.Destroy(s) }, (...) } On newer SMS version 3.x, they fixed the TObject::Destroy method.
  4. warleyalex

    stable x unstable IDE

    The download link from SMS 3.0.2 stable release: https://smartmobilestudio.com/download/3.0.2/setup.exe There is no issue when I drag n' drop a new widget/TWButton onto designer then double click at the button in SMS 3.0.2. This is an old SMS project, created with SMS 2.0.1 - packed with winrar 5.50. SMS 3.0.2 can open it but we can not jump to the W3Button1Click procedure like 3.1.x.
  5. warleyalex

    stable x unstable IDE

    SMS 3.1.0.80 (from the development channel) works as expected! The issue is from the SMS 3.0.2.20 (stable release). When I click at the widget button/W3Button2 for instance, it would go to the code editor W3Button2Click procedure in the 3.1x, but fails at 3.0x. <object type="TW3Button"> <Caption>W3Button</Caption> <Width>128</Width> <Top>272</Top> <Left>272</Left> <Height>32</Height> <Name>W3Button2</Name> <OnClick>W3Button2Click</OnClick> </object> ver3x.rar
  6. warleyalex

    stable x unstable IDE

    I've got different tastes between SMS 3.0.2.20 and SMS 3.1.0.80. The latter is works as expected. When I open a simple project in the stable version 3.0.2, and I click in button in the project, it displays "Program has errors. Operation might not be completed." It says in the 3.0.2 (this version contains all the fixes and improvements from the development-channel).
  7. warleyalex

    Smart Mobile Studio 3.0.2 is released!

    SMS 3.0.2 portable version a) Simple click at https://smartmobilestudio.com/download/3.0.2/setup.exe to install SMS 3.0.2 and install at "C:\smartms" b) move all files and directories from "C:\Users\All Users\The Smart Company\Smart Mobile Studio" to the folder "C:\smartms" c) create a file called "settings.ini" at the directory "C:\smartms" [Settings] Channel=DEVELOPMENT RelativePaths=1
  8. warleyalex

    mORMot with SMS

    I submitted the Destroy method issue to Eric Grange https://bitbucket.org/egrange/dwscript/issues/150/destroy-method
  9. warleyalex

    mORMot with SMS

    Smart Mobile Studio Compiler version 1.2 emits this var TObject={ $ClassName: "TObject", $Parent: null, ClassName: function (s) { return s.$ClassName }, ClassType: function (s) { return s }, ClassParent: function (s) { return s.$Parent }, $Init: function () {}, Create: function (s) { return s }, Destroy: function (s) { for (var prop in s) if (s.hasOwnProperty(prop)) delete s.prop }, Destroy$: function(s) { return s.ClassType.Destroy(s) }, Free: function (s) { if (s!==null) s.ClassType.Destroy(s) } }; Now, I've been thinking, the correct is the SMS 3.1x that emits delete s[prop]; var myObject = { "ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*" }; function destruir(s) { for (var prop in s) if (s.hasOwnProperty(prop)) delete s[prop] }; destruir(myObject); It will remove all properties from JavaScript object myObject. ---> this is the expected! The delete operator is more about freeing memory than deleting an element. function destruir(s) { for (var prop in s) if (s.hasOwnProperty(prop)) delete s.prop }; destruir(myObject); delete s.prop --> don't delete properties ---> the myObject is still there: {ircEvent: "PRIVMSG", method: "newURI", regex: "^http://.*"} I think we have the wrong delete s.prop in SMS 1.2 / 2.0 / 2.1 / 2.2
  10. warleyalex

    FormatDateTime?

    When you use the settings "mmmm" in the "FormatDateTime" method, internally checks case "mmmm": res+=$fmt.LongMonthNames[dt.getUTCMonth()]; break; var $fmt = { (...) LongMonthNames : [ "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" ],(...) } You can capitalize the first letter: function capitalizeFirstLetter(str: Variant): Variant; begin Result:= str[0].toUpperCase() + str.slice(1); end; capitalizeFirstLetter( formatDateTime('mmmm yyyy', Now) );
  11. warleyalex

    mORMot with SMS

    It is a bug! SmartMS 2.2.2.4694 emits correct JS, it comes with delete s.prop var myObject = { "ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*" }; delete myObject.regex; // it also work with delete myObject['regex']; Note delete s[prop] instead of delete s["prop"] Source: https://stackoverflow.com/questions/208105/how-do-i-remove-a-property-from-a-javascript-object
  12. warleyalex

    mORMot with SMS

    Smart Mobile Studio 3.1 with mORMot Nowadays, the synchronous methods are deprecated is most modern browsers, that "false" makes the request synchronous (i.g. request.open('GET', '/bar/foo.txt', false)), besides the message it works. Note: Starting with Gecko 30.0 (Firefox 30.0 / Thunderbird 30.0 / SeaMonkey 2.27), Blink 39.0, and Edge 13, synchronous requests on the main thread have been deprecated due to the negative effects to the user experience. Anyway, both synchronous and asynchronous methods are available, depending on use case. For instance, you can invoke a method to calculate both in syn or async ways. The synchronous, are methods starting with underscore _*() methods will block the browser execution, so won't be appropriate for long process - on error, they may raise EServiceException. It could be useful in order to interact in background with the server or the preload some content. You shouldn't use sync methods in the future, because it's deprecated. They work but shouldn't be there. I don't pretty sure, but I think the mORMot authentication scheme uses synchronous method for the handshaking process. You must create a service method on the server side and simply typing http://127.0.0.1:888/root/wrapper to generate smartmobilestudio wrapper client, and use the generated unit inside SMS client, like proj 27. I spent hours debugging an issue because in SMS 3.1x I couldn't detect why it couldn't work like in the previous version 2.2x. I realized a lot of optimizations was done in the 3x, like the direct implementation without the intermediary Result variable in the function returning. Anyway, I realized something was bit different from the previous version: In version 3.1x, it emits this piece: var TObject={ $ClassName: "TObject", $Parent: null, ClassName: function (s) { return s.$ClassName }, ClassType: function (s) { return s }, ClassParent: function (s) { return s.$Parent }, $Init: function (s) {}, Create: function (s) { return s }, Destroy: function (s) { for (var prop in s) if (s.hasOwnProperty(prop)) delete s[prop] }, Destroy$: function(s) { return s.ClassType.Destroy(s) }, Free: function (s) { if (s!==null) s.ClassType.Destroy(s) } } I propose this little change be made is SMS 3.1x: Destroy: function (s) { for (var prop in s) if (s.hasOwnProperty(prop)) delete s.prop }, This little issue fixed we can use Smart 3.1x with mORMot with no more errors. According to mORMot documentation, since there is no true file system API available under a HTML5 sand-boxed application, logging to a local file is not an option. Even when packaged with PhoneGap, local log files are not convenient to work with. Generated logs will have the same methods and format as with Delphi or FreePascal - see Local or remote logging. TSQLRest.Log(E: Exception) method will also log the stack trace of the exception! Our LogView tool - Logview - is able to run as a simple but efficient remote log server and viewer, shared with regular or cross-platform units of the framework. A dedicated asynchronous implementation has been refined for Smart Mobile Studio clients, so that several events will be gathered and sent at once to the remote server, to maximize bandwidth use and let the application be still responsive. It allows even complex mobile applications to be debugged with ease, on any device, even over WiFi or 3G/4G networks. Your support could ask your customer to enable logging for a particular case, then see in real time what is wrong with your application. You can use remote logging with smart Mobile Studio! It's cool. I'll have to submit the CrossPlatform units to AB to generated the correct wrapper. smartms_mormot.rar
  13. warleyalex

    SMS and MORMOT

    picture more than thousand words: mORMot with Smart Mobile Studio 3
  14. warleyalex

    SMS and MORMOT

    You can invoke a webservice created with MORMot to perform the authentication and call some services, thanks to suberb work by Arnauld Bouchez http://blog.synopse.info/post/2014/08/11/CrossPlatform-Clients/SmartMobileStudio, interface-based service can be accessed via a SmartPascal for instance, this classes are 100% smart pascal code compatible, just to prove the power the smart pascal. You can use even the SMS Basic version, but you don't have support from the desginer, you basically have to create the views and binding using the controllers (smart units), the point is you don't need to pay the Enterprese edition to consume mORMot services, of couse the professional editions is recommended. I can't believe SMS didn't put this feature info into https://smartmobilestudio.com/feature-matrix/, IMHO it may be a good selling point for SmartMobileStudio. The super-robo-architect AB has designed the units for months... I still can not believe it today, SMS didn't give due value to the super-robo-architect. Some months writting some the lib, the units will be generated directly from the mORMot server, there is no package to be installed within the SMS IDE, there is no wrappers involved, the clients are 100% written in smart pascal dialect. to enable/generate the smartmobilestudio wrapper class, just go to http://127.0.0.1:888/root/wrapper and paste into smart mobile studio for news projects. Smart Mobile Studio with mORMot is very interesting!
  15. warleyalex

    5-minute with SMS 3.1.0.75 overview

    It is known that Smart Mobile Studio applications start big, but don't grow very fast once functionality is added. In my sick project, we have 50 Forms; each form = 50 buttons, I just wanted to indicated that size is not necessarily an obstacle to writing a good web application, but using SMS 3.1.0.75 a little big file size, we've got a Index.html around 632KB (minified & obfuscated enabled). On the previous 2.2.2 version we've got similar 305KB. I remember on older versions, when I re-size the browser window, I get two successive on Resize firing all the time to all forms. I remember on previous versions (2.2) we've got two sucessive Resize event firing all the time to "all forms", and this will reduce the browser's workload. In the actual version 3.1.0.75, SMS has reduzed the bottleneck coming from the Resize event. Resize is firing multiple times yet, three times for the activate form, at least, but this is great. SmartMS.exe 3.1.0.75 has greatly increased the file size, from 7MB to 15MB, a lot of resources have been added... I don't have time to see all the features... How can I create a simple property of type String that will show a combo box in the object inspector with a predefined set of values the user could choose inside SMS IDE. I know it is possible in this version. I just don't know how! type TCustomStyle = array[1..3] of string; const CustomStyle : TCustomStyle = ('iOS','Android','Material'); type TMystyle = (cssIOS, cssAndroid, cssMaterial); TToggleComponent = class(TW3CustomControl) private fMyStyle: TMystyle; fCustomStyle : TCustomStyle; published property Mystyle: TMystyle Read fMyStyle Write fMyStyle default cssAndroid; property CustomStyle: TCustomStyle Read fCustomStyle Write fCustomStyle; How can I implement my own custom property editor for of a certain object type and see in the Object Inspector? I really appreciate the smartms community we have here. SMS 3.1.0.75 has its strenghts and limits. It does wonders for the the Controller part. Some areas, SMS is so rudimentary that, in practice, that RTL alone *.CL - does no provide a sufficient framework for development. I would like SmartMS should focus on the IDE and the compiler. When it comes to writing smart components, interesting components, like page swiper, searchBar, scrolling, reactive components, etc. I believe the correct approach should be based NOT using "pure smart pascal" approach, it seems everybody ends up rewriting another ball, it's seems, likely waste a lot of time solving problems others have already solved. I think a good alternative to go is SMS with vue. Using wrapper class around the even old vue you can create reactive components with small footprint with only 58KB, the core components in SMS should be based in this optimized vue library with minimal processing and memory overhead, then you have high level methods (based on external interfaces) to call such methods. That's not necessarily a bad thing using a vue Framework with SmartMS. I think you can achieve the same functionality used in the *.CL framework. I Like the SMS designer, but I can't seem to find anyway how to get the live preview on the smart components. One thing it's ugly to drag n' drop visual/non visual components and you see that retangle on the designer that represents the component. The leadership, Jon Lennart Aasenden, has quit his baby. Some ideas from Jon sounds like FUD to me, like Smart Desktop/Raspberry PI, the unfinished book, etc. It seems to be running too many races at once a bad idea. I'd prefer focusing on a "single target", for instance, mobile apps with a decent UI (not the current RAD approach, which is difficult to work with on real projects with a lot of screens) would be a good start. We do not need stories about SMS potential and implementation wishes, but real working features. We do not need to know what SMS "can do", but what SMS "does". It seems like there is a better future for SMS. I will open a bottle of wine here.
×