Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Next thinBasic: template dialog

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

    Next thinBasic: template dialog

    I'm few weeks I'm working on next thinBasic version: 1.9

    Among other many enhancements, one of the things I'm working on is a new template dialog, the dialog used to create a new thinBasic script (see image)
    So far I've almost completely re-coded it keeping as possible inspiration the new project dialog present in Microsoft Visual Studio

    There will be 4 areas in the dialog (see image):
    1. the repository tree structure used to store thinBasic script templates
    2. the list of templates present in a certain directory
    3. general info about templates like: author, date, version, ...
    4. a preview of the template


    I'm now working on area 3 and 4
    • In area 3 I'm trying to find a way to add that info inside template source code in order to get them during preview
    • In area 4 I'm working on adding Scintilla Text Editor as possible editor making experience with it in order to consider as possible future thinAir editor control.


    What I need?
    1. I need some advice on what you think about this new dialog layout
    2. I need some possible ideas to enhance this dialog
    3. I need idea on how to insert into template source code the template info: author, description short, description long, version, ...
      Maybe we can think to use XML as template structure. In this way it will be very easy to implement additional specifications
    4. I need some new templates from general one to complex one in order to present thinBasic programmers a quite rich set of templates to start from


    Any help will be very much appreciated.

    Ciao
    Eros
    Attached Images Attached Images
    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
    Hi, in vb6 i am using it sometimes for a hurry calc, i draw quickly textbox and a button then dblclick on the button to write textbox1=some operation, i prefer this than console or msgbox. so a template for textbox with a button for a hurry calc will be useful, because it is not easy to remember the complex syntax of the related windows api functions. such a template can make use of the attached example i have found on my hard disk made by one of the users, i have edited it slightly.
    i suggest also a simple template for a form with a canvas, with a one instruction to draw an ellipse,circle, line, pixel.
    Attached Files Attached Files

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Eros,

    few ideas from my side:

    Template file format
    I would move the template file format completely to XML, having the following structure:

    <ThinAIRTemplate version="1.0">
    // Version of template file format
    <Header>
    <DescriptionShort>Simple dialog</DescriptionShort> // Name to be displayed in the templates listing instead of filename of this template
    <DescriptionLong>This template generates code for single modal dialog with button and callback</DescriptionLong> // Description to be displayed
    <Author>Petr Schreiber</Author> // Person responsible for the template
    <Contact>Drop user "Petr Schreiber" a personal message on ThinBASIC forumor email me at...</Contact> // Contact information in case of trouble, link to source of latest version and such
    <Version>1.1<Version> // Version of this particular template
    </Header>
    <Files count="1"> // In future it could be multifile, for projects and such
    <File>
    <Name>Dialog_</Name> // Gets pre-filled in the name for new file in New thinBasic script dialog, can be left empty, to give user more freedom
    <Extension>tBasic</Extension> // This is quite important, it could be tBasic, tBasicC, tBasicI, tBasicU, Txt
    <Code>

    uses "UI"

    ... here goes thinBasic code of the file ...

    </Code>
    </File>
    </Files>
    </ThinAIRTemplate>
    I am sorry, but I didn't managed to display it indented

    "New" dialog
    I like the new layout, but have few "highlevelization" ideas to make the dialog more intuitive to users:

    Area 1
    I am not sure what is the experience of other users, but I personally do not nest the template directories. There could be simple list of directories under Templates/ instead of treeview.

    The list of templates could get more human readable format, like in Visual Studio. It could be realised with WebControl, having a look of "Listbox on steroids" realised via HTML one column table:

    • each template would have his name in bold
    • author, version and other minor metadata would be listed below
    • description in italics below
    • tooltip would tell the file name for anyone interested, but most users won't need to know it I guess

    So one item would look like:
    Simple modal dialog
    author: Petr Schreiber, version: 1.1

    This template creates code for single modal dialog, with button and callback predefined
    It is a bit of space waste, but from my experience I do not use more than 6 templates in total, so this number would still fit on the screen.
    It could erase the need for Area 3.


    The gray area above is look to far future, it would take a lot of time.


    Petr
    Last edited by Petr Schreiber; 22-01-2012 at 18:04.
    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

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    The XML template idea still valid, for the dialog layout I have new idea, more realisable.

    For a newcomer, I think it would be good to add some visual guides, because what he will see will be 3 window areas - where he should click first?
    On the other side the code listing will be not needed for the ol' coders knowing the template well. This leads to new layout in the attachement.

    It has visual guides for new comer and expandable area with code listing.


    Petr
    Attached Images Attached Images
    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

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

    as usual great ideas! Thanks.

    What is field "File name" used for?

    Eros
    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

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by zak View Post
    Hi, in vb6 i am using it sometimes for a hurry calc, i draw quickly textbox and a button then dblclick on the button to write textbox1=some operation, i prefer this than console or msgbox. so a template for textbox with a button for a hurry calc will be useful, because it is not easy to remember the complex syntax of the related windows api functions. such a template can make use of the attached example i have found on my hard disk made by one of the users, i have edited it slightly.
    i suggest also a simple template for a form with a canvas, with a one instruction to draw an ellipse,circle, line, pixel.
    Thanks zak.

    All templates I will receive will be valuated for the next version.
    I want to create a rich set of templates because I have the doubt that the many thinBasic script examples are not much visible to users while if we will create them as templates I think they will be much more visible.

    Ciao
    Eros
    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

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Thanks

    Currently, the file is always created as Untitled?.tBasic after pressing Use button.

    The file name field could be used to name the file since the beginning somehow, and the extension would be detected from the template XML File.Extension tag.

    The file name could be prefilled based on value in File.Name tag, but filling this tag in would be optional (could be left empty).

    What is this good for? For example in case of code units. As I use frequently the TBGL actor template, the new XML version of it would:
    • force tBasicU extension, as it is not standalone
    • the name would be suggested to start "actor_" to keep clear what the file is about


    Of course user can ignore this suggestion and name it as he wants.


    Petr

    Quote Originally Posted by ErosOlmi View Post
    Petr,

    as usual great ideas! Thanks.

    What is field "File name" used for?

    Eros
    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

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    I think is a great solution.

    I just need to change thinAir internal identification of new files never saved in order to ask user to save them
    At the moment "untitled" is used to identify them.
    Anyway quite simple change
    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

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

    I've created a test program to load a template XML file following your example.
    I've used Don Dickinson XML parser in order to avoid un-needed dependencies connections to big libraries or COM dependencies.

    Attached full source code and example template.

    I think I will go this way unless you have a better XML parser.

    Ciao
    Eros
    Attached Files Attached Files
    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

  10. #10
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Eros,

    I have developed very basic XML parser. It should work for our case. The usage is very simple (referencing tag directly with path), but on the other side it is not really the gold piece of code, as it could be slow for big XMLs and it is a bit hacky.

    Please try it on your PC, save it to the same directory as "_Template_.xml" to see it processed. The code relies on GRAB$ heavily, the rest is PB compatible I guess

    So... here comes the spaghetti code :
    Uses "Console", "File"
     
    $ProcessedFile = APP_SourcePath+"_Template_.XML"
     
    Function TBMain()
     
      If FILE_Exists($ProcessedFile) = FALSE Then
        MsgBox 0, "This example needs the file " + $ProcessedFile + " to work"
        Stop
      End If
       
      String sXMLBuffer = FILE_Load(APP_SourcePath+"_Template_.XML")
       
      PrintL "Version         : ", XML_GetTagParameter(sXMLBuffer, "ThinAIRTemplate", "version")
    
    ' -- The error catching is a bit silly, but should work   
    '  If Len(XML_LastError) Then 
    '    PrintL "Error occurred:"
    '    PrintL XML_LastError
    '    WaitKey
    '    Stop
    '  End If  
      
      PrintL "Type            : ", XML_GetTagParameter(sXMLBuffer, "ThinAIRTemplate", "type")
       
      PrintL
       
      PrintL "DescriptionShort: ", XML_GetString(sXMLBuffer, "ThinAIRTemplate.Header.DescriptionShort")
      PrintL "DescriptionLong : ", XML_GetString(sXMLBuffer, "ThinAIRTemplate.Header.DescriptionLong")
      PrintL "Author          : ", XML_GetString(sXMLBuffer, "ThinAIRTemplate.Header.Author")
      PrintL "Contact         : ", XML_GetString(sXMLBuffer, "ThinAIRTemplate.Header.Contact")
      PrintL "Version         : ", XML_GetString(sXMLBuffer, "ThinAIRTemplate.Header.Version")
       
      PrintL
       
      PrintL "Count           : ", XML_GetTagParameter(sXMLBuffer, "ThinAIRTemplate.Files", "count")
       
      PrintL
       
      PrintL "Name            : ", XML_GetString(sXMLBuffer, "ThinAIRTemplate.Files.Name")
      PrintL "Extension       : ", XML_GetString(sXMLBuffer, "ThinAIRTemplate.Files.Extension")
      PrintL "Code            : ", XML_GetString(sXMLBuffer, "ThinAIRTemplate.Files.Code")
           
      WaitKey
       
    End Function
    
    String XML_LastError
     
    ' -- Retrieves string from passed tag
    Function XML_GetString(sFile As String, sXPath As String) As String
     
      Return XML_GetString_NthOccurence(sFile, sXPath, 1)
       
    End Function 
     
    ' -- Retrieves parameter of given tag
    Function XML_GetTagParameter(sFile As String, sXPath As String, sParameter As String) As String
     
      ' -- By bypassing purge we retrieve the part after tag name
      String sBuffer = XML_GetString_NthOccurence(sFile, sXPath, 1, FALSE)
       
      ' -- This gives us string of the params, like: type="template" version="1.0"
      sBuffer = RTrim$(Extract$(sBuffer, ">"), ">")
       
      ' -- This chops each param to single array item
      String sParams()
      Long   nParams = Parse(sBuffer, sParams, " ")
       
      ' -- Now we seek for match, and if we do, we return the thing between quotes
      Long   i                                        
      For i = 1 To nParams
        If StartsWith(sParams(i)+"=", sParameter) Then
          Return Parse$(sParams(i), $DQ, 2)
        End If
      Next         
      
      XML_LastError = "The parameter " + $DQ + sParameter + $DQ + " could not be found for tag " + sXPath
       
    End Function
                                          
    ' -- Retrieves string from nth occurrence of passed tag                                    
    Function XML_GetString_NthOccurence(sFile As String, sXPath As String, occurence As Long, Optional purge As Long = TRUE) As String
     
      ' -- This makes sure we can process both string buffer or file from disk
      String sBuffer
      If InStr(sFile, ":") = 2 Then
        sBuffer = Acode$(UTF8ToWideChar$(FILE_Load(sFile)))
      Else
        sBuffer = sFile
      End If
     
      ' -- Some XMLs have odd tags with > on another line   
      sBuffer = Replace$(sBuffer, $LF+">", ">")
       
      ' -- Here we chop the XML tag path to pieces                                 
      String sPathElement()
      Long   i  
      Long   pathElements = Parse(sXPath, sPathElement, ".") 
       
      ' -- Here ve linearly chop the original string by tags till we get the result
      For i = 1 To pathElements                              
        If i = pathElements-1 Then                                                
               
          If InStr(sBuffer, "<"+sPathElement(i)+">") Then       
            sBuffer = Grab$(sBuffer, "<"+sPathElement(i)+">", "</"+sPathElement(i)+">", occurence) ' -- For tags without parameters    
          ElseIf InStr(sBuffer, "<"+sPathElement(i)+" ") Then 
            sBuffer = Grab$(sBuffer, "<"+sPathElement(i)+" ", "</"+sPathElement(i)+">", occurence) ' -- and for those with     
            If purge Then
              sBuffer = Remain$(sBuffer, ">")                           
            End If                                            
          Else 
            XML_LastError = "Tag " + $DQ + sPathElement(i) + $DQ + " was not found in the path " + sXPath          
          End If
        Else 
          If InStr(sBuffer, "<"+sPathElement(i)+">") Then
            sBuffer = Grab$(sBuffer, "<"+sPathElement(i)+">", "</"+sPathElement(i)+">")
          ElseIf InStr(sBuffer, "<"+sPathElement(i)+" ") Then 
            sBuffer = Grab$(sBuffer, "<"+sPathElement(i)+" ", "</"+sPathElement(i)+">")
            If purge Then
              sBuffer = Remain$(sBuffer, ">")
            End If 
          Else 
            XML_LastError = "Tag " + $DQ + sPathElement(i) + $DQ + " was not found in the path " + sXPath          
          End If
           
        End If 
      Next                
       
      Return sBuffer 
     
    End Function
    

    Petr
    Last edited by Petr Schreiber; 22-01-2012 at 22:10.
    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

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: 18-03-2010, 08:28
  2. Christmas template :D
    By ErosOlmi in forum Web and Forum
    Replies: 3
    Last Post: 04-12-2008, 23:46
  3. Confusion with DIALOG GET/SET CLIENT, DESKTOP GET SIZE and DIALOG SET LOC
    By Michael Hartlef in forum UI (User Interface)
    Replies: 3
    Last Post: 03-10-2008, 19:23

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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