Jump to content

lynkfs

Moderators
  • Content Count

    743
  • Joined

  • Last visited

  • Days Won

    146

Everything posted by lynkfs

  1. lynkfs

    memo lines ?

    Something like Memo1.Text := #' line-01 line-02 line-03 '; MyArray := StrSplit(Memo1.Text, #10); will work
  2. lynkfs

    no-code

    Setting up a blog in WordPress is a no-brainer of course. Setting one up in Smart is pretty easy too. This one repurposes a treeview as a vertical collapsible menu and a series of Google docs in an iFrame. Using Google docs is a bit of a short-cut but it does provide the basics in a single package : perfect formatting capabilities, editing online and authorisation for editing source, or able to comment, or viewing for anyone. As for the subject (a no-code/lo-code framework) this obviously is unfinished ('intro' and the beginning of 'framework' entries only). I may do some more work o
  3. ok, they changed the entry point from a function call to a var, and renamed it to 'math' //function mathjs: Variant; external 'mathjs'; var mathjs external 'math': variant; point script.src to 'https://cdnjs.cloudflare.com/ajax/libs/mathjs/5.1.0/math.min.js' and use as before (instead of referencing the cdn or a local url you can of course store whatever version of the library you like on one of your own servers and point the script.src to that)
  4. this code works var document external 'document': variant; var console external 'console': variant; function mathjs: Variant; external 'mathjs'; implementation { TForm1 } procedure TForm1.W3Button1Click(Sender: TObject); begin var Script : THandle := document.createElement('script'); Script.src := 'lib/math.js'; //'https://cdnjs.cloudflare.com/ajax/libs/mathjs/5.1.0/math.min.js'; document.head.appendChild(Script); Script.onload := procedure begin console.log('loaded'); //... do your thing console.log('1.2 / (2.3 + 0.7) [Execute] = ' + mathjs.eval('1.2 / (2.3 +
  5. If you don't want to distribute the js library yourself, there is a cdn version as well there are different ways of doing it but I usually do something like this var Script := document.createElement('script'); Script.src := https://cdnjs.cloudflare.com/ajax/libs/mathjs/5.1.0/math.min.js'; document.head.appendChild(Script); Script.onload := procedure begin console.log('loaded'); ... do your thing end; so that processing occurs only after loading. (Works with local libraries instead of cdn as well of course, alternative to the $R directive)
  6. featured demos / console / math expression parser
  7. This statement doesn't compile : Syntax Error: Name "length" is reserved [line: 101, column: 80, file: Form1] class width=10; length=12 due to the 'length' identifier. '&length' doesn't work either Any workaround for this ? edited : json.parse('{"width":10,"length":12}') works around this, just not using anonymous classes
  8. lynkfs

    framework

    you'll have to ask @EWB for source code for his project the shoestring/native framework source is accessable here and docum here
  9. the function below calculates the relative brightness of a colour (specified in hex : #008080 = 'teal') //funtion to find the relative brightness of a colour (hex-code) function Brightness(colour: string): integer; begin asm function coloro(color) { if(color.length==7){color=color.substring(1);} var R = parseInt(color.substring(0,2),16); var G = parseInt(color.substring(2,4),16); var B = parseInt(color.substring(4,6),16); return Math.sqrt(R * R * .241 + G * G * .691 + B * B * .068); } @result = coloro(colour);
  10. thought so (just a thought : besides php (an easy way) there are also other solutions like amazon s3, cloudinary, dropbox, ... which could be embedded in smart apps)
  11. afaik you can access images from anywhere on the users pc, but only store these by autodownload in the default download directory (win10 : c:/users/.../Downloads) procedure TForm1.InitializeForm; begin inherited; edPhoto1.InputType := itFile; edPhoto1.Handle.ReadyExecute( procedure () begin if w3_getIsMobile then w3_setAttrib(edPhoto1.Handle, 'accept', 'image/png,image/jpg') else w3_setAttrib(edPhoto1.Handle, 'accept', 'image/*'); w3_setAttrib(edPhoto1.Handle, 'capture', ''); edPhoto1.OnChanged := procedure(sender:TObject) begin
  12. afaics needs a bit of work from the dev team in the meantime this is a workable workaround LBitmap.Canvas.Context.DC.font := '68px serif'; // or 'italic bold 88px "Tangerine", serif'; LBitmap.Canvas.TextOut(10,70, 'It displays text but in small font', clblue); (or alternatively add a TCanvas.SetSize procedure or helper)
  13. Not as a Const I think as a Var its not a problem procedure CommandChat(aCommand, aArgs: string); var CommandTable: array of variant = [ class Command = ';'; CommandProc = @CommandChat; end, class Command = 'chat'; CommandProc = @CommandChat; end ]; implementation checking : writeln(CommandTable[1].Command); // "chat" asm console.log( CommandTable[0].CommandProc.toString() ) end; //"function CommandChat(aCommand, aArgs) { }" //print of compiled CommandChat CommandTable[0].CommandProc('a','b'); //executes CommandChat
  14. just downloading an image which is displayed in the browser : (code based on link in prev post) { TForm1 } procedure TForm1.W3Button1Click(Sender: TObject); var LARef : TControlHandle; begin asm (@LARef) = document.createElement('a'); document.body.appendChild(@LARef); end; // Setup values LARef.style := "display: none"; // Wait for the obj to appear in the DOM LARef.readyExecute( procedure () begin LARef.href := Image1.ToDataUrl; LARef.download := 'alogo2.png'; // Invoke click on link LARef.click(); end); end; procedure TForm1.InitializeObje
  15. lynkfs

    Font Demo

    in project options add a webfont (see https://jonlennartaasenden.wordpress.com/2017/10/04/webfonts-in-smart-mobile-studio/) W3Memo1.Font.Name := 'Tangerine'; W3Memo1.Font.Style := [fsItalic]; W3Memo1.Font.Size := 48; W3Memo1.Font.Weight := 'bold'; In this case I added Font 'Tangerine' (see also https://developers.google.com/fonts/docs/getting_started)
  16. as an alternative to all of the above, this works too w3EditBox1.Text := ''; w3editbox1.maxlength := 5; w3Editbox1.handle.onkeydown := procedure (e: variant) begin if (e.keyCode < 48) or (e.keyCode > 57) then //numbers if e.keyCode <> 8 then e.preventDefault(); //allow backspace if e.shiftKey then e.preventDefault(); //disallow shift end; last post
  17. substituting w3Editbox1.onkeypress := procedure (sender:tobject; const character:char) begin W3EditBox1.MaxLength := s.length; if character in '01234567890' then begin if s.length < 4 then s += character; end; end; works ok on my machine however fast I type how about yours? edited : if you want to kill repeating keystrokes, like continuous pressing of backspace, then add w3Editbox1.handle.onkeydown := procedure (e: variant) begin //writeln(e.keyCode); if e.keyCode = 8 then e.preventDefault(); end;
  18. some minor changes to previous post
  19. you could do something like this to 'disallow' a key press : (an editbox without being able to type an 'a') var S: string; W3EditBox1.text := ''; //W3EditBox1.MaxLength := 4; w3Editbox1.onkeypress := procedure (sender:tobject; const character:char) begin W3EditBox1.MaxLength := s.length; if character <> 'a' then begin if s.length < 4 then s += character; end; end; w3Editbox1.onkeyup := procedure (sender:tobject; const keycode:integer) begin if keycode = 8 then s := leftstr(S, S.length-1); w3editbox1.text := s; end;
  20. you could emulate a number editbox doing this : W3EditBox1.text := ''; W3EditBox1.MaxLength := 4; w3Editbox1.onkeyup := procedure (sender:tobject; const keycode:integer) begin writeln(keycode); if (keycode < 48) or (keycode > 57) then //numbers only if keycode <> 8 then //backspace/delete w3editbox1.text := LeftStr(w3editbox1.text, w3editbox1.text.length-1); end; just a normal editbox, don't set it to itNumber (which by the way still allows the character 'e', used in scientific number notations). it will briefl
  21. lynkfs

    design surface

    @lennarthas been working on a design surface component (TW3DesignSurface) see https://jonlennartaasenden.wordpress.com/2016/11/07/ Could the code for this component be shared ?
  22. lynkfs

    Grid - spreadsheet

    I've used the DHTMLXGRID library in the past. See Combining this js library with 2 standard php scripts enabled me to provide (web)pages linked to a MySQL db on a cloud server with inline gridcell editing and immediate updates of the db without additional coding. Works well but looks a bit dated now. In the latest SMS release there is the SmartCL.DBGrid component, looks like it has editor capabilities. @jarto to the rescue for a demo of this unit ?
  23. lynkfs

    framework

    as an aside : A DBGrid component has been added to the native/shoestring framework. This component features sizeable columns where columns are also autosized on content. Works on any DB / server as long as it returns a json-structure in the format of a 'rows' object as an array of arbitrary field/value pairs {"rows":[{ "ID":"90020", "Category":"Triggerfishy", "Common name":"Clown Triggerfish", "Species name":"Ballistoides conspicillum", "Note":"Also known as the big spotted triggerfish..."}, }]} usage example : DBGrid1.Query := #' Select
×
×
  • Create New...