Jump to content

bilcan

Members
  • Content Count

    24
  • Joined

  • Last visited


Reputation Activity

  1. Thanks
    bilcan reacted to lennart in SQL Server Connection   
    You dont do threads in JS unless its exceptionally important.
    Server side you delegate work between processes, as in shell-execute and then passing work to it via node's message channel.
    So lets say you have a heavy duty server and for some reason need threading, you would write the thread code as a completely separate node application. In the server you would then start the process on demand and then pass the socket-handle (the request object) to the newly created process.
    This is the same as threading but easier to build up on since you are using the outer layer of shell/os.
    You can also use web-workers, which are threads, but still need to pass the request object (or whatever else you need) via messages, so most people just spawn a new process and pass in the request to handle it.
    So a low down would be:
    Server accepts request Server creates a process for handling the request Server pass the http/websocket request to the process process does whatever its designed to do Server is notified when the process is done or have failed So its more or less the same.
    I should underline that the whole point of ASYNC coding is to avoid threading as much as possible, but i realize that this mindset can be a bit alien for beginners in Smart Pascal - so you can evolve with it safely as you get more into it
    When it comes to DB then yes, absolutely - but im not sure there is a SQL server wrapper for it. But node supports just about every DB engine out there.
    Its one of the engines I will write a connection class for in our next 2 updates. SQLite is already there (actually we have 2, one via node and one we compiled to asm.js ourselves), mariadb (mysql), MSSQL, Firebird and oracle is on my list.
    Simply google if node.js can do it -- if it can, we can do it also. But when importing modules like this, someone have to write a wrapper.
    Its like delphi when using a dll file, you have to write defines for the methods etc. and load in the module before using it.
    So its fairly identical to how you work with external code in delphi.
    Visit NPM and have a look, there are quite a bit to pick from
    https://www.npmjs.com/search?q=SQLServer
     
  2. Like
    bilcan reacted to jarto in Application.Display.OnMouseMove   
    All the mouse and touch events are these days handled centrally by TW3EventManger. When the mouse moves anywhere in the document, it finds out which component it should belong to and generates the mousemove. If you use SetCapture, the Event Manager makes sure to only send the mousemove event to that component and nowhere else.
    The old versions of Smart Mobile Studio was not as strict, but that resulted in all kinds of other problems where the same event could fire multiple times etc.
    If you want to be able to listen to global mouse movements, you can still do it with addEventListener:
    uses ... W3C.DOM, ... procedure GlobalMouseMove(eventObj: JMouseEvent); begin WriteLn('Global Mousemove!'); end; Application.Document.Handle.addEventListener('mousemove', @GlobalMouseMove, True);  
  3. Like
    bilcan reacted to lennart in Migrating from 2.2 to 3.00 beta 2 and gotoform is not working   
    One thing I noticed is that you pass TRUE as the second parameter of RegisterForm -- This should only be done once.
    The TRUE defines that the registered form is the "main" form. So only one should have TRUE while all the others should be false.

    I also suspect that you should wait for the instance to finish before jumping (since you have modified the start code directlt):

    TW3Dispatch.WaitFor([form1,form2,form3], procedure ()
    begin
      Application.GotoForm(bla bla bla);
    end);
  4. Like
    bilcan reacted to jarto in Migrating from 2.2 to 3.00 beta 2 and gotoform is not working   
    You only attached Unit1, so there's no way for me to properly debug. Here's my best guess:
    This is what Unit1 looks like in a new project.
    unit Unit1; interface uses Pseudo.CreateForms, // auto-generated unit that creates forms during startup System.Types, SmartCL.System, SmartCL.Components, SmartCL.Forms, SmartCL.Application, Form1; type TApplication = class(TW3CustomApplication) end; implementation end. While previously you created all the forms by code, it's now done by TW3Application itself. You can control it here:

    If you can't see all your forms there, try creating a new project and add your old existing forms to it. When Auto is checked in that list, TW3Application creates the form during startup. If you continue to have issues, you can send a zip of your project to jt at smartmobilestudio.com and I'll be happy to help.
  5. Like
    bilcan reacted to lennart in Websocket Server Start Error   
    Its actually one of the coolest things about node.js!
    Node also has clang (c++ compiler) built-in, so if you use native packages it will actually re-compile node.js on the spot (!)
    But the majority of modules are raw JS and can be safely copied between systems.
    So you can write a server on windows, and just copy it to linux without any change
  6. Like
    bilcan reacted to gabr42 in How to change the properties of a control in a form from another form   
    Solution IV: Move {$I 'FrmMain:intf'} from the 'private' section to 'public' and all components will become visible to other forms.
  7. Like
    bilcan got a reaction from IElite in Several problems I encounter (probably bugs)   
    I have encountered some strange things, I am not sure these are bugs or not.
     
    1-) I use Application.GotoForm(FrmXXXX, fefromright) to navigate another forms and it works fine but if I use fenone parameter, SMS navigates me to a different form !!!
     
    2-) I have created my own tw3panel class (tw3mypanel) and has 4 tw3mybutton class which has own Tw3label. For example there are 2 tmyw3panel object on form1 and when I navigate back to form1 from form2 tw3labels on tw3mypanel disappear and buttons on tw3mypanel move to different locations from I set on create event !!!
     
    There are total 5 forms in my project (Include Main form).
     
    I use beta5
  8. Like
    bilcan got a reaction from jorn in Reading JSON data   
    What is the way of reading that kind of JSON data. I tried some ways which I found at the forum but I could not. 
     
    {This is Embarcadero example of Json}
    uses System.json;
     
    var
       Obj, ObjCons, ObjIpp: TJSONObject;
     
    begin
       Obj := TJSONObject.Create;
    try
      ObjIpp := TJSONObject.Create;
      ObjIpp.AddPair('ipp', TJSONNumber.Create(1122368));
     
      ObjCons := TJSONObject.Create;
      ObjCons.AddPair('decision', 'NA');
      ObjCons.AddPair('idPatient', ObjIpp);
      ObjCons.AddPair('idStructure', TJSONNumber.Create(300000000023887));
     
      Obj.AddPair('consentement', ObjCons);
      Memo1.Lines.Add(Obj.ToJSON);
    finally
      Obj.Free;
    end;
     
    end;
     
     
     
×