Lots of folks are always asking about how to download the wiki for off-line use, and over the years we've always used tools such as HTTrack to download and copy the website to save a local copy. The problem with this is that the archive we get is often huge as BLEEP! The last wiki I downloaded and shared was an archive of over 1.1GB in size!
So, I wanted a much simpler alternative, and thus I came up with this little solution:
Code: (Select All)
$Console:Only
DefLng A-Z
Const HomePage$ = "https://qb64phoenix.com"
ReDim Shared PageNames(10000) As String
NumberOfPageLists = DownloadPageLists 'As of mid 2022, there are only 2 pages listing all the page names.
'NumberOfPageLists = 2 'hard coded for counting without having to download pages repeatedly while testing code
PageCount = CountPages(NumberOfPageLists)
Print PageCount
t# = Timer: t$ = Time$
For i = 1 To PageCount
Cls
Print "Downloading... (Started at: "; t$; ")"
FileName$ = Mid$(PageNames(i), _InStrRev(PageNames(i), "/") + 1) + ".HTML"
FileName$ = CleanHTML(FileName$)
Print i; "of"; PageCount, FileName$
Download PageNames(i), FileName$
_Display
Next
_AutoDisplay
Print "FINISHED!! (Finsihed at: "; Time$; ")"
Print
Print Using "##,###.## seconds to download everything on this PC."; Timer - t#
Function CountPages (NumberOfPageLists)
FileLeft$ = "Page List("
FileRight$ = ").txt"
For i = 1 To NumberOfPageLists
file$ = FileLeft$ + _Trim$(Str$(i)) + FileRight$
Open file$ For Binary As #1
l = LOF(1): t$ = Space$(l)
Get #1, 1, t$
Close #1
start = InStr(t$, "<ul") 'skip down to the part of the page with the page listins
finish = InStr(start, t$, "</ul") 'and we can quit parsing when we get down to this point
p = start 'current position in file we're parsing
Do Until p > finish
p = InStr(p, t$, "<li><a href=") + 13
If p = 13 Then Exit Do 'we've parsed all the lists from the page. No need to keep going
p2 = InStr(p, t$, Chr$(34))
count = count + 1
PageNames(count) = Mid$(t$, p, p2 - p)
Loop
Next
CountPages = count
ReDim _Preserve PageNames(count) As String
End Function
Function DownloadPageLists
FileLeft$ = "Page List("
FileRight$ = ").txt"
FileCount = 1
CurrentFile$ = ""
url$ = "/qb64wiki/index.php/Special:AllPages" 'the first file that we download
Do
file$ = FileLeft$ + _Trim$(Str$(FileCount)) + FileRight$
Download url$, file$
url2$ = GetNextPage$(file$)
P = InStr(url2$, "from=")
If P = 0 Then Exit Do
If Mid$(url2$, P + 5) > CurrentFile$ Then
CurrentFile$ = Mid$(url2$, P + 5)
FileCount = FileCount + 1
url$ = url2$
Else
Exit Do
End If
Loop
DownloadPageLists = FileCount
End Function
Function CleanHTML$ (OriginalText$)
text$ = OriginalText$ 'don't corrupt incoming text
Type ReplaceList
original As String
replacement As String
End Type
'Expandable HTML replacement system
Dim HTML(200) As ReplaceList
HTML(0).original = "&": HTML(0).replacement = "&"
' HTML(1).original = "%24": HTML(1).replacement = "$"
For i = 1 To 200
HTML(i).original = "%" + Hex$(i + 16)
HTML(i).replacement = Chr$(i + 16)
'Print HTML(i).original, HTML(i).replacement
'Sleep
Next
For i = 0 To UBound(HTML)
Do
P = InStr(text$, HTML(i).original)
If P = 0 Then Exit Do
text$ = Left$(text$, P - 1) + HTML(i).replacement + Mid$(text$, P + Len(HTML(i).original))
Loop
Next
CleanHTML$ = text$
End Function
Function GetNextPage$ (currentPage$)
SpecialPageDivClass$ = "<div class=" + Chr$(34) + "mw-allpages-nav" + Chr$(34) + ">"
SpecialPageLink$ = "<a href="
SpecialPageEndLink$ = Chr$(34) + " title"
Open currentPage$ For Binary As #1
l = LOF(1)
t$ = Space$(l)
Get #1, 1, t$
Close
sp = InStr(t$, SpecialPageDivClass$)
If sp Then
lp = InStr(sp, t$, SpecialPageLink$)
If lp Then
lp = lp + 9
lp2 = InStr(lp, t$, SpecialPageEndLink$)
link$ = Mid$(t$, lp, lp2 - lp)
GetNextPage$ = CleanHTML(link$)
End If
End If
End Function
With all of 130 lines of code, we fetch and save the whole wiki to disk!
NOTE: If you run this, this will save over 600 files into the same directory where this program is ran from! I'd suggest saving it into its own directly and running it from there! Complaining over a messy QB64 folder after this warning wil only get me to laugh at you.
Now, this creates a whole bunch of files with a *.HTML extension to them. You can click on any of these files and open them in your web browser, but you should know in advance that the links between them aren't going to work as they expect a specific file structure on the wiki and we're not providing that here. You'll have to click and open each file individually yourself.
There's a little more work with working with these files, but there's also a couple of large advantages as well:
1) Anytime you run the program, you'll know you have the most up to date version of information from the wiki.
2) You don't have to wait for someone to run HTTrack, grab a copy from the web, and share it with you.
3) The total size of this on disk is about 20MB -- not 1.2GB!! It's a helluva lot more portable!
Pages aren't quite as pretty as what you'll find when you go to the wiki itself, as it doesn't have the templates to pull upon to format everything properly, but they're more than readable in my opinion. Below is the way the scancode page looks for me, in microsoft edge, as an example page.
If there's anyone who just wants the files themselves, without having to download the pages on their own (as they take about 10 minutes or so on my machine to download all of them), I've zipped them all up in a 7z archive, which is available via the attachment below.
The Ulam conjecture is a popular task in IT teaching. This is an implementation in QB64.
A "problem" arises when the output is very long, because then the heading can no longer be read because the side scroll bars are missing.
Code: (Select All)
' EP in C' S.47, šb.4.6 'Ulamsches Problem': Von einer beliebigen Startzahl
' Erweitert fuer grosse Zahlen (Formatierung noch anpassen) - 09.04.2022
' QuickBasic 64 Version - 23.05.2022
'========================================================================================
OPTION _EXPLICIT
DIM startzahl AS LONG, sum AS LONG
DIM z AS INTEGER
CLS
PRINT TAB(25); "** ULAMSCHES PROBLEM **"
PRINT TAB(25); "======================="
PRINT TAB(10); "Erzeugt eine Folge von Zahlen aus einer gegebenen Startzahl"
PRINT TAB(10); "nach der Regel:"
PRINT TAB(10); " 1. Ist die Zahl 1, dann Stop (Ende)."
PRINT TAB(10); " 2. Ist die Zahl gerade, wird sie halbiert. Gehe nach (1.)"
PRINT TAB(10); " 3. Ist die Zahl ungerade, wird sie verdreifacht und um eins"
PRINT TAB(10); " vermehrt. Gehe nach (1.)"
PRINT
INPUT "Geben Sie eine (ganze) Startzahl ein: ", startzahl
PRINT "Ergibt die Folge -->"
PRINT
z = 0
sum = 0
WHILE (startzahl <> 1)
IF startzahl MOD 2 = 0 THEN
startzahl = startzahl / 2 'Wenn startzahl gerade ist (Regel 2)
ELSE
startzahl = startzahl * 3 'Wenn startzahl ungerade ist (Regel 3)
startzahl = startzahl + 1
END IF
PRINT USING "######"; startzahl;
sum = sum + startzahl
z = z + 1
IF z MOD 11 = 0 THEN 'Fuer Formatierung der Ausgabe
PRINT
END IF
WEND
PRINT: PRINT
PRINT USING "Diese Folge besteht aus #### Zahlen. Ihre Summe betraegt ######"; z, sum
Simple question. Has anyone written a slit-scan effect program for QB64? That is like the "trip" sequence in the movie "2001 a Space Oddity". If not, is anyone up to the challenge of making one? If so one little rule, it should use an external image to scan. Here is a short YouTube video that shows the technique. I can almost understand how to do it from that myself. Final thought - it might make a good screensaver project too.
errorchecker:
glitch = glitch + 1
Locate 8 + glitch, 1
Print "Glitch in a file somewhere. Something didn't get downloaded properly. :P"
Resume Next
skip_errorchecker:
Dim Shared Cache_Folder As String
Cache_Folder$ = "./"
If InStr(_OS$, "WIN") = 0 Then Cache_Folder$ = ".\"
'If _DirExists(Cache_Folder$) = 0 Then MkDir Cache_Folder$
Dim Shared Help_sx, Help_sy, Help_cx, Help_cy
Dim Shared Help_Select, Help_cx1, Help_cy1, Help_SelX1, Help_SelX2, Help_SelY1, Help_SelY2
Dim Shared Help_MSelect
Help_sx = 1: Help_sy = 1: Help_cx = 1: Help_cy = 1
Dim Shared Help_wx1, Help_wy1, Help_wx2, Help_wy2 'defines the text section of the help window on-screen
Dim Shared Help_ww, Help_wh 'width & height of text region
Dim Shared help_h, help_w 'width & height
Dim Shared Help_Txt$ '[chr][col][link-byte1][link-byte2]
Dim Shared Help_Txt_Len
Dim Shared Help_Line$ 'index of first txt element of a line
Dim Shared Help_Link$ 'the link info [sep][type:]...[sep]
Dim Shared Help_Link_Sep$: Help_Link_Sep$ = Chr$(13)
Dim Shared Help_LinkN
Dim Shared Help_NewLineIndent
Dim Shared Help_Underline
'Link Types:
' PAGE:wikipagename
' EXTL:external link url
Dim Shared Help_Pos, Help_Wrap_Pos
Dim Shared Help_BG_Col
Dim Shared Help_Col_Normal: Help_Col_Normal = 7
Dim Shared Help_Col_Link: Help_Col_Link = 9
Dim Shared Help_Col_Bold: Help_Col_Bold = 15
Dim Shared Help_Col_Italic: Help_Col_Italic = 15
Dim Shared Help_Col_Section: Help_Col_Section = 8
Dim Shared Help_Bold, Help_Italic, Help_DList
Dim Shared Help_LockWrap, Help_LockParse
Dim Shared Help_Center, Help_CIndent$
ReDim Shared Help_LineLen(1)
ReDim Shared Back$(1)
ReDim Shared Back_Name$(1)
Type Help_Back_Type
sx As Long
sy As Long
cx As Long
cy As Long
End Type
ReDim Shared Help_Back(1) As Help_Back_Type
Back$(1) = "QB64 Help Menu"
Back_Name$(1) = Back2BackName$(Back$(1))
Help_Back(1).sx = 1: Help_Back(1).sy = 1: Help_Back(1).cx = 1: Help_Back(1).cy = 1
Dim Shared Help_Back_Pos
Help_Back_Pos = 1
Dim Shared Help_Search_Time As Double
Dim Shared Help_Search_Str As String
Dim Shared Help_PageLoaded As String
Dim Shared Help_Recaching, Help_IgnoreCache
'Unicode replacements
Type wikiUtf8Replace
utf8 As String * 4 '= MKI$(reversed hex 2-byte UTF-8 sequence) or MKL$(reversed hex 3/4-byte UTF-8 sequence)
repl As String * 8 '= replacement string (1-8 chars)
End Type
Dim Shared wpUtfRepl(0 To 50) As wikiUtf8Replace
Dim Shared wpUtfReplCnt: wpUtfReplCnt = -1 'wpUtfRepl index counter (pre-increment, hence
'you don't need "wpUtfReplCnt - 1" when used in loops, just do "0 TO wpUtfReplCnt"
'Note: All UTF-8 values must be reversed in MKI$/MKL$, as it flips them to little endian.
' In the wiki text they are noted in big endian, hence we need to pre-flip them.
'2-byte sequences
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA9C2): wpUtfRepl(wpUtfReplCnt).repl = "(c)" 'copyright
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA9C3): wpUtfRepl(wpUtfReplCnt).repl = Chr$(130) 'accent (é)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA2C3): wpUtfRepl(wpUtfReplCnt).repl = Chr$(131) 'accent (â)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA0C3): wpUtfRepl(wpUtfReplCnt).repl = Chr$(133) 'accent (à)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA5C3): wpUtfRepl(wpUtfReplCnt).repl = Chr$(134) 'accent (å)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA7C3): wpUtfRepl(wpUtfReplCnt).repl = Chr$(135) 'accent (ç)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HAAC3): wpUtfRepl(wpUtfReplCnt).repl = Chr$(136) 'accent (ê)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HABC3): wpUtfRepl(wpUtfReplCnt).repl = Chr$(137) 'accent (ë)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA8C3): wpUtfRepl(wpUtfReplCnt).repl = Chr$(138) 'accent (è)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HAFC3): wpUtfRepl(wpUtfReplCnt).repl = Chr$(139) 'accent (ï)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HAEC3): wpUtfRepl(wpUtfReplCnt).repl = Chr$(140) 'accent (î)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA2C2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(155) 'cents (ø)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HBDC2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(171) 'fraction (½)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HBCC2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(172) 'fraction (¼)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA0C2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(255) 'non-breaking space
'3-byte sequences
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA680E2): wpUtfRepl(wpUtfReplCnt).repl = "..." 'ellipsis
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H8C94E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(218) 'single line draw (top/left corner)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9094E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(191) 'single line draw (top/right corner)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9494E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(192) 'single line draw (bottom/left corner)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9894E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(217) 'single line draw (bottom/right corner)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H8094E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(196) 'single line draw (horizontal line)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H8294E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(179) 'single line draw (vertical line)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HB494E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(193) 'single line draw (hori. line + up connection)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HAC94E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(194) 'single line draw (hori. line + down connection)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA494E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(180) 'single line draw (vert. line + left connection)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9C94E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(195) 'single line draw (vert. line + right connection)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBC94E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(197) 'single line draw (hori./vert. line cross)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HB296E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(30) 'triangle up
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBC96E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(31) 'triangle down
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H8497E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(17) 'triangle left
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBA96E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(16) 'triangle right
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9186E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(24) 'arrow up
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9386E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(25) 'arrow down
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9086E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(27) 'arrow left
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9286E2): wpUtfRepl(wpUtfReplCnt).repl = Chr$(26) 'arrow right
'4-byte sequences
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H80989FF0): wpUtfRepl(wpUtfReplCnt).repl = ":)" 'smily
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H88989FF0): wpUtfRepl(wpUtfReplCnt).repl = ";)" 'wink
'========= END OF WIKI.BI
updatestep = 1
Do 'main loop
'-------- custom display changes --------
'update steps
Select Case updatestep
Case 1
Print "Generating list of cached content..."
Case 2
Print "Adding core help pages to list..."
Case 3
Print "Regenerating keyword list..."
Case 4
Print "Building download queue..."
Case 5
Locate 8, 1: Print "Updating help content file...";
End Select
If updatestep = 5 Then
maxprogresswidth = 52 'arbitrary
percentage = Int(n / c * 100)
percentagechars = Int(maxprogresswidth * n / c)
'percentageMsg$ = "[" + STRING$(percentagechars, 254) + SPACE$(maxprogresswidth - percentagechars) + "]" + STR$(percentage) + "%"
percentageMsg$ = Str$(percentage) + "%"
Print percentageMsg$
ElseIf updatestep = 6 Then
percentageMsg$ = " 100%"
Print percentageMsg$
End If
'-------- end of custom display changes --------
'-------- update routine -------------------------------------
Select Case updatestep
Case 1
'Create a list of all files to be recached
f$ = Chr$(0)
'Prepend core pages to list
f$ = Chr$(0) + "Keyword_Reference_-_By_usage.txt" + f$
f$ = Chr$(0) + "QB64_Help_Menu.txt" + f$
f$ = Chr$(0) + "QB64_FAQ.txt" + f$
updatestep = updatestep + 1
Case 2
updatestep = updatestep + 1
Case 3
'Download and PARSE alphabetical index to build required F1 help links
FullMessage$(1) = "Regenerating keyword list..."
Help_Recaching = 1: Help_IgnoreCache = 1
Print "Downloading: Keyword Reference - Alphabetical "
a$ = Wiki$("Keyword Reference - Alphabetical")
Help_Recaching = 0: Help_IgnoreCache = 0
WikiParse a$
fh1 = FreeFile
Open "Keyword_Reference_-_Alphabetical_1000000_100000000_-_100000000000.txt" For Binary As #fh1
temp$ = Space$(LOF(fh1))
Get #fh1, 1, temp$
Close #fh1
Open "links.txt" For Output As #fh1
Print "GENERATING KEYWORDS..."
Do
p = InStr(p + 2, temp$, "]]")
If p = 0 Then Exit Do
p1 = _InStrRev(p, temp$, "[[")
If p1 < oldp Or p1 = 0 Then Exit Do
l$ = Mid$(temp$, p1 + 2, p - p1 - 2)
If Left$(l$, 1) = "_" Then l$ = Mid$(l$, 2)
If Left$(l$, 1) <> "#" Then Print #fh1, l$
oldp = p + 2
Loop
Close #fh1
Print "GENERATED KEYWORDS..."
updatestep = updatestep + 1
Case 4
'Add all linked pages to download list (if not already in list)
fh = FreeFile
Open "links.txt" For Input As #fh
Do Until EOF(fh)
Line Input #fh, l$
If Len(l$) Then
c = InStr(l$, ","): l$ = Right$(l$, Len(l$) - c)
'Escape all invalid and other critical chars in filenames
PageName2$ = ""
For i = 1 To Len(l$)
c = Asc(l$, i)
Select Case c
Case 32 ' '(space)
PageName2$ = PageName2$ + "_"
Case 34, 38, 42, 47, 58, 60, 62, 63, 92, 124 '("&*/:<>?\|)
PageName2$ = PageName2$ + "%" + Hex$(c)
Case Else
PageName2$ = PageName2$ + Chr$(c)
End Select
Next
PageName2$ = PageName2$ + ".txt"
If InStr(f$, Chr$(0) + PageName2$ + Chr$(0)) = 0 Then
f$ = f$ + PageName2$ + Chr$(0)
End If
End If
Loop
Close #fh
'Redownload all listed files
If f$ <> Chr$(0) Then
c = 0 'count files to download
For x = 2 To Len(f$)
If Asc(f$, x) = 0 Then c = c + 1
Next
c = c - 1
f$ = Right$(f$, Len(f$) - 1)
z$ = Chr$(0)
n = 0
Else
GoTo stoprecache
End If
FullMessage$(2) = ""
updatestep = updatestep + 1
Case 5
If Len(f$) > 0 Then
x2 = InStr(f$, z$)
f2$ = Left$(f$, x2 - 1): f$ = Right$(f$, Len(f$) - x2)
If Right$(f2$, 4) = ".txt" Then
f2$ = Left$(f2$, Len(f2$) - 4)
n = n + 1
FullMessage$(2) = "Page title: " + f2$
Help_IgnoreCache = 1: Help_Recaching = 1: ignore$ = Wiki(f2$): Help_Recaching = 0: Help_IgnoreCache = 0
End If
Else
updatestep = updatestep + 1
End If
Case 6
stoprecache:
FullMessage$(1) = "All pages updated."
FullMessage$(2) = ""
Print "Finished!"
End
_Limit 20
End Select
'-------- end of update routine ------------------------------
mousedown = 0
mouseup = 0
Loop
'========= START OF WIKI.BM
Function Back2BackName$ (a$)
If a$ = "Keyword Reference - Alphabetical" Then Back2BackName$ = "Alphabetical": Exit Function
If a$ = "Keyword Reference - By usage" Then Back2BackName$ = "By Usage": Exit Function
If a$ = "QB64 Help Menu" Then Back2BackName$ = "Help": Exit Function
If a$ = "QB64 FAQ" Then Back2BackName$ = "FAQ": Exit Function
Back2BackName$ = a$
End Function
Function Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached)
Help_PageLoaded$ = PageName$
'Escape all invalid and other critical chars in filenames
PageName2$ = ""
For i = 1 To Len(PageName$)
c = Asc(PageName$, i)
Select Case c
Case 32 ' '(space)
PageName2$ = PageName2$ + "_"
Case 34, 38, 42, 47, 58, 60, 62, 63, 92, 124 '("&*/:<>?\|)
PageName2$ = PageName2$ + "%" + Hex$(c)
Case Else
PageName2$ = PageName2$ + Chr$(c)
End Select
Next
PageName3$ = wikiSafeName$(PageName2$) 'case independent name
'Is this page in the cache?
If Help_IgnoreCache = 0 Then
If _FileExists(Cache_Folder$ + PageName3$ + ".txt") Then
fh = FreeFile
Open Cache_Folder$ + PageName3$ + ".txt" For Binary As #fh
a$ = Space$(LOF(fh))
Get #fh, , a$
Close #fh
chr13 = InStr(a$, Chr$(13))
removedchr13 = 0
Do While chr13 > 0
removedchr13 = -1
a$ = Left$(a$, chr13 - 1) + Mid$(a$, chr13 + 1)
chr13 = InStr(a$, Chr$(13))
Loop
If removedchr13 Then
fh = FreeFile
Open Cache_Folder$ + PageName3$ + ".txt" For Output As #fh: Close #fh
Open Cache_Folder$ + PageName3$ + ".txt" For Binary As #fh
Put #fh, 1, a$
Close #fh
End If
Wiki$ = a$
Exit Function
End If
End If
'Check for curl
If _ShellHide("curl --version") <> 0 Then
Print "Can not find cURL. Terminating program."
_Delay 3
System
End If
'Download message (Status Bar)
If Help_Recaching = 0 Then
a$ = "Downloading '" + PageName$ + "' page..."
If Len(a$) > 60 Then a$ = Left$(a$, 57) + String$(3, 250)
If Len(a$) < 60 Then a$ = a$ + Space$(60 - Len(a$))
Color 0, 3
Print a$
End If
If Help_Underline Then
w = Help_Pos
Help_Pos = 1
If Help_Underline = Help_Col_Section Then
Help_AddTxt String$(w - 1, 205), Help_Underline, 0
Else
Help_AddTxt String$(w - 1, 196), Help_Underline, 0
End If
Help_Underline = 0 'keep before Help_NewLine (recursion)
Help_NewLine
End If
Help_Pos = 1
If Help_Center > 0 Then 'center overrides regular indent
Help_NewLineIndent = 0
Help_AddTxt Space$(Asc(Help_CIndent$, 1)), Help_Col, 0
Help_CIndent$ = Mid$(Help_CIndent$, 2)
ElseIf Help_NewLineIndent > 0 Then
Help_AddTxt Space$(Help_NewLineIndent), Help_Col, 0
End If
End Sub
Sub Help_CheckFinishLine 'Make sure the current help line is finished
If Help_Txt_Len >= 4 Then
If Asc(Help_Txt$, Help_Txt_Len - 3) <> 13 Then Help_NewLine
End If
End Sub
Sub Help_CheckBlankLine 'Make sure the last help line is a blank line (implies finish current)
If Help_Txt_Len >= 8 Then
If Asc(Help_Txt$, Help_Txt_Len - 3) <> 13 Then Help_NewLine
If Asc(Help_Txt$, Help_Txt_Len - 7) <> 13 Then Help_NewLine
End If
End Sub
Sub Help_CheckRemoveBlankLine 'If the last help line is blank, then remove it
If Help_Txt_Len >= 8 Then
If Asc(Help_Txt$, Help_Txt_Len - 3) = 13 Then
Help_Txt_Len = Help_Txt_Len - 4
help_h = help_h - 1
Help_Line$ = Left$(Help_Line$, Len(Help_Line$) - 4)
End If
For i = Help_Txt_Len - 3 To 1 Step -4
If Asc(Help_Txt$, i) <> 32 Then
Help_Txt_Len = i + 3: Exit For
End If
Next
If Asc(Help_Txt$, Help_Txt_Len - 3) <> 13 Then Help_NewLine
End If
End Sub
Function Help_Col 'Helps to calculate the default color
col = Help_Col_Normal
If Help_Italic Then col = Help_Col_Italic
If Help_Bold Then col = Help_Col_Bold 'Note: Bold overrides italic
Help_Col = col
End Function
Help_Pos = 1: Help_Wrap_Pos = 0
Help_Line$ = MKL$(1)
'Word wrap locks (lock wrapping only, but continue parsing regularly)
Help_LockWrap = 0
'Parser locks (neg: soft lock, zero: unlocked, pos: hard lock)
'hard: 2 = inside code blocks, 1 = inside output blocks
'soft: -1 = inside text blocks, -2 = inside fixed blocks
'=> all parser locks also imply a wrapping lock
'=> hard locks almost every parsing except utf-8 substitution and line breaks
'=> soft allows all elements not disrupting the current block, hence only
' paragraph creating things are locked (eg. headings, lists, rulers etc.),
' but text styles, links and template processing is still possible
Help_LockParse = 0
Help_Bold = 0: Help_Italic = 0
Help_Underline = 0
Help_BG_Col = 0
Help_Center = 0: Help_CIndent$ = ""
Help_DList = 0
link = 0: elink = 0: cb = 0: nl = 1
col = Help_Col
'Syntax Notes:
'=============
'everywhere in text
'------------------
' ''' = bold text style
' '' = italic text style
' [url text] = external link to url with text to appear (url ends at 1st found space)
' [[page]] = link to another wikipage
' [[page|text]] = link to another wikipage with alternative text to appear
' {{templatename|param|param|param}} or simply {{templatename}} = predefined styles
'---------------------
'at start of line only
'---------------------
' * = dot list point
' ** = sub (ie. further indented) dot list point
' ;def:desc = full definition/description list
' :desc = description only, but indented as in a full def/desc list
' ;* def:desc = combi list, list dot always belongs to description
' :* desc = combi, description only
'First find and write the page title and last update
d$ = "Page not yet updated, expect visual glitches.": i = InStr(a$, "{{QBDLDATE:")
If i > 0 Then
d$ = "Last updated: " + Mid$(a$, i + 11, InStr(i + 11, a$, "}}") - i - 11)
i = InStr(a$, "{{QBDLTIME:")
If i > 0 Then d$ = d$ + ", at " + Mid$(a$, i + 11, InStr(i + 11, a$, "}}") - i - 11)
ElseIf InStr(a$, "{{PageInternalError}}") > 0 Then
d$ = "Page not found."
End If
t$ = Help_PageLoaded$: i = InStr(a$, "{{DISPLAYTITLE:")
If i > 0 Then t$ = Mid$(a$, i + 15, InStr(i + 15, a$, "}}") - i - 15)
If Left$(t$, 4) = "agp@" Then
d$ = "Auto-generated temporary page."
t$ = Mid$(t$, 5)
End If
i = Len(d$): ii = Len(t$)
Help_AddTxt " Ú" + String$(ii + 2, "Ä") + "¿", 14, 0: Help_NewLine
Help_AddTxt " ³ ", 14, 0: Help_AddTxt t$, 12, 0: Help_AddTxt " ³", 14, 0
Help_AddTxt Space$(Help_ww - i - 2 - Help_Pos) + Chr$(4), 14, 0
If Left$(d$, 4) = "Page" Then i = 8: Else i = 7
Help_AddTxt " " + d$, i, 0: Help_NewLine
Help_AddTxt "ÄÄÄÁ" + String$(ii + 2, "Ä") + "Á" + String$(Help_ww - ii - 7, "Ä"), 14, 0: Help_NewLine
'Init prefetch array
prefetch = 20
Dim c$(prefetch)
For ii = 1 To prefetch
c$(ii) = Space$(ii)
Next
'BEGIN_PARSE_LOOP
n = Len(a$)
i = 1
Do While i <= n
'Get next char and fill prefetch array
c = Asc(a$, i): c$ = Chr$(c)
For i1 = 1 To prefetch
ii = i
For i2 = 1 To i1
If ii <= n Then
Asc(c$(i1), i2) = Asc(a$, ii)
Else
Asc(c$(i1), i2) = 32
End If
ii = ii + 1
Next
Next
'Wiki specific code handling (no restrictions)
s$ = "__NOEDITSECTION__" + Chr$(10): If c$(Len(s$)) = s$ Then i = i + Len(s$) - 1: GoTo charDone
s$ = "__NOEDITSECTION__": If c$(Len(s$)) = s$ Then i = i + Len(s$) - 1: GoTo charDone
s$ = "__NOTOC__" + Chr$(10): If c$(Len(s$)) = s$ Then i = i + Len(s$) - 1: GoTo charDone
s$ = "__NOTOC__": If c$(Len(s$)) = s$ Then i = i + Len(s$) - 1: GoTo charDone
s$ = "<nowiki>": If c$(Len(s$)) = s$ Then i = i + Len(s$) - 1: GoTo charDone
s$ = "</nowiki>": If c$(Len(s$)) = s$ Then i = i + Len(s$) - 1: GoTo charDone
'Direct HTML code is not handled in Code/Output blocks (hard lock), as all text
'could be part of the code example itself (just imagine a HTML parser/writer demo)
If Help_LockParse <= 0 Then
s$ = "<sup>": If c$(Len(s$)) = s$ Then Help_AddTxt "^", col, 0: i = i + Len(s$) - 1: GoTo charDone
s$ = "</sup>": If c$(Len(s$)) = s$ Then i = i + Len(s$) - 1: GoTo charDone
s$ = "<center>" 'centered section
If c$(Len(s$)) = s$ Then
i = i + Len(s$) - 1
wla$ = wikiLookAhead$(a$, i + 1, "</center>")
If InStr(wla$, "#toc") > 0 Or InStr(wla$, "to Top") > 0 Then
i = i + Len(wla$) + 9 'ignore TOC links
Else
Help_Center = 1: Help_CIndent$ = wikiBuildCIndent$(wla$)
Help_AddTxt Space$(Asc(Help_CIndent$, 1)), col, 0 'center content
Help_CIndent$ = Mid$(Help_CIndent$, 2)
End If
GoTo charDone
End If
s$ = "</center>"
If c$(Len(s$)) = s$ Then
i = i + Len(s$) - 1
Help_Center = 0
Help_NewLine
GoTo charDone
End If
s$ = "<p style=" 'custom paragraph (maybe centered)
If c$(Len(s$)) = s$ Then
i = i + Len(s$) - 1
For ii = i To Len(a$) - 1
If Mid$(a$, ii, 1) = ">" Then
wla$ = wikiLookAhead$(a$, ii + 1, "</p>")
If InStr(wla$, "#toc") > 0 Or InStr(wla$, "to Top") > 0 Then
i = ii + Len(wla$) + 4 'ignore TOC links
ElseIf InStr(Mid$(a$, i, ii - i), "center") > 0 Then
Help_Center = 1: Help_CIndent$ = wikiBuildCIndent$(wla$)
Help_AddTxt Space$(Asc(Help_CIndent$, 1)), col, 0 'center (if in style)
Help_CIndent$ = Mid$(Help_CIndent$, 2)
i = ii
End If
Exit For
End If
Next
GoTo charDone
End If
s$ = "</p>"
If c$(Len(s$)) = s$ Then
i = i + Len(s$) - 1
Help_Center = 0
Help_NewLine
GoTo charDone
End If
s$ = "<span" 'custom inline attributes ignored
If c$(Len(s$)) = s$ Then
i = i + Len(s$) - 1
For ii = i To Len(a$) - 1
If Mid$(a$, ii, 1) = ">" Then i = ii: Exit For
Next
GoTo charDone
End If
s$ = "</span>"
If c$(Len(s$)) = s$ Then
i = i + Len(s$) - 1
GoTo charDone
End If
s$ = "<div" 'ignore divisions (TOC and letter links)
If c$(Len(s$)) = s$ Then
i = i + Len(s$) - 1
For ii = i To Len(a$) - 1
If Mid$(a$, ii, 6) = "</div>" Then i = ii + 5: Exit For
Next
GoTo charDone
End If
s$ = "<!--" 'ignore HTML comments
If c$(Len(s$)) = s$ Then
i = i + Len(s$) - 1
For ii = i To Len(a$) - 1
If Mid$(a$, ii, 3) = "-->" Then i = ii + 2: Exit For
Next
GoTo charDone
End If
End If
'Wiki text styles are not handled in Code/Output blocks (hard lock),
'as they could be part of the code example itself
If Help_LockParse <= 0 Then
'Bold style
If c$(3) = "'''" Then
i = i + 2
If Help_Bold = 0 Then Help_Bold = 1 Else Help_Bold = 0
col = Help_Col
GoTo charDone
End If
'Italic style
If c$(2) = "''" Then
i = i + 1
If Help_Italic = 0 Then Help_Italic = 1 Else Help_Italic = 0
col = Help_Col
GoTo charDone
End If
End If
'Wiki links ([ext], [[int]]) are not handled in Code/Output blocks (hard lock),
'as all text could be part of the code example itself
If Help_LockParse <= 0 Then
'External links
If c$(5) = "[http" And elink = 0 Then
elink = 1
elink$ = ""
GoTo charDone
End If
If elink = 1 Then
If c$ = "]" Then
elink = 0
etext$ = elink$
i2 = InStr(elink$, " ")
If i2 > 0 Then
etext$ = Right$(elink$, Len(elink$) - i2)
elink$ = Left$(elink$, i2 - 1)
End If
If Help_LockParse = 0 Then
Help_AddTxt etext$, Help_Col_Link, Help_LinkN
Else
Help_AddTxt etext$, Help_Col_Bold, Help_LinkN
End If
GoTo charDone
End If
elink$ = elink$ + c$
GoTo charDone
End If
'Internal links
If c$(2) = "[[" And link = 0 Then
i = i + 1
link = 1
link$ = ""
GoTo charDone
End If
End If
'However, the internal link logic must run always, as it also handles
'the template {{Cb|, {{Cl| and {{KW| links used in code blocks
If link = 1 Then
If c$(2) = "]]" Or c$(2) = "}}" Then
i = i + 1
link = 0
text$ = link$
i2 = InStr(link$, "|")
If i2 > 0 Then
text$ = Right$(link$, Len(link$) - i2)
link$ = Left$(link$, i2 - 1)
End If
If InStr(link$, "#") Then 'local page links not supported
Help_AddTxt text$, 8, 0
GoTo charDone
ElseIf Left$(link$, 9) = "Category:" Then 'ignore category links
Help_CheckRemoveBlankLine
GoTo charDone
End If
If Help_LockParse = 0 Then
Help_AddTxt text$, Help_Col_Link, Help_LinkN
Else
Help_AddTxt text$, Help_Col_Bold, Help_LinkN
End If
GoTo charDone
End If
link$ = link$ + c$
GoTo charDone
End If
'Wiki tables ({|...|}) are not handled in Code/Output blocks (hard lock),
'as everything could be part of the code example itself
If Help_LockParse <= 0 Then
'Tables (ignored, give info, if not in blocks)
If c$(2) = "{|" Then
wla$ = wikiLookAhead$(a$, i + 2, "|}"): iii = 0
For ii = 1 To Len(wla$)
If Mid$(wla$, ii, 1) = "|" And Mid$(wla$, ii, 2) <> "|-" Then iii = iii + 1
Next
i = i + 1 + Len(wla$) + 2
If iii > 1 Or InStr(wla$, "__TOC__") = 0 Then 'ignore TOC only tables
If Help_LockParse = 0 Then
Help_AddTxt Space$((Help_ww - 52) \ 2) + "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»", 8, 0: Help_NewLine
Help_AddTxt Space$((Help_ww - 52) \ 2) + "º ", 8, 0: Help_AddTxt "The original help page has a table here, please ", 15, 0: Help_AddTxt " º", 8, 0: Help_NewLine
Help_AddTxt Space$((Help_ww - 52) \ 2) + "º ", 8, 0: Help_AddTxt "use the ", 15, 0: ii = Help_BG_Col: Help_BG_Col = 3: Help_AddTxt " View on Wiki ", 15, 0: Help_BG_Col = ii: Help_AddTxt " button in the upper right", 15, 0: Help_AddTxt " º", 8, 0: Help_NewLine
Help_AddTxt Space$((Help_ww - 52) \ 2) + "º ", 8, 0: Help_AddTxt "corner to load the page into your browser. ", 15, 0: Help_AddTxt " º", 8, 0: Help_NewLine
Help_AddTxt Space$((Help_ww - 52) \ 2) + "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ", 8, 0
End If
End If
GoTo charDone
End If
End If
'Wiki templates are handled always, as these are the basic building blocks of all
'the wiki pages, but look for special conditions inside (Help_LockParse checks)
If c$(5) = "{{Cb|" Or c$(5) = "{{Cl|" Or c$(5) = "{{KW|" Then 'just nice wrapped links
i = i + 4 ' 'KW is deprecated (but kept for existing pages)
link = 1
link$ = ""
GoTo charDone
End If
If c$(2) = "{{" Then 'any other templates
i = i + 1
cb = 1
cb$ = ""
GoTo charDone
End If
If cb > 0 Then
If c$ = "|" Or c$(2) = "}}" Then
If c$ = "|" And cb = 2 Then
wla$ = wikiLookAhead$(a$, i + 1, "}}")
cb = 0: i = i + Len(wla$) + 2 'after 1st, ignore all further template parameters
ElseIf c$(2) = "}}" Then
If LCase$(Left$(cb$, 5)) = "small" Then
If Asc(cb$, 6) = 196 Then
Help_AddTxt " " + String$(Help_ww - Help_Pos, 196), 15, 0
Help_BG_Col = 0: col = Help_Col
Else
Help_Center = 0
End If
Help_NewLine: cb$ = "" 'avoid reactivation below
End If
cb = 0: i = i + 1
End If
If c$ = "|" And cb = 1 Then cb = 2
If Help_LockParse = 0 Then 'no section headings in blocks
cbo$ = ""
'Standard section headings (section color, h3 w/o underline, h2 with underline)
'Recommended order of main page sections (h2) with it's considered sub-sections (h3)
If cb$ = "PageSyntax" Then cbo$ = "Syntax:"
If cb$ = "PageLegacySupport" Then cbo$ = "Legacy support" 'sub-sect
If cb$ = "PageParameters" Or cb$ = "Parameters" Then cbo$ = "Parameters:" 'w/o Page suffix is deprecated (but kept for existing pages)
If cb$ = "PageDescription" Then cbo$ = "Description:"
If cb$ = "PageQBasic" Then cbo$ = "QBasic/QuickBASIC" 'sub-sect
If cb$ = "PageNotes" Then cbo$ = "Notes" 'sub-sect
If cb$ = "PageErrors" Then cbo$ = "Errors" 'sub-sect
If cb$ = "PageUseWith" Then cbo$ = "Use with" 'sub-sect
If cb$ = "PageAvailability" Then cbo$ = "Availability:"
If cb$ = "PageExamples" Then cbo$ = "Examples:"
If cb$ = "PageSeeAlso" Then cbo$ = "See also:"
'Independent main page end sections (centered, no title)
If cb$ = "PageCopyright" Then cbo$ = "Copyright"
If cb$ = "PageNavigation" Then cbo$ = "" 'ignored for built-in help
'Internally used templates (not available in Wiki)
If cb$ = "PageInternalError" Then cbo$ = "Sorry, an error occurred:"
'----------
If cbo$ <> "" Then
If Right$(cbo$, 1) = ":" Then Help_Underline = Help_Col_Section
Help_AddTxt cbo$, Help_Col_Section, 0: Help_NewLine
If cbo$ = "Copyright" Then '_gl commands only
Help_NewLine: Help_AddTxt "1991-2006 Silicon Graphics, Inc.", 7, 0: Help_NewLine
Help_AddTxt "This document is licensed under the SGI Free Software B License.", 7, 0: Help_NewLine
Help_AddTxt "https://spdx.org/licenses/SGI-B-2.0.html https://spdx.org/licenses/SGI-B-2.0.html", 15, 0: Help_NewLine
End If
End If
End If
'Code Block
If cb$ = "InlineCode" And Help_LockParse = 0 Then
Help_BG_Col = 1: Help_LockParse = 2
End If
If cb$ = "InlineCodeEnd" And Help_LockParse <> 0 Then
Help_BG_Col = 0: Help_LockParse = 0
Help_Bold = 0: Help_Italic = 0: col = Help_Col
End If
If cb$ = "CodeStart" And Help_LockParse = 0 Then
Help_CheckBlankLine
Help_BG_Col = 1: Help_LockParse = 2
Help_AddTxt String$(Help_ww - 15, 196) + " Code Block " + String$(3, 196), 15, 0: Help_NewLine
If c$(3) = "}}" + Chr$(10) Then i = i + 1
End If
If cb$ = "CodeEnd" And Help_LockParse <> 0 Then
Help_CheckFinishLine: Help_CheckRemoveBlankLine
Help_AddTxt String$(Help_ww, 196), 15, 0: Help_NewLine
Help_BG_Col = 0: Help_LockParse = 0
Help_Bold = 0: Help_Italic = 0: col = Help_Col
End If
'Output Block
If Left$(cb$, 11) = "OutputStart" And Help_LockParse = 0 Then 'does also match new OutputStartBGn templates
Help_CheckBlankLine
Help_BG_Col = 2: Help_LockParse = 1
Help_AddTxt String$(Help_ww - 17, 196) + " Output Block " + String$(3, 196), 15, 0: Help_NewLine
If c$(3) = "}}" + Chr$(10) Then i = i + 1
End If
If cb$ = "OutputEnd" And Help_LockParse <> 0 Then
Help_CheckFinishLine: Help_CheckRemoveBlankLine
Help_AddTxt String$((Help_ww - 54) \ 2, 196), 15, 0
Help_AddTxt " This block does not reflect the actual output colors ", 15, 0
Help_AddTxt String$(Help_ww - Help_Pos + 1, 196), 15, 0: Help_NewLine
Help_BG_Col = 0: Help_LockParse = 0
Help_Bold = 0: Help_Italic = 0: col = Help_Col
End If
'Text Block
If cb$ = "TextStart" And Help_LockParse = 0 Then
Help_CheckBlankLine
Help_BG_Col = 6: Help_LockParse = -1
Help_AddTxt String$(Help_ww - 15, 196) + " Text Block " + String$(3, 196), 15, 0: Help_NewLine
If c$(3) = "}}" + Chr$(10) Then i = i + 1
End If
If cb$ = "TextEnd" And Help_LockParse <> 0 Then
Help_CheckFinishLine: Help_CheckRemoveBlankLine
Help_AddTxt String$(Help_ww, 196), 15, 0: Help_NewLine
Help_BG_Col = 0: Help_LockParse = 0
Help_Bold = 0: Help_Italic = 0: col = Help_Col
End If
'Fixed Block
If (cb$ = "FixedStart" Or cb$ = "WhiteStart") And Help_LockParse = 0 Then 'White is deprecated (but kept for existing pages)
Help_CheckBlankLine
Help_BG_Col = 6: Help_LockParse = -2
Help_AddTxt String$(Help_ww - 16, 196) + " Fixed Block " + String$(3, 196), 15, 0: Help_NewLine
If c$(3) = "}}" + Chr$(10) Then i = i + 1
End If
If (cb$ = "FixedEnd" Or cb$ = "WhiteEnd") And Help_LockParse <> 0 Then 'White is deprecated (but kept for existing pages)
Help_CheckFinishLine: Help_CheckRemoveBlankLine
Help_AddTxt String$(Help_ww, 196), 15, 0: Help_NewLine
Help_BG_Col = 0: Help_LockParse = 0
Help_Bold = 0: Help_Italic = 0: col = Help_Col
End If
'Template wrapped table
If Right$(cb$, 5) = "Table" And Help_LockParse = 0 Then 'no table info in blocks
Help_AddTxt Space$((Help_ww - 52) \ 2) + "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»", 8, 0: Help_NewLine
Help_AddTxt Space$((Help_ww - 52) \ 2) + "º ", 8, 0: Help_AddTxt "The original help page has a table here, please ", 15, 0: Help_AddTxt " º", 8, 0: Help_NewLine
Help_AddTxt Space$((Help_ww - 52) \ 2) + "º ", 8, 0: Help_AddTxt "use the ", 15, 0: ii = Help_BG_Col: Help_BG_Col = 3: Help_AddTxt " View on Wiki ", 15, 0: Help_BG_Col = ii: Help_AddTxt " button in the upper right", 15, 0: Help_AddTxt " º", 8, 0: Help_NewLine
Help_AddTxt Space$((Help_ww - 52) \ 2) + "º ", 8, 0: Help_AddTxt "corner to load the page into your browser. ", 15, 0: Help_AddTxt " º", 8, 0: Help_NewLine
Help_AddTxt Space$((Help_ww - 52) \ 2) + "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ", 8, 0
End If
'Small template text will be centered (maybe as block note)
If LCase$(cb$) = "small" And Help_LockParse <= 0 Then 'keep as is in Code/Output blocks
wla$ = wikiLookAhead$(a$, i + 1, "}}")
Help_CIndent$ = wikiBuildCIndent$(wla$): iii = 0
If i > 31 And Asc(Help_CIndent$, 1) >= Help_ww / 4 Then
If InStr(Mid$(a$, i - 30, 30), "{{CodeEnd}}") > 0 Then iii = -1
If InStr(Mid$(a$, i - 30, 30), "{{TextEnd}}") > 0 Then iii = -6
If InStr(Mid$(a$, i - 31, 31), "{{FixedEnd}}") > 0 Then iii = -6
If InStr(Mid$(a$, i - 31, 31), "{{WhiteEnd}}") > 0 Then iii = -6
End If
If iii <> 0 Then
For ii = Help_Txt_Len - 3 To 1 Step -4
If Asc(Help_Txt$, ii) = 13 And iii < 0 Then
help_h = help_h - 1: Help_Line$ = Left$(Help_Line$, Len(Help_Line$) - 4)
ElseIf Asc(Help_Txt$, ii) = 196 And iii < 0 Then
iii = -iii
ElseIf Asc(Help_Txt$, ii) = 13 And iii > 0 Then
Help_Txt_Len = ii + 3: Exit For
End If
Next
Help_BG_Col = iii: cb$ = cb$ + Chr$(196) 'special signal byte
Help_AddTxt String$(Asc(Help_CIndent$, 1) - 1, 196) + " ", 15, 0
col = 15 'further text color until closing
Else
Help_Center = 1: cb$ = cb$ + Chr$(0) 'no special signal
Help_AddTxt Space$(Asc(Help_CIndent$, 1)), col, 0 'center content
End If
Help_CIndent$ = Mid$(Help_CIndent$, 2)
End If
GoTo charDone
End If
If cb = 1 Then cb$ = cb$ + c$ 'reading macro name
If cb = 2 Then Help_AddTxt Chr$(c), col, 0 'copy macro'd text
GoTo charDone
End If
'Wiki headings (==...==}) are not handled in blocks (soft- and hard lock), as it would
'disrupt the block, also in code blocks it could be part of the code example itself
If Help_LockParse = 0 Then
'Custom section headings (current color, h3 w/o underline, h2 with underline)
ii = 0
If c$(5) = " === " Then ii = 4
If c$(4) = "=== " Then ii = 3
If c$(4) = " ===" Then ii = 3
If c$(3) = "===" Then ii = 2
If ii > 0 Then i = i + ii: GoTo charDone
ii = 0
If c$(4) = " == " Then ii = 3
If c$(3) = "== " Then ii = 2
If c$(3) = " ==" Then ii = 2
If c$(2) = "==" Then ii = 1
If ii > 0 Then i = i + ii: Help_Underline = col: GoTo charDone
End If
'Wiki/HTML rulers (----, <hr>) are not handled in blocks (soft- and hard lock), as it would
'disrupt the block, also in code blocks it could be part of the code example itself
If Help_LockParse = 0 Then
'Rulers
If c$(4) = "----" And nl = 1 Then
i = i + 3
Help_AddTxt String$(Help_ww, 196), 8, 0
GoTo charDone
End If
If c$(4) = "<hr>" Or c$(6) = "<hr />" Then
If c$(4) = "<hr>" Then i = i + 3
If c$(6) = "<hr />" Then i = i + 5
Help_CheckFinishLine
Help_AddTxt String$(Help_ww, 196), 8, 0
GoTo charDone
End If
End If
'Wiki definition lists (;...:...) are not handled in blocks (soft- and hard lock), as it would
'disrupt the block, also in code blocks it could be part of the code example itself
If Help_LockParse = 0 Then
'Definition lists
If c$ = ";" And nl = 1 Then 'definition (new line only)
If c$(2) = "; " Then i = i + 1
Help_Bold = 1: col = Help_Col: Help_DList = 1
If c$(3) = ";* " Then i = i + 2: Help_DList = 3 'list dot belongs to description
If c$(2) = ";*" Then i = i + 1: Help_DList = 2 'list dot belongs to description
GoTo charDone
End If
If c$ = ":" And Help_DList > 0 Then 'description (same or new line)
If c$(2) = ": " Then i = i + 1
Help_Bold = 0: col = Help_Col
If nl = 0 Then Help_NewLine
Help_AddTxt " ", col, 0
Help_NewLineIndent = Help_NewLineIndent + 3
If Help_DList > 1 Then
Help_AddTxt Chr$(4) + " ", 14, 0
Help_NewLineIndent = Help_NewLineIndent + 2
End If
Help_DList = 0
GoTo charDone
End If
If c$ = ":" And nl = 1 Then 'description w/o definition (new line only)
If c$(2) = ": " Then i = i + 1
Help_AddTxt " ", col, 0
Help_NewLineIndent = Help_NewLineIndent + 3
GoTo charDoneKnl 'keep nl state for possible <UL> list bullets
End If
End If
'Wiki lists (*, **) are not handled in blocks (soft- and hard lock), as it would
'disrupt the block, also in code blocks it could be part of the code example itself
If Help_LockParse = 0 Then
'Unordered lists
If nl = 1 Then
If c$(2) = "**" Then
If c$(3) = "** " Then i = i + 2: Else i = i + 1
Help_AddTxt " " + Chr$(4) + " ", 14, 0
Help_NewLineIndent = Help_NewLineIndent + 5
GoTo charDone
End If
If c$ = "*" Then
If c$(2) = "* " Then i = i + 1
Help_AddTxt Chr$(4) + " ", 14, 0
Help_NewLineIndent = Help_NewLineIndent + 2
GoTo charDone
End If
End If
End If
'Unicode handling (no restrictions)
If ((c And &HE0~%%) = 192) And ((Asc(c$(2), 2) And &HC0~%%) = 128) Then '2-byte UTF-8
i = i + 1
For ii = 0 To wpUtfReplCnt
If wpUtfRepl(ii).utf8 = c$(2) + MKI$(&H2020) Then
Help_AddTxt RTrim$(wpUtfRepl(ii).repl), col, 0: Exit For
End If
Next
GoTo charDone
End If
If ((c And &HF0~%%) = 224) And ((Asc(c$(2), 2) And &HC0~%%) = 128) And ((Asc(c$(3), 3) And &HC0~%%) = 128) Then '3-byte UTF-8
i = i + 2
For ii = 0 To wpUtfReplCnt
If wpUtfRepl(ii).utf8 = c$(3) + Chr$(0) Then
Help_AddTxt RTrim$(wpUtfRepl(ii).repl), col, 0: Exit For
End If
Next
GoTo charDone
End If
If ((c And &HF8~%%) = 240) And ((Asc(c$(2), 2) And &HC0~%%) = 128) And ((Asc(c$(3), 3) And &HC0~%%) = 128) And ((Asc(c$(4), 4) And &HC0~%%) = 128) Then '4-byte UTF-8
i = i + 3
For ii = 0 To wpUtfReplCnt
If wpUtfRepl(ii).utf8 = c$(4) Then
Help_AddTxt RTrim$(wpUtfRepl(ii).repl), col, 0: Exit For
End If
Next
GoTo charDone
End If
'Line break handling (no restrictions)
If c = 10 Or c$(4) = "<br>" Or c$(6) = "<br />" Then
If c$(4) = "<br>" Then i = i + 3
If c$(6) = "<br />" Then i = i + 5
Help_NewLineIndent = 0
If Help_LockParse > -2 Then 'everywhere except in fixed blocks
If Help_Txt_Len >= 8 Then 'allow max. one blank line (ie. collapse multi blanks to just one)
If Asc(Help_Txt$, Help_Txt_Len - 3) = 13 And Asc(Help_Txt$, Help_Txt_Len - 7) = 13 Then
If Help_Center > 0 Then Help_CIndent$ = Mid$(Help_CIndent$, 2) 'drop respective center indent
GoTo skipMultiBlanks
End If
End If
End If
Help_AddTxt Chr$(13), col, 0
skipMultiBlanks:
If Help_LockParse <> 0 Then 'in all blocks reset styles at EOL
Help_Bold = 0: Help_Italic = 0: col = Help_Col
Else
If c = 10 Then Help_DList = 0: Help_Bold = 0: col = Help_Col 'def list incl. style ends after real new line
End If
nl = 1
GoTo charDoneKnl 'keep just set nl state
End If
Help_AddTxt Chr$(c), col, 0
charDone:
nl = 0
charDoneKnl: 'done, but keep nl state
i = i + 1
Loop
'END_PARSE_LOOP
'Trim Help_Txt$
Help_Txt$ = Left$(Help_Txt$, Help_Txt_Len) + Chr$(13) 'chr13 stops reads past end of content
End Sub
Function wikiSafeName$ (page$) 'create a unique name for both case sensitive & insensitive systems
ext$ = Space$(Len(page$))
For i = 1 To Len(page$)
c = Asc(page$, i)
Select Case c
Case 65 To 90: Asc(ext$, i) = 49 'upper = 1
Case 97 To 122: Asc(ext$, i) = 48 'lower = 0
Case Else: Asc(ext$, i) = c 'non-letter = take as is
End Select
Next
wikiSafeName$ = page$ + "_" + ext$
End Function
Function wikiLookAhead$ (a$, i, token$) 'Prefetch further wiki text
wikiLookAhead$ = "": If i >= Len(a$) Then Exit Function
j = InStr(i, a$, token$)
If j = 0 Then
wikiLookAhead$ = Mid$(a$, i)
Else
wikiLookAhead$ = Mid$(a$, i, j - i)
End If
End Function
Function wikiBuildCIndent$ (a$) 'Pre-calc center indentions
wikiBuildCIndent$ = "": If a$ = "" Then Exit Function
org$ = a$: b$ = "" 'eliminate internal links
For i = 1 To Len(org$)
If Mid$(org$, i, 2) = "[[" Then
For ii = i + 2 To Len(org$)
If Mid$(org$, ii, 1) = "|" Then i = ii + 1: Exit For
If Mid$(org$, ii, 2) = "]]" Then i = i + 2: Exit For
Next
End If
If Mid$(org$, i, 2) = "]]" Then i = i + 2
b$ = b$ + Mid$(org$, i, 1)
Next
org$ = b$: b$ = "" 'eliminate external links
For i = 1 To Len(org$)
If Mid$(org$, i, 5) = "[http" Then
For ii = i + 5 To Len(org$)
If Mid$(org$, ii, 1) = " " Then i = ii + 1: Exit For
If Mid$(org$, ii, 1) = "]" Then i = i + 1: Exit For
Next
End If
If Mid$(org$, i, 1) = "]" Then i = i + 1
b$ = b$ + Mid$(org$, i, 1)
Next
org$ = b$: b$ = "" 'eliminate templates
For i = 1 To Len(org$)
If Mid$(org$, i, 2) = "{{" Then
For ii = i + 2 To Len(org$)
If Mid$(org$, ii, 1) = "|" Then i = ii + 1: Exit For
If Mid$(org$, ii, 2) = "}}" Then i = i + 2: Exit For
Next
End If
If Mid$(org$, i, 1) = "|" Then
For ii = i + 1 To Len(org$)
If Mid$(org$, ii, 2) = "}}" Then i = ii: Exit For
Next
End If
If Mid$(org$, i, 2) = "}}" Then i = i + 2
b$ = b$ + Mid$(org$, i, 1)
Next
org$ = b$: b$ = "" 'eliminate text styles
For i = 1 To Len(org$)
If Mid$(org$, i, 3) = "'''" Then i = i + 3
If Mid$(org$, i, 2) = "''" Then i = i + 2
b$ = b$ + Mid$(org$, i, 1)
Next
b$ = StrReplace$(b$, "<br>", Chr$(10)) 'convert HTML line breaks
b$ = StrReplace$(b$, "<br />", Chr$(10)) 'convert XHTML line breaks
b$ = _Trim$(b$) + Chr$(10) 'safety fallback
i = 1: st = 1: br = 0: res$ = ""
While i <= Len(b$)
ws = InStr(i, b$, " "): lb = InStr(i, b$, Chr$(10))
If lb > 0 And (ws > lb Or lb - st <= Help_ww) Then Swap ws, lb
If ws > 0 And ws - st <= Help_ww Then
br = ws: i = ws + 1
If Asc(b$, ws) <> 10 And i <= Len(b$) Then _Continue
End If
If br = 0 Then
If lb < ws Then
br = lb
Else
If ws > 0 Then br = ws: Else br = lb
End If
End If
ci = (Help_ww - (br - st)) \ 2: If ci < 0 Then ci = 0
res$ = res$ + Chr$(ci)
i = br + 1: st = br + 1: br = 0
Wend
wikiBuildCIndent$ = res$
End Function
'===== Strings.bas
Function StrRemove$ (myString$, whatToRemove$) 'noncase sensitive
Dim a$, b$
Dim As Long i
a$ = myString$
b$ = LCase$(whatToRemove$)
i = InStr(LCase$(a$), b$)
Do While i
a$ = Left$(a$, i - 1) + Right$(a$, Len(a$) - i - Len(b$) + 1)
i = InStr(LCase$(a$), b$)
Loop
StrRemove$ = a$
End Function
Function StrReplace$ (myString$, find$, replaceWith$) 'noncase sensitive
Dim a$, b$
Dim As Long basei, i
If Len(myString$) = 0 Then Exit Function
a$ = myString$
b$ = LCase$(find$)
basei = 1
i = InStr(basei, LCase$(a$), b$)
Do While i
a$ = Left$(a$, i - 1) + replaceWith$ + Right$(a$, Len(a$) - i - Len(b$) + 1)
basei = i + Len(replaceWith$)
i = InStr(basei, LCase$(a$), b$)
Loop
StrReplace$ = a$
End Function
Function AddQuotes$ (s$)
AddQuotes$ = Chr$(34) + s$ + Chr$(34)
End Function
"So what is this, and what does it do," you ask?
It takes a look at our wiki and basically does the same thing externally that QB64.bas does internally with the Help menu -- it downloads our wiki in a simplified TEXT format.
Now, one important caveat before you guys load this and run it: Save this program in a directory by itself, as it *WILL* download about 870 files from the internet into that directory. If you run this is your main QB64 folder, and come back later to complain about the mess it made of things, I *WILL* giggle at you and point at the big red warning here. Remember -- make a directory for this program, save it inside that directory, and OUTPUT EXE TO SOURCE FOLDER.
Or not... And have a very cluttered directory which this download tons of junk off the web to... The choice is yours.
I just figured this might be something nice which folks who code without using the IDE might want to use for offline reference from time to time, without having to grab the whole wiki itself.
Note2: As is, this doesn't download any of the _gl keywords. We almost never see programs which use _gl commands in them on the forums here, so I figured there wasn't a large demand to have those files downloaded from the wiki. Why waste bandwidth and tie up the wiki with requests for something which folks don't generally use? The files which are downloaded here are all the QB45 A-Z commands, and all the QB64 _A-_Z commands. Other pages can be added later, if wanted/needed.
Note3: This is still a work in progress, hence the forum I posted it under. Don't expect it to be 100% glitch free yet.
I downloaded 0.7.0 this evening. I deleted all files from my 0.6.0 location and extracted 0.7.0 to this location.
Problem 1: If I go to Help / About it still reports that it is 0.6.0.
Problem 2: My program that compiled fine under 0.6.0 fails to compile on 0.7.0. Something odd about this as well. My program file is named "WordClock 1.0.1.9.bas" but when it compiles it, an EXE called "WordClock.EXE" is created.
If I rename the program to "WordClock.bas" it still compiles to "WordClock.exe", but I still get an error and the EXE file size is significantly larger than it was with 0.6.0 (5.53MB vs 3.54MB).
Error reported is: C++ Compilation failed (Check .\internal\temp\compilelog.txt)
1) Other than extracting the files, is there something else I should be doing?
2) I am running on what may possibly be the final build of Windows 11 22H2. This is as yet to be determined, but I thought that it was important that I mention this. Is it possible that this could be contributing to the problem?
One last piece of info: As a test, I disabled real time virus scanning to be sure that is not a contributing factor.
A couple years ago I got this code from Felippe and made a cave shooter game with it as well as a gold hunting game. Today I decided to use Felippe's original example and add my own funny little game map to it. You use the arrow keys to move your guy around the map I drew. The map itself moves unless you are near an edge of the map. This is just an example but feel free to use any or all of the code as well as my map but please keep my "SierraKen" name on the bottom right corner of the map. I'm no artist as you can see, but I like it. Attached is the zip file called Map Movement Example.zip with the .bas and the .jpg files inside. Put both in the same directory. Tell me what you think, thanks.
If a .bas file had a space in the name, it would not compile properly.
When multiple instances of the IDE were used, the second instance would not always recompile the program after changes are made.
The symbol file was fixed to work correctly even when the EXE variable provided to the Makefile includes a path.
The version number was fixed to correctly reflect the release version.
Fix to windows setup_win.bat cleaning up the mingw compilers after installation.
Fix to IDE freeze occurring due to invalid line endings coming from git.
Fix to Run Only not deleting the temporary executable on some distros of Linux.
Fix to _DESKTOPWIDTH and _DESKTOPHEIGHT. They no longer require a valid window handle to generate a proper response.
Enhancements:
IDE wiki parser has been enhanced and replaced for more versatile and professional looking pages inside Help.
Creation of a new MakeFile system.
Release v0.6.0 Notes
Add "Run Only" option to IDE menu.
Swap out PNG library for modern version -- we now load PNG files about 30% faster.
Fix to page width with variable width fonts.
_Bin$ added to the language. (see wiki for more information)
Removed/Replaced several more links which were pointing to the old qb64.org sites and forums.
Using the number-based $VERSIONINFO flags will now also set the string versions of those flags, if values for them are not provided.
Release v0.5.0 Notes
Another step forward in making our first version "1.0" as the new team working on QB64. This release (version 0.5) now:
Has swapped out the mingw compilers to updated versions for Windows users.
Reduced the size of the repo considerably for those who wish to download direct and setup QB64 manually, for whatever reason.
Prepacked Linux and max versions of QB64, which come in at less than 10MB each now.
We've swapped out all the references to the now defunct .net and .org sites that we could find, and replaced them to proper, working links which now connect to our new wiki, forum, and all at qb64phoenix.com.
$Color:0 and $Color:32 has now been tweaked to work with $NoPrefix. Color names will remain the same in all cases, if $Color is used without $NoPrefix. When $Color is used in conjunction with $NoPrefix, the colors of Red, Green, and Blue which would normally conflict with the now underscoreless commands of _Red, _Green, _Blue, have been altered to have NP_appended to them (for No Prefix). Example: Color NP_Red, Orange for a red on orange color.
Click on the big title above to go directly to the release page and grab yourself a copy of the latest version for all your QB64 needs!
Here's something I made to use for several things, thought I'd share it here. It's a scrolling fog or cloud background you can easily add to programs. The image is seamless so it looks like the fog/cloud just keeps rolling. I threw in a flying witch to show how you can use it as a background with other things.
This uses a real image converted to bas code - I'm trying to figure out how to make a good looking seamless fog image using just QB64 drawing commands instead, so I can eliminate using a real image (and a lot of BAS code). Anyway, here's an example of scrolling an image as a background.
- Dav
Code: (Select All)
'=============
'FOGSCROLL.BAS
'=============
'Scrolls a seamless fog image on screen.
'Coded by Dav, MAY/2022
'I made a seamless fog image in a paint program and
'converted it into BAS code using the BASIMAGE program.
'This demo puts two images side by side so it scrolls them.
'The result is an effect of a constant moving fog or cloud.
'You may freely use this in your programs.
'I threw in a flying witch to show how easy it is to use.
'Press SPACE to raise the witch up.
SCREEN _NEWIMAGE(1000, 600, 32)
fog& = BASIMAGE1&
witch& = BASIMAGE2&
DO
'===================================================
'This way scrolls fog images left...
_PUTIMAGE (spos, 0)-(spos + _WIDTH, _HEIGHT), fog&
_PUTIMAGE (spos + _WIDTH, 0)-(spos + (_WIDTH * 2), _HEIGHT), fog&
spos = spos - 6: IF spos <= -_WIDTH THEN spos = 0
'Use this one to scroll right...
'_PUTIMAGE (spos, 0)-(spos + _WIDTH, _HEIGHT), fog&
'_PUTIMAGE (spos - _WIDTH, 0)-(spos, _HEIGHT), fog&
'spos = spos + 6: IF spos >= _WIDTH THEN spos = 0
'Here's the witch code....
'if pressed space, move witch up& forward
IF INP(&H60) = 57 THEN
witchflyy = witchflyy - 4
witchflyx = witchflyx + 3
spos = spos - 2 '<-- scroll fog faster too (remove it wanted)
ELSE
' else wich drifts down
witchflyy = witchflyy + 2
witchflyx = witchflyx - 1
END IF
'keep witch in screen bounds
IF witchflyx < 5 THEN witchflyx = 5
IF witchflyx > _WIDTH - 100 THEN witchflyx = _WIDTH - 100
IF witchflyy < 5 THEN witchflyy = 5
IF witchflyy > _HEIGHT - 100 THEN witchflyy = _HEIGHT - 100