The interface now uses InKey$ instead of Input, woohoo!
Code: (Select All)
' Opens google qb64.rip links in mirror site.
' http://qb64phoenix.com/forum/showthread.php?tid=429
' DATE WHO-DONE-IT DID-WHAT
' 2022-05-18 Pete Created QB64.org URL redirector.
' 2022-07-22 madscijr Added options menu and support for wiki.
' 2022-07-29 madscijr Changed input from Input to Inkey$.
' TEST LINKS:
' https://www.qb64.org/forum/index.php?topic=3348.0
' https://www.qb64.org/forum/index.php?topic=896.0
' https://www.qb64.org/forum/index.php?topic=1073.0
' http://www.qb64.org/wiki/SCREEN#Legacy_Screen_Modes
' http://www.qb64.org/wiki/TIMER_(statement)
' http://www.qb64.org/wiki/ON_TIMER(n)
' http://www.qb64.org/wiki/COLOR
Const FALSE = 0
Const TRUE = Not FALSE
Dim in$
Dim iCount%: iCount% = 0
Dim oldURL$
Dim parse$
Dim newURL$
Dim bUpdateClipboard%
Dim sOpenBrowser$
Dim sValue$
Dim sMessage$
Dim iPos%
Dim sKey$
Dim bChrome%
Dim bFirefox%
Dim bDontNavigate%
Dim bScreenUpdate%
bScreenUpdate% = TRUE
bUpdateClipboard% = TRUE
sOpenBrowser$ = "c"
sMessage$ = ""
Do
bChrome% = (sOpenBrowser$ = "g")
bFirefox% = (sOpenBrowser$ = "f")
bDontNavigate% = ((bChrome% = FALSE) And (bFirefox% = FALSE))
If (bScreenUpdate% = TRUE) Then
Cls
Print "QB64.org link updater by Pete, modified by madscijr"
Print
Print "1. Copy old link to clipboard first"
Print "2. Select options (see below)"
Print "3. Press ENTER to convert link and do something."
Print
Print "ESC = quit"
Print
Print "---------------------------------------------------"
Print "Clipboard options:"
Print "C = Enable update clipboard.........." + IIFSTR$(bUpdateClipboard%, "<---", " ")
Print "D = Disable update clipboard.........." + IIFSTR$(bUpdateClipboard%, " ", "<---")
Print
Print "Navigation options:"
Print "G = Navigates to new link in Chrome..." + IIFSTR$(bChrome%, "<---", " ")
Print "F = Navigates to new link in Firefox.." + IIFSTR$(bFirefox%, "<---", " ")
Print "N = Don't navigate to new link........" + IIFSTR$(bDontNavigate%, "<---", " ")
Print "---------------------------------------------------"
Print sMessage$: If Len(sMessage$) > 0 Then sMessage$ = ""
bScreenUpdate% = FALSE
End If
sKey$ = InKey$
If UCase$(sKey$) = "C" Then
If bUpdateClipboard% = FALSE Then
bUpdateClipboard% = TRUE
bScreenUpdate% = TRUE
End If
ElseIf UCase$(sKey$) = "D" Then
If bUpdateClipboard% = TRUE Then
bUpdateClipboard% = FALSE
bScreenUpdate% = TRUE
End If
ElseIf UCase$(sKey$) = "G" Then
If sOpenBrowser$ <> "g" Then
sOpenBrowser$ = "g"
bScreenUpdate% = TRUE
End If
ElseIf UCase$(sKey$) = "F" Then
If sOpenBrowser$ <> "f" Then
sOpenBrowser$ = "f"
bScreenUpdate% = TRUE
End If
ElseIf UCase$(sKey$) = "N" Then
If sOpenBrowser$ <> "n" Then
sOpenBrowser$ = "n"
bScreenUpdate% = TRUE
End If
ElseIf sKey$ = Chr$(27) Then
Exit Do
ElseIf sKey$ = Chr$(13) Then
If Len(_Clipboard$) Then
oldURL$ = LCase$(_Clipboard$)
' FORUMS:
' OLD: https://www.qb64.org/forum/index.php?topic={topic}
' NEW: https://qb64forum.alephc.xyz/index.php?topic={topic}
' WIKI:
' OLD: http://www.qb64.org/wiki/{topic}
' NEW: https://qb64phoenix.com/qb64wiki/index.php/{topic}
If InStr(oldURL$, "/www.qb64.org/forum/index.php") > 0 Then
' URL IS FROM FORUMS...
If InStr(oldURL$, "?topic=") > 0 Then
sMessage$ = sMessage$ + "Detected forum link." + Chr$(13)
parse$ = Mid$(oldURL$, InStr(oldURL$, "index"))
newURL$ = "https://qb64forum.alephc.xyz/" + parse$
Else
sMessage$ = sMessage$ + "Detected forum link, no topic." + Chr$(13)
' GOTO THE ROOT FORUMS URL
newURL$ = "https://qb64forum.alephc.xyz/index.php"
End If
iCount% = iCount% + 1
ElseIf InStr(oldURL$, "/www.qb64.org/wiki") > 0 Then
' URL IS FROM WIKI...
If InStr(oldURL$, "/www.qb64.org/wiki/") > 0 Then
sMessage$ = sMessage$ + "Detected wiki link." + Chr$(13)
iPos% = _InStrRev(oldURL$, "/wiki/")
If iPos% > 0 Then
parse$ = Right$(oldURL$, Len(oldURL$) - (iPos% + 5))
End If
newURL$ = "https://qb64phoenix.com/qb64wiki/index.php/" + parse$
Else
sMessage$ = sMessage$ + "Detected wiki link, no topic." + Chr$(13)
' GOTO THE ROOT WIKI URL
newURL$ = "https://qb64phoenix.com/qb64wiki/index.php"
End If
iCount% = iCount% + 1
Else
sMessage$ = sMessage$ + "Link not recognized." + Chr$(13)
newURL$ = ""
End If
If Len(newURL$) > 0 Then
sMessage$ = sMessage$ + "Converted, new URL is:" + Chr$(13) + newURL$ + Chr$(13)
If sOpenBrowser$ = "g" Then
sMessage$ = sMessage$ + "Opening new link in Chrome." + Chr$(13)
Shell _DontWait "chrome " + newURL$
ElseIf sOpenBrowser$ = "f" Then
sMessage$ = sMessage$ + "Opening new link in Firefox." + Chr$(13)
Shell _DontWait "firefox " + newURL$
End If
If bUpdateClipboard% = TRUE Then
sMessage$ = sMessage$ + "Copying new link to clipboard." + Chr$(13)
_Clipboard$ = newURL$
End If
End If
Else
sMessage$ = sMessage$ + "Clipboard is empty!" + Chr$(13)
End If
bScreenUpdate% = TRUE
End If
If bScreenUpdate% = TRUE Then
While InKey$ <> "": Wend ' Clear the keyboard buffer
End If
_Limit 60
Loop
'System
End
' /////////////////////////////////////////////////////////////////////////////
' IIF function for QB for strings
Function IIFSTR$ (Condition, IfTrue$, IfFalse$)
If Condition Then IIFSTR$ = IfTrue$ Else IIFSTR$ = IfFalse$
End Function
' ----------------------------------------------------------------------------------------------------------------------------------------------------------------
' Redirect old-forum and wiki search results to Pheonix as appropriate.
' http://qb64phoenix.com/forum/showthread.php?tid=429
' mpgcan
' 05-18-2022, 10:37 AM
'
' You know how it goes. Searching for a QB64 solution, search engines return
' results to the old-forum or old-wiki. Clicking the link only to be informed the
' server is not found.
'
' With the link returned, you can use part of it to search in either the new-wiki
' or old-backup forum. This has become very tedious. I thought there must be a
' better way.
'
' A simple solution is to use Einar Egilsson's Redirector for this. It is a
' browser add-on for Firefox, Chrome, Edge and Opera. The Redirector allows you
' to search for a specific URL, substitute it for another URL and force the
' browser to redirect to this new URL.
'
' How to install redirector on Firefox:
'
' 1) Use the following link to get the add-on
' https://addons.mozilla.org/en-GB/firefox/addon/redirector/
'
' 2) Note: This add-on is not actively monitored for security by Mozilla.
' Check out the "Learn more" link. After reading your choice
' if you wish to continue.
'
' 3) Click the Add to Firefox button.
'
' 4) Add Redirector? This extension will have permission to:
' Click Add button
'
' 5) Redirector was added.
' Click the check box. Allow this extension to run in Private Windows
' Click Okay button.
'
' 6) A redirector symbol is displayed at the top right of the browser
' confirming it is successfully installed.
'
' Configuring redirector:
' Redirect from the old QB64 forum to Phoenix's old-archived read only
' working forum.
'
' 1) Click on the redirector symbol in the drop down click
' "Edit Redirects" button.
' 2) On the new browser page that opens, click "Create New Redirect"
' 3) Fill in the form with the following information:
' Configuration information:
' Description........: QB64_forum_old_to_archive
' Example URL........: https://forum.qb64.org/
' Include pattern....: https://forum.qb64.org/*
' Redirect to........: https://qb64forum.alephc.xyz/$1
' Pattern type.......: Wildcard click radio buttom
' Pattern Description: Leave blank
' Example result: https://qb64forum.alephc.xyz/
' To complete it, click the "Save" button.
' 4) Click "Create New Redirect"
' 5) Fill in the form with the following information:
' Configuration information:
' Redirect from the old QB64 Wiki to Pheonix's new QB64 Wiki.
' Description : QB64_Wiki_old_to_new
' Example URL : https://wiki.qb64.org/wiki/
' Include pattern : https://wiki.qb64.org/wiki/*
' Redirect to : https://qb64phoenix.com/qb64wiki/index.php/$1
' Pattern type : Wildcard click radio buttom
' Pattern Description: Leave blank
' Example result: https://qb64phoenix.com/qb64wiki/index.php/
' To complete it, click the "Save" button.
' 6) Finally disable the first configuration
' "Example redirect, try going to http://example.com/anywordhere"
' By clicking the "Disable" button.
'
' Test:
' Try the following two links in your browser:
' https://forum.qb64.org/index.php?topic=456.0
' https://wiki.qb64.org/wiki/$IF
'
' All the best
' MPGCAN
'
' ----------------------------------------------------------------------------------------------------------------------------------------------------------------
' madscijr
' 05-19-2022, 11:39 AM
' (05-18-2022, 10:37 AM) mpgcan Wrote:
' >A simple solution is to use Einar Egilsson's Redirector for this.
' >It is a browser add-on for Firefox, Chrome, Edge and Opera.
' >The Redirector allows you to search for a specific URL,
' >substitute it for another URL and force the browser to redirect
' >to this new URL.
'
' Thanks for sharing this and explaining how to use it.
' This can come in handy for any number of things...
'
' ----------------------------------------------------------------------------------------------------------------------------------------------------------------
' Pete, Administrator
' 05-19-2022, 01:21 AM
'
' Looks like a useful plugin.
' I made my own in QB64...
'
' ----------------------------------------------------------------------------------------------------------------------------------------------------------------
' madscijr
' 05-19-2022, 11:38 AM
'
' (05-19-2022, 01:21 AM) Pete Wrote:
' >Looks like a useful plugin.
' >I made my own in QB64...
'
' Very cool!
' Not only does it work and is useful, but I never knew QB64 could do that,
' and learned something knew.
' Thanks Pete
' ----------------------------------------------------------------------------------------------------------------------------------------------------------------