Jump to content

EWB

Members
  • Content count

    494
  • Joined

  • Last visited

  • Days Won

    143

EWB last won the day on January 14

EWB had the most liked content!

About EWB

  • Rank

Profile Information

  • Location
    Brazil, Seven Lakes

Business

Smart Mobile Studio

  • Edition
    Basic
  1. Smart Test Framework

    Hey, here is the SMS test framework fixed! Projct download: ProjTester
  2. c++

    The PostInc and PostDec functions (using variable per reference) DOES NOT work on the initialization section!. On the implementation section, it's seems to be working for me. /* VARIABLE++ */ function PostInc(var i: integer): integer; begin Result := i; inc(i); end; /* VARIABLE-- */ function PostDec(var i: integer): integer; begin Result := i; Dec(i); end; initialization var j : Integer; var s := [ postInc(j), j, Inc(j), j, postDec(j), j, Dec(j), j] ; //---> [undefined, 0, 1, 1, undefined, 1, 0, 0]
  3. c++

    Pre-increment: 1. Let's say you want to buy a very expensive apple for $2 2. Your mam gives you $1 3. You ask your dad and he decides to give you $1 dollar too 4. You buy the apple 5. Total money received: $2 Post-increment: 1. You want the same apple for $2 2. Mam gives you $1 3. You ask dad, but dad will only give you a dollar when you bring something back for him from the shop 4. You go to the shop but can't buy the apple, and bring something back for your dad 5. Total money received: $2 In javascript world: var i = 0; [ i++, i, ++i, i, i--, i, --i, i ]; //----> [0, 1, 2, 2, 2, 1, 0, 0] In smart pascal world: AFAIK, smart don't have the equivalent i++ post increment operator, inc(i) will emit --i the trick to mimic i++ and i-- var j := 0; var postInc := lambda(): integer; j += 1; result := j - 1; end; var postDec := lambda(): integer; j -= 1; result := j + 1; end; [ postInc, j, Inc(j), j, postDec, j, Dec(j), j] ; //----> [0, 1, 2, 2, 2, 1, 0, 0]
  4. back(s)lash

    uses ECMA.JSON type JC = record id : integer; external 'id'; name : string; external 'name'; age : integer; external 'age'; end; JB = record field1 : string; external 'field1'; params : Array of JC; external 'params'; end; JA= record fields : array of JB; external 'JA'; end; var recA : JA; recB : JB; recC : JC; for var k:=0 to 5 do begin recC.id := k; recC.name := 'abc'+IntToStr(k); recC.age := 10+k; recB.field1 := 'rec'+ IntToStr(k); recB.params.Add(recC); recA.fields.Add(recB); end; { "JA" : [{ "field1" : "rec0", "params" : [{ "id" : 0, "name" : "abc0", "age" : 10 }, { "id" : 1, "name" : "abc1", "age" : 11 }, { "id" : 2, "name" : "abc2", "age" : 12 }, { "id" : 3, "name" : "abc3", "age" : 13 }, { "id" : 4, "name" : "abc4", "age" : 14 }, { "id" : 5, "name" : "abc5", "age" : 15 } ] }, { "field1" : "rec1", "params" : [{ "id" : 0, "name" : "abc0", "age" : 10 }, { "id" : 1, "name" : "abc1", "age" : 11 }, { "id" : 2, "name" : "abc2", "age" : 12 }, { "id" : 3, "name" : "abc3", "age" : 13 }, { "id" : 4, "name" : "abc4", "age" : 14 }, { "id" : 5, "name" : "abc5", "age" : 15 } ] }, { "field1" : "rec2", "params" : [{ "id" : 0, "name" : "abc0", "age" : 10 }, { "id" : 1, "name" : "abc1", "age" : 11 }, { "id" : 2, "name" : "abc2", "age" : 12 }, { "id" : 3, "name" : "abc3", "age" : 13 }, { "id" : 4, "name" : "abc4", "age" : 14 }, { "id" : 5, "name" : "abc5", "age" : 15 } ] }, { "field1" : "rec3", "params" : [{ "id" : 0, "name" : "abc0", "age" : 10 }, { "id" : 1, "name" : "abc1", "age" : 11 }, { "id" : 2, "name" : "abc2", "age" : 12 }, { "id" : 3, "name" : "abc3", "age" : 13 }, { "id" : 4, "name" : "abc4", "age" : 14 }, { "id" : 5, "name" : "abc5", "age" : 15 } ] }, { "field1" : "rec4", "params" : [{ "id" : 0, "name" : "abc0", "age" : 10 }, { "id" : 1, "name" : "abc1", "age" : 11 }, { "id" : 2, "name" : "abc2", "age" : 12 }, { "id" : 3, "name" : "abc3", "age" : 13 }, { "id" : 4, "name" : "abc4", "age" : 14 }, { "id" : 5, "name" : "abc5", "age" : 15 } ] }, { "field1" : "rec5", "params" : [{ "id" : 0, "name" : "abc0", "age" : 10 }, { "id" : 1, "name" : "abc1", "age" : 11 }, { "id" : 2, "name" : "abc2", "age" : 12 }, { "id" : 3, "name" : "abc3", "age" : 13 }, { "id" : 4, "name" : "abc4", "age" : 14 }, { "id" : 5, "name" : "abc5", "age" : 15 } ] } ] }
  5. TPersistent idea

    Hi there, we've created this demo ObjectList with navigation using SMS. The classes were based on this custom uWebCore unit. It would be awesome to add persistence and load JSON easily. type TCust = class(TPersistent) private FCustomerID: String; FCompanyName: String; FAddress1: String; FAddress2: String; FCity: String; FStateProvince: String; FZipPostalCode: String; FCountry: String; FTerms: String; FNotes: String; FContact: String; FContactEmail: String; FContactPhone: String; published property CustomerID: String read FCustomerID write FCustomerID; property CompanyName: String read FCompanyName write FCompanyName; property Address1: String read FAddress1 write FAddress1; property Address2: String read FAddress2 write FAddress2; property City: String read FCity write FCity; property StateProvince: String read FStateProvince write FStateProvince; property ZipPostalCode: String read FZipPostalCode write FZipPostalCode; property Country: String read FCountry write FCountry; property Terms: String read FTerms write FTerms; property Notes: String read FNotes write FNotes; property Contact: String read FContact write FContact; property ContactEmail: String read FContactEmail write FContactEmail; property ContactPhone: String read FContactPhone write FContactPhone; end; Const Cust1Props = '{'+CRLF+ '"CustomerID": "ADF",'+CRLF+ '"CompanyName": "American Dream Factory, Inc.",'+CRLF+ '"Address1": "43 Cherry Street",'+CRLF+ '"Address2": "",'+CRLF+ '"City": "Langley Falls",'+CRLF+ '"StateProvince": "Virginia",'+CRLF+ '"ZipPostalCode": "24870",'+CRLF+ '"Country": "United States",'+CRLF+ '"Terms": "Cash\/Check", "Notes": "Can''t seem to catch up, always behind schedule.",'+CRLF+ '"Contact": "Stan Smith",'+CRLF+ '"ContactEmail": "stan.smith@americandreamfactory.com",'+CRLF+ '"ContactPhone": "587-555-6200"'+CRLF+ '}'; Const Cust2Props = '{'+CRLF+ '"CustomerID": "DM",'+CRLF+ '"CompanyName": "Dunder Mifflin, Inc.",'+CRLF+ '"Address1": "78 Branch Street",'+CRLF+ '"Address2": "",'+CRLF+ '"City": "Scranton",'+CRLF+ '"StateProvince": "Pennsylvania",'+CRLF+ '"ZipPostalCode": "38410",'+CRLF+ '"Country": "United States",'+CRLF+ '"Terms": "Net 30",'+CRLF+ '"Notes": "Very weird manager.",'+CRLF+ '"Contact": "Michael Scott",'+CRLF+ '"ContactEmail": "michael.scott@dundermifflin.com",'+CRLF+ '"ContactPhone": "360-555-4410"'+CRLF+ '}'; procedure TForm1.InitializeObject; begin inherited; Reader:= TReader.Create; Writer:= TWriter.Create; CreateCustomers; InitializeCustomer1; SaveCustomer1; InitializeCustomer2; SaveCustomer2; end; procedure TForm1.CreateCustomers; begin Customer1:= TCust.Create; Customer2:= TCust.Create; end; procedure TForm1.FreeCustomers; begin Customer1.Free; Customer1:=nil; Customer2.Free; Customer2:=nil; end; procedure TForm1.InitializeCustomer1; begin Reader.Initialize(Cust1Props); Customer1.Load(Reader); end; procedure TForm1.InitializeCustomer2; begin Reader.Initialize(Cust2Props); Customer2.Load(Reader); end; procedure TForm1.LoadCustomer1; begin Reader.Initialize( Cust1Props ); Customer1.Load(Reader); end; procedure TForm1.LoadCustomer2; begin Reader.Initialize( Cust2Props ); Customer2.Load(Reader); end; procedure TForm1.SaveCustomer1; begin Writer.Initialize; Customer1.Save(Writer); WriteLn ( Writer.Output ); end; procedure TForm1.SaveCustomer2; begin Writer.Initialize; Customer2.Save(Writer); WriteLn ( Writer.Output ); end; Unfortunately, I still didn't finish to convert this uWebCore unit, its not fully implemented, we still have some issues related to the parser. Just a heads up.
  6. Black Screen of Death

    Just place DebugBreak somewhere in your code, and it will act like a breakpoint. You need to have Chrome Developer Tools open for this to work (hit F12). If you have Developer Tools open, an extra bit of awesomeness is that you can click and hold the Refresh button to clear the cache. I step through Code using chrome directly not using the internal SMS integrated debugger! procedure TForm1.Button1Click(Sender: TObject); begin DebugBreak; console.log('Button1 clicked'); end; My SMS integrated debugger is disabled.
  7. Black Screen of Death

    thanks for the feedback!
  8. Since SMS is using the TControlHandleHelper everywhere. Use requestAnimationFrame instead of setTimeout. Instead of running after a certain period of time, though, it runs the next time page paint is requested. I think this provides a better way to loop over events, because it runs when the browser paint is actually happening, rather than when we guestimate it will. I sincerely didn't test the approach. procedure TControlHandleHelper.ReadyExecuteAnimFrame(const OnReady: TProcedureRef); begin var LExists := BrowserAPI.Body.contains(self); if LExists then TW3Dispatch.RequestAnimationFrame(OnReady) else begin (* Try again ASAP *) //TW3Dispatch.SetTimeout(procedure () // begin // ReadyExecuteAnimFrame(OnReady); // end, 100); TW3Dispatch.RequestAnimationFrame(procedure () begin ReadyExecuteAnimFrame(OnReady); end); end; end; procedure TControlHandleHelper.ReadyExecuteEx(const Tag: TObject; const OnReady: TProcedureRefO); begin var LExists := BrowserAPI.Body.contains(self); if LExists then OnReady(Tag) else /*TW3Dispatch.SetTimeout(procedure () begin ReadyExecuteEx(Tag, OnReady); end, 100);*/ TW3Dispatch.RequestAnimationFrame(procedure () begin ReadyExecuteEx(Tag, OnReady); end); end; procedure TControlHandleHelper.ReadyExecute(const OnReady: TProcedureRef); Begin var LExists := BrowserAPI.Body.contains(self); if LExists then OnReady() else /*TW3Dispatch.SetTimeout(procedure () begin ReadyExecute(OnReady); end, 100);*/ TW3Dispatch.RequestAnimationFrame(procedure () begin ReadyExecute(OnReady); end); end;
  9. See the above picture, there's also Syntax error at SmartCL.System unit when using the old SmartMS.exe ver 2.2.2.4694 I have to edit C:\Smart\RTL\SmartCL\SmartCL.System.pas and fix the lines 1108 and 1154. function w3_getIsChrome: Boolean; begin var LUserAgent := TVariant.AsString(BrowserAPI.Navigator.userAgent).ToLower(); if LUserAgent.Contains('chrome') then result := if Boolean(BrowserAPI.window.chrome) then true else false; end; function w3_getIsOpera: Boolean; begin result := if Boolean(BrowserAPI.window.opera) then true else false; end;
  10. a. extract all files from SMS Alpha download link to C:\Smart then launch SmartUpdate.exe, now we SMS version 2.9.9.90. b. Since I'm using the deprecated OS System (Windows XP SP3), the new SmartMS.exe does not run on this system. I've replaced to an old version 2.2.2.4694. I using this OS under UBUNTU. I've used the above steps and now is working for me.
  11. Black Screen of Death

    When I start the app and I get the black screen hell, no syntax errors, no hints. Logic errors are more difficult to debug than syntax errors because they're not something that outwardly looks wrong. The syntax of the code is written correctly, but it's just not doing what you want it to do. Debugging logic errors requires more work, luckily I could find the issue in minutes. The uWebUI unit have 15,550 lines, and apparently there are some logic error in some place that I'm getting the black screen, the JavaScript Debugger tool makes the work much easier to find syntax error, but where to set the breakpoint? Before I begin debugging, let's take a look at the problem: In the uWebUI unit, the main class is TInterfaceManager. We know that "the TInterfaceManager class represents the interface manager, which is responsible for managing the user interface of an application at both design-time and run-time. A global instance of the TInterfaceManager class is created automatically at application startup, and is called InterfaceManager". we have to invoke the debugger at the TInterfaceManager constructor! Firstly, I've created a global function function debugger: variant; external "debugger"; constructor TInterfaceManager.Create; begin inherited Create; debugger; {...} end; Stepping Through Code, using F9 and F10, I couldn't find the error. Step Over (F9)—Step Over allows you to execute one line of code at a time. When you're on a line that executes an if statement and you press Step Over, it checks to see whether the condition in the if statement is met. If the condition is met, the debugger moves to the next line. When the condition in the if statement is not met, the debugger jumps to the else portion of the statement (assuming that there is an else portion) or jumps to the next section of code. Step Into (F10)—Step Into allows you to step into a function and monitor the execution of each line in that function. Once inside the function, you can use Step Over to move line by line. Step Out (F11)—Use Step Out when you have stepped into a function, have verified what you wanted to see, and want to automatically execute the rest of the function without having to step over each remaining line of the function. Once the Debugger completes running through the function, you can continue stepping through the rest of the code line by line (if you want). I could Identify a suspect method called CreateRootElement(ROOT_ELEMENT_NAME,ELEMENT_CLASS_BODY); I don't know, I've been thinking, is this method trying to create the body element? Just commented this method and no more black screen! Thank you a lot.
  12. I just download the SMS Alpha 2.9.9.80 and created a hello world program to test on my old shoes the virtual WinXP (XP under Ubuntu). The new SMS compiler does not work on this environment, we've got some kind of silence error "run and exit". They're probably using some feature that is not supporting Windows XP. So, I'll stick with the old compiler version 2.2.2.4694 and test the alpha RTL. When I first run SmartMS.exe I've got the Loading package failed message: We have to edit some files to fix this entry message box. a. edit SmartCL.Controls.ToolBar and SmartCL.Controls.Header units, this is very weird, I had to add "overload" to disappear the Hint. 48' procedure SetBounds(const NewLeft, NewTop, NewWidth, NewHeight: integer); overload; override; b. about the Redundant specifier, visibility is already “PROTECTED”, is just duplicated Protected keyword used at the SmartCL.Controls.Elements and SmartCL.DBGrid units, we have to edit those units and comment duplicated protected keywords. They forgot to clean up those units. In the SmartCL.DBGrid, we have to replace "OffsetY" to "ScrollTop". c. The syntax Error: No method “SupportAdjustment” ??? The Slider component can be found at the C:\smart\RTL\SmartCL\SmartCL.Slider.pas, alright? but this component was designed " as internal" this component and not made "external" as expected! A quick fix, just edit C:\smart\Packages\SmartCL.Slider.spk and comment the SupportAdjustment (does not exist anymore) public //class function SupportAdjustment: Boolean; override; /*class function TW3Slider.SupportAdjustment: Boolean; begin Result := False; end;*/ d. OK. No message box anymore. Now, I'm going to create my Hello World program, it's just a evil WriteLn( FormatDateTime('dddd d of mmmm yyyy', now) ); When we try to execute this malicious code project, we've surprised got some unexpected error, dialog box, I suspect what would be I had to edit C:\smart\Templates\default.html, hum my old compiler does not suppport this <?pas=Project.WebFonts?> So I just deleted this above line. I suspect the project will inject some web font at the project by default, and the actual compiler does not understand this keyword. e. hum. no more unexpected error dialog. Now, I'll try to execute the project and then a Syntax Error: Syntax Error: Unknown name "TW3ThemeBackground" [line: 1066, column: 30, file: SmartCL.Dialogs] a nasty trick would go to the Project Options --> Compiler --> Custom conditionals defines: --> I must to define a directive here called: THEME_AUTOSTYLE; f. and it was compiled! when I run the project I've got "ReferenceError, fmtLongMonthNames is not defined" g. almost there. My evil program uses a function FormatDateTime('dddd d of mmmm yyyy', now) I would expect something like: "friday 22 of december 2017" We have to edit the source code, the old compiler uses a registred function called function FormatDateTime(fmt, v, u) which there's a minor error the codegen emit case "mmmm": res+=fmtLongMonthNames[dt.getUTCMonth()]; break; but the correct is: case "mmmm": res+=$fmt.LongMonthNames[dt.getUTCMonth()]; break; Now, it's working for me.
  13. Black Screen of Death

    We've converted more than 64K source lines code to SMS in 24h, the code was structured in various units (32). Most of the EWB code translates well, but more unusual code and some sophisticated language feature (e.g. property overloading), we've got crashed with runtime errors, internal errors, but a few patches got gents to about 90% of what we needed. Even then, the remaining 10% was till enormous. When running the project, I can't see anything except a black screen, no messages errors, we usually get some obscure hidden error occurred somewhere. Yes, this is a real nightmare. The issue is probably on the big uWebUI unit (3x bigger then SmartCL.Components ), it has more than 15K of source lines. A very challenging is discover where lives the source of the black screen.
  14. directive HINTS OFF issue

    I'd like to disable some compiler hints: [INFO] Building project 'projEWB'... [INFO] Compilation successful [1 seconds,531 ms] Hint: Private method "RegisterElementClass" declared but never used [line: 3449, column: 19, file: uWebUI] Hint: Private method "UpdateAlwaysOnTop" declared but never used [line: 1873, column: 32, file: uWebUI] Hint: Private method "GetValidArc" declared but never used [line: 701, column: 19, file: uWebUI] Hint: Private method "ClearBookmarks" declared but never used [line: 463, column: 20, file: uWebData] Hint: Private method "GetIconNames" declared but never used [line: 829, column: 19, file: uWebCtrls] Hint: Private method "GetDataColumnNames" declared but never used [line: 692, column: 19, file: uWebCtrls] Hint: Private method "GetButtonsWidth" declared but never used [line: 521, column: 19, file: uWebForms] Hint: Private method "GetButtonsHeight" declared but never used [line: 522, column: 19, file: uWebForms] Hint: Private method "SetStyle" declared but never used [line: 170, column: 20, file: uWebMaps] Hint: Private method "SetPosition" declared but never used [line: 169, column: 20, file: uWebMaps] Hint: Private method "SetPosition" declared but never used [line: 153, column: 20, file: uWebMaps] Hint: Private method "SetPosition" declared but never used [line: 140, column: 20, file: uWebMaps] Hint: Private method "SetPosition" declared but never used [line: 127, column: 20, file: uWebMaps] Hint: Private method "SetOpened" declared but never used [line: 114, column: 20, file: uWebMaps] Hint: Private method "SetStyle" declared but never used [line: 94, column: 20, file: uWebMaps] Hint: Private method "SetPosition" declared but never used [line: 93, column: 20, file: uWebMaps] Hint: Private method "SetZoomControl" declared but never used [line: 227, column: 20, file: uWebMaps] Hint: Private method "SetZoom" declared but never used [line: 226, column: 20, file: uWebMaps] Hint: Private method "SetTilt" declared but never used [line: 225, column: 20, file: uWebMaps] Hint: Private method "SetStreetViewControl" declared but never used [line: 224, column: 20, file: uWebMaps] Hint: Private method "SetScrollWheel" declared but never used [line: 223, column: 20, file: uWebMaps] Hint: Private method "SetScaleControl" declared but never used [line: 222, column: 20, file: uWebMaps] Hint: Private method "SetRotateControl" declared but never used [line: 221, column: 20, file: uWebMaps] Hint: Private method "SetPanControl" declared but never used [line: 220, column: 20, file: uWebMaps] Hint: Private method "SetOverviewMapControl" declared but never used [line: 219, column: 20, file: uWebMaps] Hint: Private method "SetMinZoom" declared but never used [line: 218, column: 20, file: uWebMaps] Hint: Private method "SetMaxZoom" declared but never used [line: 217, column: 20, file: uWebMaps] Hint: Private method "SetMapTypeControl" declared but never used [line: 215, column: 20, file: uWebMaps] Hint: Private method "SetMapType" declared but never used [line: 216, column: 20, file: uWebMaps] Hint: Private method "SetKeyboardShortCuts" declared but never used [line: 214, column: 20, file: uWebMaps] Hint: Private method "SetHeading" declared but never used [line: 213, column: 20, file: uWebMaps] Hint: Private method "SetDraggable" declared but never used [line: 212, column: 20, file: uWebMaps] Hint: Private method "SetDisableDefaultUI" declared but never used [line: 210, column: 20, file: uWebMaps] Hint: Private method "SetDisableDblClickZoom" declared but never used [line: 211, column: 20, file: uWebMaps] Hint: Private method "Initalize" declared but never used [line: 105, column: 20, file: uWebSock] [INFO] Generating JavaScript successful [16 seconds,313 ms] [INFO] Linking successful [391 ms] The directive {$HINTS OFF} does not work for me (the hints are still there) // on the interface section {$HINTS OFF} procedure UpdateAlwaysOnTop; {$HINTS ON} // on the implementation section {$HINTS OFF} procedure TElement.UpdateAlwaysOnTop; begin if Assigned(FParent) then begin if FParent.InUpdate then FParent.DoChanged(ecChildDisplayChanged) else FParent.Elements.ResetDisplayIndexes; end; end; {$HINTS ON}
  15. Async keyword

    Yeap, this is not worth to implement. I didn't see, behind the scenes, EWB was using poor setTimeout(function(){...}, 0) to break the synchronous flow. It's certainly the simplest technique - asynchronous that simply means it isn't executed sequentially. I thought they were using the new Async / Await new javascript features. This Async/Await javascript JavaScript feature that makes working with asynchronous functions much more enjoyable and easier to understand. It is build on top of Promises and is compatible with all existing Promise-based APIs, but it uses ES6. Since EWB and SMS are limited to plain ES3/ES5 javascript code and not support ES6 syntax, I found out several good alternatives to write complex asynchronous code asyncawait for Node Async utilities for node and the browser BlueBird co
×