Thanks Petr
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, " ", " ")
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, " ", " ")
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
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
Thanks Petr
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
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
Hi,
you are right. I changed the script and the attachement too.
One thing - the "|" character is sometimes used in syntax, like here:
which makes the line end on odd places. This occurs in just a few cases, but maybe different caracter could be used.DO [{WHILE | UNTIL} NumericExpression]
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
Eros,
it seems some postprocessing takes place.
The CodeTip for ASC is:
... but displayed is something damaged, see attached screenshot.ASC(StringExpression [, position])|Return the ASCII code (0 to 255) of the specified character in a string.
Petr
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
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:
<BR> would be replacement for "|". I know the files will grow up, but they will be more maintainable I think.<syntax>COMMAND(something)</syntax><descr>Description:<BR>It is easy</descr>
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
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/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
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/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Of course,
file attached
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
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/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Bookmarks