Jump to content

All Activity

This stream auto-updates     

  1. Last week
  2. Thanks, but I don't really understand your choices in that code. I already have a workaround. I want the compiler fixed. -David
  3. warleyalex

    Assigning a Record Type Function Result to a Variant

    I'll try to mimic your example... type TTeamXfer = record TeamID: integer; external 'teamID'; Name: string; external 'name'; Desc: string; external 'desc'; Web: string; external 'web'; Bonus: integer; external 'bonus'; Shots: integer; external 'shots'; Splats: integer; external 'splats'; BonusCurrent: integer; external 'bonusCurrent'; ShotsCurrent: integer; external 'shotsCurrent'; SplatsCurrent: integer; external 'splatsCurrent'; end; type TTeamStruct = class public r: TTeamXfer; function Save(Value: TTeamXfer): TTeamXfer; end; function TTeamStruct.Save(Value: TTeamXfer): TTeamXfer; begin Result.TeamID := Value.TeamID; Result.Name := Value.Name; Result.Desc := Value.Desc; Result.Web := Value.Web; Result.Bonus := Value.Bonus; Result.Shots := Value.Shots; Result.Splats := Value.Splats; Result.BonusCurrent := Value.BonusCurrent; Result.ShotsCurrent := Value.ShotsCurrent; Result.SplatsCurrent := Value.SplatsCurrent; end; type TPXMessageCallback = procedure; procedure test; begin console.log('testing...'); end; procedure PXSend(v: integer; aData: Variant; aCallback: TPXMessageCallback); begin console.log( aData.obj.r ); end; procedure PXTeamCreate(aTeam: TTeamStruct; aCallback: TPXMessageCallback); begin var aData: Variant := new JObject; aData.obj := aTeam; aData.team := @aTeam.Save; PXSend(200, aData, @aCallback); end; var Team: TTeamStruct; Team := TTeamStruct.Create; Team.r.TeamID := 10; Team.r.Name := 'warleyalex'; PXTeamCreate(Team, @test); the compiler emittes this: function PXTeamCreate(aTeam, aCallback) { var aData; aData = {}; aData.obj = aTeam; aData.team = $Event1(aTeam,TTeamStruct.Save); PXSend(200,aData,aCallback); };
  4. This... procedure PXTeamCreate(aTeam: TTeamStruct; aCallback: TPXMessageCallback); begin var aData: Variant := new JObject; aData.team := aTeam.Save; PXSend(PXM_TEAMCREATE, aData, aCallback); end; Compiles to this: function PXTeamCreate(aTeam$4, aCallback$4) { var aData$5; aData$5 = {}; aData$5.team = {}; PXSend(122,aData$5,aCallback$4); }; All I can figure is that TTeamStruct.Save returns a *record* type, and somehow the poor result is being scoped out of existence before it even gets a chance. function TTeamStruct.Save: TTeamXfer; begin Result.TeamID := TeamID; Result.Name := Name; Result.Desc := Desc; Result.Web := Web; Result.Bonus := Bonus; Result.Shots := Shots; Result.Splats := Splats; Result.BonusCurrent := BonusCurrent; Result.ShotsCurrent := ShotsCurrent; Result.SplatsCurrent := SplatsCurrent; end; TTeamXfer = record TeamID: integer; external 'teamID'; Name: string; external 'name'; Desc: string; external 'desc'; Web: string; external 'web'; Bonus: integer; external 'bonus'; Shots: integer; external 'shots'; Splats: integer; external 'splats'; BonusCurrent: integer; external 'bonusCurrent'; ShotsCurrent: integer; external 'shotsCurrent'; SplatsCurrent: integer; external 'splatsCurrent'; end; Here's my current workaround: procedure PXTeamCreate(aTeam: TTeamStruct; aCallback: TPXMessageCallback); begin var aData: Variant := new JObject; var aTeamXfer := aTeam.Save; asm (@aData).team = @aTeamXfer; end; PXSend(PXM_TEAMCREATE, aData, aCallback); end;
  5. jarto

    FinalizeObject seems not to fire

    Seems like there are bugs in the Form freeing or unregistering code. I have to dig deeper to see what's going on. Thanks for reporting this.
  6. petermm

    FinalizeObject seems not to fire

    It seems that in my project FinalizeObject for my MainForm never fires. What can be the reason? Is there an another place to dispose central resources? In Delphi I would do that at FormClose, but SMS Forms didn’t have this event.
  7. Earlier
  8. Tim Koscielski

    Mixing Javascript and SMS

    Thank you for the quick overview. I had seen notes about the handle, but was hoping someone could summarize it here for me. This helps to clarify and gives me a start. I will always try to figure out how to keep things organized in SMS, but for the short term, ASM may be the crutch I need to get things going.
  9. Beezooka

    My SMS Project: Paintball Net Revival

    I played all the clones through the years infrequently and paintball-net will always be my favorite. Hvpb took it in a interesting route but the no class system is the best route imo. Excited to get back to splatting and maybe play some tournaments down the road! Thanks for bringing it back online and glad you had fun compiling it DavidRM! formerly KevDog. Currently Beezooka
  10. lynkfs

    Long Press/ Taphold

    Back to basics : https://www.kirupa.com/html5/press_and_hold.htm Works on desktop and Android, didn't check iOS You could implement this using the js as is, or convert it (eliminate the asm blocks), or use the available units in the rtl (smartCL.eventmanager, smartCL.events, system.events and system.time)
  11. COMFIED

    Long Press/ Taphold

    Hi Any ideas on how to detect long press or taphold on a panel or label?
  12. lynkfs

    internet explorer

    Something we all knew for a long time https://www.zdnet.com/article/microsoft-security-chief-ie-is-not-a-browser-so-stop-using-it-as-your-default/ a good thing microsoft has ditched Edge as well (hopefully Safari will solve their compatibility issues soon)
  13. lynkfs

    Mixing Javascript and SMS

    Example 2 : see below (first post in that thread) for some function call examples Example 1 : depends on what attribute. In your example you want to manipulate the visibility property of a button. These types of properties usually are mapped on a property or attribute of the underlying DOM-element. In this case you could use the style element visibility : W3Button1.handle.style.visibility := 'hidden' / 'visible'. 'handle' is the doorway between object pascal on the left hand side and the dom on the right hand side. No need for an asm block here. you can go the other way too : var x : variant := W3Button1.handle; asm console.log((@x).style.visibility); end; but you can't directly manipulate the properties of an object pascal object, as in asm @W3Button1.Visible = true Of course you can do some conditional js coding and execute object pascal code (like W3Button1.Visible := true;) depending on the return outcomes. Out of habit I suppose I try to minimise the use of asm blocks (although there is nothing wrong with using them). The only times I have to use them if a js object doesn't have a create constructor but instead can only be instantiated by the 'new' keyword var formData : variant; asm @formData = new FormData(); end; //from here all methods and attributes of the js object are accessible outside an asm block formData.append("userfile", EditBox1.handle.files[0]); or wrapping a js function. (you can set @result in an asm block)
  14. Tim Koscielski

    Mixing Javascript and SMS

    I have been using ASM blocks in my project and find that I want to mix javascript and SMS. Below are two use cases. In an ASM block I would like to set a SMS attribute on a SMS object like a button doing something like TW3Button.Visible := True In an ASM blick I would like to call a SMS procedure or function to complete some common actions Below is my psuedo code which I am hoping someone can correct and give some guidance on. I'm just looking for enough to be dangerous..... EXAMPLE 1: Set attribute on button. asm // Unsure how to do this here to call back to a button in SMS @W3Button1.Visible = True end; Example 2: Call SMS function from a javascript block procedure TForm.DoSomething; begin ShowMessage('Doing something'); end; procedure TForm.OnButtonClick(Sender: TObject); begin asm @DoSomething; end; end; For me this is the simplest I can make it which will help better understand the javascript-SMS links. I am hopeful that you understand, for these examples, it is not exactly how I'm using them, but for understanding I thouhgt this was the easiest examples I could do. Thanks. tim
  15. lynkfs

    Providing Credentials to a Frame

    you can access the iframes dom through its contentWindow or contentDocument property something like yourIFrameHTMLElement.handle.contentDocument.body (or ...handle.contentWindow.document.body) (with scripting you might run into same-origin policy concerns)
  16. Christian

    Providing Credentials to a Frame

    Hi, is there a way to set username and password to a W3IFrameHTMLElement, or how should i solve the following issue: I want to open a website running in a W3IFrameHTMLElement and this page requests credentials which i want to enter automatically. Christian
  17. jarto

    Grid control

    I'll send a version to you.
  18. sibar

    Grid control

    OK. Is it possible to have the source of the current version for testing on a project I'm doing now? It's an application that will run on Android tablets and PC's. Thanks
  19. @sibar Thank you. I can reproduce the problem now. Edit: Fixed. Will be in the next update.
  20. jarto

    Grid control

    I have a pretty nice Grid component, which I have not been able to release yet as it has performance problems on iOS. I've been trying to find the reason but haven't found a solution yet. This is extra weird as it's extremely fast on Android and extremely slow on iOS.
  21. Tim Koscielski

    Uploading a file that has been selected using INPUT box type=itFile

    Ok, this first follow up is what I did to get it working based on some of the links for handling forms in javascript. Fortunately because I could mix and match SMS Pascal and Javascript, I get the best of both worlds. On my Smart Form, I have a TW3Button and a TW3EditBox with a type of ltFile. Then with the following javascript, I can get the form posted correctly to a backend which is able to capture the file and other variables of the form. Note that the other elements are created dynamically based on an example I was using. The ShowMessage and Alert items were just feedback mechanisms for me to see this part working. Both my DMVC server and a PHP script were able to process this. I am sure that there is a more friendly SMS way of writing this, but for now it got my form working and I was able to continue to plow forward with this upload piece being reasonably well contained. My key take way was getting the file upload field and the code below did the trick. This may not be the best way, but at least it was a starting point. myFile = document.getElementById('id', 'fupload1'); The InitializeObject was important to label the TW3EditBox element correctly. Below that is the code that I stuck in the OnClick event for the button. I saw many other ways to deal with this, but I just wanted to keep it straight forward for the UI. procedure TForm_ImportFile.InitializeObject; begin inherited; {$I 'Form_ImportFile:impl'} W3ButtonBack.InnerHTML := '<i class="fa fa-arrow-left fa-2x"></i>'; // this is a good place to initialize components W3EditBox1.handle.setAttribute('name','fupload'); W3EditBox1.handle.setAttribute('id', 'fupload1'); // Initialize EditBox id to find it with getElementById below W3EditBox1.InputType := itFile; end; // BUTTON CLICK EVENT CODE ShowMessage('Starting'); asm var formData = new FormData(); alert('Trying to get file box'); myFile = document.getElementById("fupload1").files[0]; alert('Got file: ' + myFile.name); formData.append("username", "Groucho"); formData.append("accountnum", 123456); // number 123456 is immediately converted to a string "123456" // HTML file input, chosen by user //formData.append("fupload", fileInputElement.files[0]); //var myFile = new Blob([content], {type: "text/plain"}); formData.append("userfile", myFile, myFile.name); // JavaScript file-like object var content = '<a id="a"><b id="b">hey!</b></a>'; // the body of the new file... var blob = new Blob([content], { type: "text/xml"}); formData.append("webmasterfile", blob); var request = new XMLHttpRequest(); request.open("POST", "http://127.0.0.1:2001/file"); request.send(formData); end; ShowMessage('Done');
  22. Daniel Eiszele

    RTL Class Browser stays empty

    I added the commandline arguements into a batch file which works for me!
  23. petermm

    RTL Class Browser stays empty

    Finally it works. Must have to do something with the ShortCut. Starting SmartUpdate via commandline is OK.
  24. sibar

    Grid control

    Hi, Will there be a proper (column resizing, sorting etc.) grid control any time soon? Regards Sindre
  25. Attached is a simple project with a Cw.Client.Core unit i a subdirectory Client. I've made an error in the Cw.Client.Core and when I try to compile i reports that the Cw.Client.Core not found. Also Ctrl-Click is not working and File/Open... will open the untiu but not shift to the tab sheet. Sindre SearchPathTest.zip
  26. jarto

    License (Gumroad)

    Can you please send Jörn (ja at smartmobilestudio.com) an e-mail about this? Please tell him which e-mail address you have registered under Gumroad, so he can find your subscription.
  27. Jake

    License (Gumroad)

    Same issue here. I was "auto-renewed" by Gumroad but all they will send me is a receipt. No license. My old license doesn't work with the new version, so how can I access it?
  1. Load more activity
×