View Poll Results: Do you like new concise syntax?

Voters
8. You may not vote on this poll
  • Yes

    6 75.00%
  • No

    1 12.50%
  • Do not know

    1 12.50%
Results 1 to 4 of 4

Thread: thinBasic 1.10.5 UI is becoming more easier and more clean (I hope)

  1. #1
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10

    thinBasic 1.10.5 UI is becoming more easier and more clean (I hope)

    Another new set of features you will get in next thinBasic 1.10.5 is the ability to specify shorter sentences for creating windows and controls and later, when it's the right time, specify the missing information using a simple <object>.<property> notation. This is possible using the new "Name" option that will allow to give a name to Windows and Controls and use that name to reference to specific windows or controls without the need to know windows handle and control IDs

    Of course remaining 100% compatible with previous notation.
    No need to change anything in your scripts if you do not want.

    A script example and a bundled exe can show you how.
    uses "ui"
    
    
    begin ControlID
      %lbl
      %txt
      %btnClose
      %stBar
      %listbox
      %progressbar
    end ControlID
    
    
    '---Create Window and controls using new shot notations
    '---All the rest of properties can be defined later during window events
    DIALOG New Pixels, Name frmMain, 0, "Window to demonstrate Named Controls"
      control add label     , name lbl      , frmMain.Handle, %lbl      , "This is a label"
      control add textbox   , name txt      , frmMain.Handle, %txt      , "This is a textbox"
      control add Button    , name btnClose , frmMain.Handle, %btnClose , "Close"
      Control Add Statusbar , name stBar    , frmMain.Handle, %stBar    , ""
    
    
    DIALOG SHOW MODAL frmMain.Handle
    
    
    
    
    '--------------------------------------------
    callBack function frmMain_OnCallback() As Long
    '--------------------------------------------
    
    
    end Function
    
    
    '--------------------------------------------
    callBack function frmMain_OnInit() As Long
    '--------------------------------------------
    
    
      long dW, dH
    
    
      '---Define window style
      frmMain.Style = %WS_DLGFRAME | %DS_CENTER | %WS_CAPTION | %WS_SYSMENU | %WS_OVERLAPPEDWINDOW
    
    
      '---Get desktop size
      DESKTOP GET SIZE TO dW, dH
      
      '---Set Window client size
      frmMain.cw = 800
      frmMain.ch = 600
    
    
      '---Set window minimum size
      frmMain.MinSize = 640, 480
      
      '---Center window
      frmMain.x  = (dW - frmMain.cw)/ 2
      frmMain.y  = (dH - frmMain.ch)/ 2
    
    
    end Function
    
    
    '--------------------------------------------
    callBack function frmMain_OnSize() As Long
    '--------------------------------------------
    
    
      '---Set controls locations and size
      lbl.x = 5:      lbl.y =  5:  lbl.w = 200:  lbl.h = 20
      txt.x = 5:      txt.y = 25:  txt.w = 200:  txt.h = 25
    
    
      btnClose.x = frmMain.cw - 110
      btnClose.y = frmMain.ch - 50 - stBar.h
      btnClose.w = 100
      btnClose.h = 40
    
    
    end function
    
    
    '--------------------------------------------
    callback function btnClose_OnClick()
    '--------------------------------------------
    
    
      frmMain.End
      
    end Function
    
    Attached Files Attached Files
    Last edited by ErosOlmi; 30-11-2017 at 00:49.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736
    I consider this to be the jump to the right direction - it makes the creation of dialogs and controls simple.
    With less code more done while it does not compromise the clarity and meaning.

    My wish is to get rid of those evil DIALOG and CONTROL commands.

    If we look at:
    control add label , name lbl , frmMain.Handle, %lbl , "This is a label"
    
    ...BASICally, the %lbl is redunant and the same could be done in a way similar to:
    add label "lbl", "This is a label" to frmMain
    
    (handle known to frmMain, no need for ctrlId, which could be autogenerated internally)

    ...or maybe more standard:
    lbl = new Label("This is a label")
    frmMain.addControl(lbl)
    

    Petr
    Last edited by Petr Schreiber; 30-11-2017 at 21:32.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    Member
    Join Date
    Aug 2015
    Location
    Keralam, India
    Posts
    121
    Rep Power
    22
    Hi Eros,
    Great changes !. Please consider function syntax like this;
    FunctionName(Param1, Param2....,ParamN)
    Here is an example of window creation;
    Window_Handle = CreateWindow(Location=(x,y), Size=(x,y), Title="String", WindowStyles=(List_Of_Styles))
    
    And here is one for control creation;

    Control_Handle = CreateButton(Parent=Window_Handle, Location=(x,y), Size=(x,y), Text="String", ButtonStyles=(List_Of_Styles))
    Control_Handle = CreateLabel(Parent = Window_Handle, Location=(x,y), Size=(x,y), Text="String", LabelStyles=(List_Of_Styles))
    Control_Handle = CreateTextBox(Parent = Window_Handle, Location=(x,y), Size=(x,y), Text="String", TextBoxlStyles=(List_Of_Styles))
    
    And bind events like this;
    BindEvent(Control_Handle, EventName = TB_EVENT_MOUSE_HOVER, CallBackFunction = "NameOfFunction")
    
    looks like python style. But its an easy one.
    Last edited by kcvinu; 01-12-2017 at 17:10.

  4. #4
    i agree with Petr:
    add label "lbl", "This is a label" to frmMain
    we will never forget this syntax, or may be :
    add label "lbl", w,h, x,y, "This is a label", to frmMain

    so it is a kind of a wrapper to the complex syntax, which will stay available (as i understand from Eros reply somewhere) .

Similar Threads

  1. Cool and Clean, safe to use?
    By kryton9 in forum Suggestions/Ideas discussions
    Replies: 3
    Last Post: 05-05-2017, 14:01
  2. Computer hope
    By ErosOlmi in forum Shout Box Area
    Replies: 1
    Last Post: 02-07-2010, 14:25
  3. Pirates of the Mediterranean (fixed - I hope)
    By danbaron in forum Shout Box Area
    Replies: 11
    Last Post: 25-06-2010, 01:15
  4. clean(ish) Energy
    By Michael Clease in forum Science
    Replies: 12
    Last Post: 20-10-2008, 19:37

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •