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

Thread: CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,086
    Blog Entries
    5
    Rep Power
    725

    CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

    Hi guys,

    I managed to generate CodeTips for 99% of ThinBASIC commands .
    I did it completely by hand ... ok, just joking.

    I first decompiled all the help files using HTML Help Workshop, and then ran the following script on them (warning, dirty code):
    [code=thinbasic]
    ' -- HTML help 2 code tips
    Uses "file", "console"

    Dim Files() As String
    Dim nFiles As Long

    ' -- Where HTML files are
    Dim SearchPath As String = APP_SourcePath

    ' -- Filter them
    nFiles = DIR_ListArray(Files, SearchPath, "*.htm", %FILE_NORMAL Or %FILE_ADDPATH)

    Dim i As Long
    Dim sBuffer, sSyntax, sDescription As String
    Dim sCodeTips As String
    Dim sLineFinal As String

    PrintL nFiles, "found"
    Dim found As Long
    Dim fSpace As Long

    For i = 1 To nFiles
    ' -- Load file
    sBuffer = FILE_Load(Files(i))
    If InStr(sBuffer, ">Syntax") = 0 Then Iterate For

    ' -- Extract and postprocess description
    sDescription = GRAB$(sBuffer, ">Description", "Syntax<")

    sDescription = Replace$(sDescription, "&nbsp;", " ")
    sDescription = Replace$(sDescription, $CRLF, "|")
    sDescription = BirdBracketPurge(sDescription)
    sDescription = Trim$(sDescription, Any $CRLF+$SPC)
    sDescription = TrimFull$(sDescription)

    While InStr(sDescription, "||")
    sDescription = Replace$(sDescription, "||", "|")
    Wend
    sDescription = Trim$(sDescription, Any " |")

    ' -- Extract and postprocess syntax
    If InStr(sBuffer, "Returns<") Then
    sSyntax = GRAB$(sBuffer, ">Syntax", "Returns<")
    Else
    sSyntax = GRAB$(sBuffer, ">Syntax", "Return value<")
    End If

    sSyntax = Replace$(sSyntax, "&nbsp;", " ")

    If InStr(sSyntax, "= ") Then sSyntax = Remain$(sSyntax, "= ")
    If InStr(sSyntax, " =") Then sSyntax = Remain$(sSyntax, " =")
    If InStr(sSyntax, "Type") Then Iterate For
    If InStr(sSyntax, "expression1") Then Iterate For

    sSyntax = Replace$(sSyntax, $CRLF, "|")
    sSyntax = BirdBracketPurge(sSyntax)

    sSyntax = Trim$(sSyntax, Any $CRLF+$SPC)
    sSyntax = TrimFull$(sSyntax)

    While InStr(sSyntax, "||")
    sSyntax = Replace$(sSyntax, "||", "|")
    Wend
    sSyntax = Trim$(sSyntax, Any " |")
    ' -- Silly bad syntax detection
    If InStr(sSyntax, "2005") > 0 Then Iterate For
    If InStr(sSyntax, "2006") > 0 Then Iterate For
    If InStr(sSyntax, "2007") > 0 Then Iterate For
    If InStr(sSyntax, "2008") > 0 Then Iterate For
    If InStr(sSyntax, "2009") > 0 Then Iterate For

    ' -- Build final description
    sLineFinal = sSyntax+"|"+sDescription+$CRLF

    ' -- Silly test if it is really what we want
    If sLineFinal = "||.|"+$CRLF Then Iterate For
    If InStr(sLineFinal, "( ...|... )") Then Iterate For
    If sLineFinal = "FTP_(, )||.|"+$CRLF Then Iterate For
    If LEFT$(sLineFinal, 1) = "|" Then Iterate For
    If LEFT$(sLineFinal, 1) = "'" Then Iterate For
    If LEFT$(sLineFinal, 1) = "%" Then Iterate For
    If LEFT$(sLineFinal, 3) = "|||" Then Iterate For
    If LEFT$(sLineFinal, 2) = "1|" Then Iterate For
    If LEFT$(sLineFinal, 4) = "see(" Then Iterate For
    If LEFT$(sLineFinal, 4) = "see " Then Iterate For
    If LEFT$(sLineFinal, 7) = "number^" Then Iterate For
    If LEFT$(sLineFinal, 6) = "for( C" Then Iterate For
    If LEFT$(sLineFinal, 6) = "b Site" Then Iterate For
    If LEFT$(sLineFinal, 5) = "TYPE(" Then Iterate For
    If LEFT$(sLineFinal, 6) = "There(" Then Iterate For
    If LEFT$(sLineFinal, 7) = "String(" Then Iterate For
    If LEFT$(sLineFinal, 7) = "nStart(" Then Iterate For
    If LEFT$(sLineFinal, 7) = "nStart " Then Iterate For
    If LEFT$(sLineFinal,16) = "StringExpression" Then Iterate For
    If LEFT$(sLineFinal, 9) = "There are" Then Iterate For

    sCodeTips += sLineFinal
    PrintL "--", Files(i)
    Incr found

    Next

    Dim LinesOfClips() As String
    Parse(sCodeTips, LinesOfClips, $CRLF)

    Array Sort LinesOfClips

    sCodeTips = Join$(LinesOfClips, $CRLF)
    PrintL "END OF PROCESSING"
    ' -- Put it to clipboard
    ClipBoard_SetText(sCodeTips)

    WaitKey

    ' -- Removes anything bird brackets ( purging text from HTML tags )
    Function BirdBracketPurge(sString As String) As String
    Dim i As Long
    Dim char, result As String
    Dim inBracket As Long

    For i = 1 To Len(sString)
    char = Mid$(sString, i, 1)
    If char = "<" Then Incr inBracket

    If inBracket = 0 Then result += char

    If char = ">" Then Decr inBracket
    Next
    Return result
    End Function
    [/code]

    To use it, just copy the contents of attached file to thinBasic_Codetips_Usr.ini


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

  2. #2
    thinBasic MVPs
    Join Date
    Sep 2006
    Posts
    3,289
    Blog Entries
    2
    Rep Power
    343

    Re: CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

    Thanks Petr

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10

    Re: CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

    oh Petr, this is of great help.
    Thank you so much. I will use this for next release so it will be in official Codetip file and not user file.

    I just need a favour: do not put double || between data. I ask that because I'm writing a new CodeTip dedicated control that will adjust itself height/width based on data it will find. Using double || will in some way break the rule. See image.

    Ciao and thanks again.
    Eros
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	NewCodeTipWindow.jpg 
Views:	163 
Size:	22.1 KB 
ID:	6181  
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,086
    Blog Entries
    5
    Rep Power
    725

    Re: CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

    Hi,

    you are right. I changed the script and the attachement too.

    One thing - the "|" character is sometimes used in syntax, like here:
    DO [{WHILE | UNTIL} NumericExpression]
    which makes the line end on odd places. This occurs in just a few cases, but maybe different caracter could be used.

    The new look is very nice!
    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
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,086
    Blog Entries
    5
    Rep Power
    725

    Re: CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

    Eros,

    it seems some postprocessing takes place.
    The CodeTip for ASC is:
    ASC(StringExpression [, position])|Return the ASCII code (0 to 255) of the specified character in a string.
    ... but displayed is something damaged, see attached screenshot.


    Petr
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	CodeTip_Problem.png 
Views:	147 
Size:	968 Bytes 
ID:	6183  
    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

  6. #6
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,086
    Blog Entries
    5
    Rep Power
    725

    Re: CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

    One more idea - separating syntax with description using "|" is simple, but could be little bit clumsy. Maybe some tag structure could be used, allowing multiline example (maybe you already have it solved). So I propose something like:
    <syntax>COMMAND(something)</syntax><descr>Description:<BR>It is easy</descr>
    <BR> would be replacement for "|". I know the files will grow up, but they will be more maintainable I think.

    What do you think?
    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

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10

    Re: CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

    Because you have ASC both in
    thinBasic_Codetips.ini
    thinBasic_Codetips_Usr.ini
    files. Just put your great work into thinBasic_Codetips.ini and leave thinBasic_Codetips_Usr.ini empty.

    I will use your great file for thinBasic_Codetips.ini in future so use it.

    Regarding char | to be used as separator, we can think about something else.
    Anything to suggest?

    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10

    Re: CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

    We were posting at the same time.

    Your tag help seems great and much less confusing.
    Can you please produce a file with your idea and I will try to us it.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,086
    Blog Entries
    5
    Rep Power
    725

    Re: CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

    Of course,

    file attached
    Attached Files Attached Files
    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

  10. #10
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10

    Re: CodeTips - for complete thinBASIC (including TBAI, TBGL, TBEM)

    Great Petr.
    I will check right now how to change thinAir in order to use this syntax.

    As a general rule, I would say that
    [code=thinbasic]<syntax>...</syntax><description>...</description>[/code]
    is the minimum to be found in file.
    Than I will check if additional tags are present and us them like (for example)
    [code=thinbasic]<syntax>...</syntax><description>...</description><example>...</example>[/code]

    Thanks again
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Page 1 of 2 12 LastLast

Similar Threads

  1. TBGL, TBEM
    By Petr Schreiber in forum Fixed or cleared errors in help material
    Replies: 2
    Last Post: 12-04-2008, 18:44

Posting Permissions

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