Post by xxgeek on Dec 9, 2022 15:07:54 GMT
' Created Dec 9 2022 by xxgeek, a member of the Just Basic Forums @ - justbasiccom.proboards.com/
' A compact version of JB Search - for use in other projects
' Uses little real-estate
' There is no "Contents" for the help pages - for searching the help files only
' With some editing could be used in many projects as an addon / plugin
'
' WARNING - PLACE THIS FILE IN A FOLDER OF IT'S OWN - It copies the JB AppData Folder to DefaultDir$
' NEW VERSION Dec 11 2022 v1.1 - posted approx 6:25 am (Eastern)
' Changed - JB AppData Folder is now copied to it's own folder in DefaultDir$
' Changed - Using separate windows for the results list, and the search textbox.
' Changed - No more "Down Arrow" / "F4 Key" crap. Figured out a good work around.
' Changed - Widened, and lengthened the Listbox - "size matters"
' Added the Prized "GO" Button for the "Mouse Happy" users.
' Changed - Thinned the Scrollbar a bit more.
' Note - If focus to the #main (the small window) is lost, hit the "GO" button, or the small window's frame.
' Note - Put this file into a folder of it's own before RUNing. It creates files, and it copies
' - the Just Basic v2.o folder to DefaultDir$, which is whatever folder this file is in when it is RUN
' NEW VERSION Dec 13 2022 v1.2c - posted approx 1:15 am (Eastern)
' moved the [help] button a little to the left
' Added ability for "Escape Key" to close "#results" and "#main" windows, IF "#results" window is OPEN.
' Added the ability to use the "F1" key to close "#main" window if "#results" window is closed
' Added the ability to use "Tab" when "#results" window is open(only in the "#results" window though)
' - when tabbing through the "#results" window you can regain focus on "#main" window by making a selection
' in "#results" window: re: (font inc/def/dec) or [help] button - or any of the radio buttons.
' To change Window Position: Edit line 9 "winPos = wpCenter" - line 8 shows options.
' - this option(&code) was provided by tsh73 -
' Also thanks to tsh73 the bak folder no longer gets copied to DefaultDir$
' - and it should now work in Windows versions XP and later
' Added ability to use back button in search textbox - This option(and code) was provided by Rod
' NEW Version# 1.3 Dec 14 2022 posted approx 3:20pm (Eastern)
' Now the user can just type a search word and hit [enter] to get results, no more hitting [enter] twice
' When the "Escape" key was pressed. A character was being typed into the search textbox. Fixed
' Noticed a new issue. When "Shift" was pressed a character was being typed into the search textbox
' causing the next search to fail. It also prevented any uppercase characters from being used as search words. Fixed.
' Users can now search for characters like $,#,@,!,~ & * ( ) _ + | without problems
' Main update = When you open this app now, just type a search word and hit [Enter] and the list is populated without
' - having to type ]Enter} again.
' Am I happy now? Darn right I am
' Anyone finds another issue "I KILL YOU". "There are NO MORE ISSUES" - jk of course, speak up if 'anything at all' comes to mind.
' NEW Version # v1.7 Dec 21 2022 approx 1:00 am (Eastern)
' New permanent name = Tiny Jb HelpSearch
'
' When selecting any of the font resizing buttons the text would resize once and quit. Fixed
' Did some editing to what gets displayed, depending on the circumstances of the results.
' Added indication a search is underway while waiting for a results (for slower older hard drives and PC's)
' Took Rod's advice to avoid complexity and changed from a graphics to dialog windows (on all 3 windows)
' Focus can be lost (by clicking on an open (list)window, including scroll bars, but regained easily
' _ by hitting [enter] or [GO], resetting a font, a checkbox, or clicking anywhere in the small window.
' Escape closes the window with focus, (if main(small window) then all windows close)
' Change - put Contents back functioning for those who like having it available.
' Changes - checkbox and font resize buttons put in view, and main window is slightly smaller
' _ plus the help button has changed from "Help" to "?"
' Change - Contents, Results and Main windows are each separate windows.
' Contents menu opens to the left of Results window when Contents button is pressed
'_ and closes if a search is made (can be editted to stay open easily)
'_ code lines for changing are marked with a comment.
' NEW Version # v1.9 Dec 23 2022 posted approx 9:30pm
' Cleaned up the code a bit.
' Changed Font resizing method and let Windows take care of initial font size
' Added the Tutorial menu - The TuT button - Opens to the left of Results
' Changed name of Contents to Help (space was limited), wanted to keep it tiny.
Tiny JB Help Search v1.9
' A compact version of JB Search - for use in other projects
' Uses little real-estate
' There is no "Contents" for the help pages - for searching the help files only
' With some editing could be used in many projects as an addon / plugin
'
' WARNING - PLACE THIS FILE IN A FOLDER OF IT'S OWN - It copies the JB AppData Folder to DefaultDir$
' NEW VERSION Dec 11 2022 v1.1 - posted approx 6:25 am (Eastern)
' Changed - JB AppData Folder is now copied to it's own folder in DefaultDir$
' Changed - Using separate windows for the results list, and the search textbox.
' Changed - No more "Down Arrow" / "F4 Key" crap. Figured out a good work around.
' Changed - Widened, and lengthened the Listbox - "size matters"
' Added the Prized "GO" Button for the "Mouse Happy" users.
' Changed - Thinned the Scrollbar a bit more.
' Note - If focus to the #main (the small window) is lost, hit the "GO" button, or the small window's frame.
' Note - Put this file into a folder of it's own before RUNing. It creates files, and it copies
' - the Just Basic v2.o folder to DefaultDir$, which is whatever folder this file is in when it is RUN
' NEW VERSION Dec 13 2022 v1.2c - posted approx 1:15 am (Eastern)
' moved the [help] button a little to the left
' Added ability for "Escape Key" to close "#results" and "#main" windows, IF "#results" window is OPEN.
' Added the ability to use the "F1" key to close "#main" window if "#results" window is closed
' Added the ability to use "Tab" when "#results" window is open(only in the "#results" window though)
' - when tabbing through the "#results" window you can regain focus on "#main" window by making a selection
' in "#results" window: re: (font inc/def/dec) or [help] button - or any of the radio buttons.
' To change Window Position: Edit line 9 "winPos = wpCenter" - line 8 shows options.
' - this option(&code) was provided by tsh73 -
' Also thanks to tsh73 the bak folder no longer gets copied to DefaultDir$
' - and it should now work in Windows versions XP and later
' Added ability to use back button in search textbox - This option(and code) was provided by Rod
' NEW Version# 1.3 Dec 14 2022 posted approx 3:20pm (Eastern)
' Now the user can just type a search word and hit [enter] to get results, no more hitting [enter] twice
' When the "Escape" key was pressed. A character was being typed into the search textbox. Fixed
' Noticed a new issue. When "Shift" was pressed a character was being typed into the search textbox
' causing the next search to fail. It also prevented any uppercase characters from being used as search words. Fixed.
' Users can now search for characters like $,#,@,!,~ & * ( ) _ + | without problems
' Main update = When you open this app now, just type a search word and hit [Enter] and the list is populated without
' - having to type ]Enter} again.
' Am I happy now? Darn right I am
' Anyone finds another issue "I KILL YOU". "There are NO MORE ISSUES" - jk of course, speak up if 'anything at all' comes to mind.
' NEW Version # v1.7 Dec 21 2022 approx 1:00 am (Eastern)
' New permanent name = Tiny Jb HelpSearch
'
' When selecting any of the font resizing buttons the text would resize once and quit. Fixed
' Did some editing to what gets displayed, depending on the circumstances of the results.
' Added indication a search is underway while waiting for a results (for slower older hard drives and PC's)
' Took Rod's advice to avoid complexity and changed from a graphics to dialog windows (on all 3 windows)
' Focus can be lost (by clicking on an open (list)window, including scroll bars, but regained easily
' _ by hitting [enter] or [GO], resetting a font, a checkbox, or clicking anywhere in the small window.
' Escape closes the window with focus, (if main(small window) then all windows close)
' Change - put Contents back functioning for those who like having it available.
' Changes - checkbox and font resize buttons put in view, and main window is slightly smaller
' _ plus the help button has changed from "Help" to "?"
' Change - Contents, Results and Main windows are each separate windows.
' Contents menu opens to the left of Results window when Contents button is pressed
'_ and closes if a search is made (can be editted to stay open easily)
'_ code lines for changing are marked with a comment.
' NEW Version # v1.9 Dec 23 2022 posted approx 9:30pm
' Cleaned up the code a bit.
' Changed Font resizing method and let Windows take care of initial font size
' Added the Tutorial menu - The TuT button - Opens to the left of Results
' Changed name of Contents to Help (space was limited), wanted to keep it tiny.
Tiny JB Help Search v1.9
'Search the JB Help files with Tiny JB HelpSearch
' Original JB HelpSearch created by cundo
' Edited by xxgeek with added features, changed appearance, and a more focussed relevant variety Results
' NEW Version # v1.7 Dec 21 2022
' New permanent name = Tiny Jb HelpSearch
'
' When selecting any of the font resizing buttons the text would resize once and quit. Fixed
' Did some editing to what gets displayed, depending on the circumstances of the results.
' Added indication a search is underway while waiting for a results (for slower older hard drives and PC's)
' Took Rod's advice to avoid complexity and changed from a graphics to dialog windows (on all 3 windows)
' Focus can be lost (by clicking on an open (list)window, including scroll bars, but regained easily
' _ by hitting [enter] or [GO], resetting a font, a checkbox, or clicking anywhere in the small window.
' Escape closes the window with focus, (if main(small window) then all windows close)
' Change - put Contents back functioning for those who like having it available.
' Changes - checkbox and font resize buttons put in view, and main window is slightly smaller
' _ plus the help button has changed from "Help" to "?"
' Change - Contents, Results and Main windows are each separate windows.
' Contents menu opens to the left of Results window when Contents button is pressed
'_ and closes if a search is made (can be editted to stay open easily)
'_ code lines for changing are marked with a comment.
'
' NEW Version # v1.9 Dec 23 2022 posted approx 9:30pm
' Cleaned up the code a bit.
' Changed Font resizing method and let Windows take care of initial font size
' Added the Tutorial menu - The TuT button - Opens to the left of Results
' Changed name of Contents to Help (space was limited), wanted to keep it tiny.
nomainwin
TITLE$ = "Tiny JB-HelpSearch v1.7 - by xxgeek"
call getUserPath 'get the users home path
if VAL(Version$)<2 then notice "Just BASIC 2.0 required" : end 'get JB version #
WindowWidth = 265 : WindowHeight = 70 'start defining the window for #main
UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
UpperLeftY=INT((DisplayHeight-WindowHeight)/2-300)
dim searchList$(500), info$(0,0), oneOf$(2500), hiddenCharacters$(25), mainList$(500), tutorialList$(100) 'declare some variables
global jbPath$, helpFilePath$,tutorialPath$, freeformPath$, upath$
jbPath$ = getEnvVar$("ProgramFiles")+"\Just Basic v2.0"
jbexe$ = jbPath$;"\jbasic.exe"
helpFilePath$ = jbPath$;"\jb2help\JustBASIC_2_web"
helpFileMenu$ = "amber_menu.htm"
freeformPath$ = helpFilePath$;"\html\fformhelp"
uAppPath$ = upath$;"\Application Data\Just Basic v2.0"
tutorialPath$ = jbPath$ ;"\jbtutorial"
homeWork$ = uAppPath$;"\TUTORIAL"
tutorialEditPage$ = DefaultDir$;"\Just Basic v2.0\TUTORIAL"
q$ = chr$(34)
[checkpoint]
'Check for jb help files existence - end program if false
if fileExists(helpFilePath$, helpFileMenu$) = 0 then notice "Program Terminated";chr$(13) ; "Sorry, Can't find the help files" : end
' if not exist, copy the users 'justbasic2.ini' file to DefaultDir$ (the dir this file is running from)
' This is done to prevent the "World of Just Basic" window, with all the Links from opening
' when a Code file( Example or Function) is opened in JB the IDE
if fileExists(uAppPath$, "justbasic2.ini") then
if fileExists(DefaultDir$, "justbasic2.ini") = 0 then
open uAppPath$;"\justbasic2.ini" for input as #1
open DefaultDir$;"\justbasic2.ini" for output as #2
#2 input$(#1, lof(#1)) : close #1 : close #2
end if
else
notice "Can't find the justbasic2.ini file = minor problem - continue on" : goto [checkpoint]
end if
'Copy the folder from appdata to defaultdir (So the support files are present and the .bas files work when opened in JB)
if pathExists(DefaultDir$;"\Just Basic v2.0") = 0 then
cursor hourglass
a = CopyFolder(uAppPath$, DefaultDir$;"\Just Basic v2.0")
cursor normal
end if
open helpFilePath$; "\"; helpFileMenu$ for input as #1
txt$ = input$(#1, lof(#1))
close #1
'Load the "Contents" menu list array
lowerTxt$= lower$(txt$)
while 1
scan
startAt = c+1
a = instr(lowerTxt$, "href",startAt)
b = instr(lowerTxt$, ">",a+1)
c = instr(lowerTxt$, "</a>",b+1)
if a=0 or b=0 or c= 0 then exit while
hrefA= instr(lowerTxt$,chr$(34),a+1)
hrefB= instr(lowerTxt$,chr$(34),hrefA+1)
idx = idx +1
mainList$(idx)= trim$(mid$(txt$,b+1,c-b-1));chr$(0);_
trim$(mid$(txt$,hrefA+1,hrefB-hrefA-1))
wend
'Create the form - open the window - set some fonts
textbox #main.tb 2, 18, 102, 20
button #main.default, "&GO", [startSearching], UL, 106, 18, 30, 20
button #main.contents, "&Help", [Contents], UL, 138, 18, 30, 20
button #main.jb_tut, "&TuT", [jbtutorial], UL, 170, 18, 30, 20
button #main.incFont, "&+", [incFont], UL, 201, 18, 20, 20
button #main.decFont, "&-", [decFont], UL, 221, 18, 20, 20
button #main.help, "?", [help], UL, 241, 18, 15, 20
checkbox #main.jbhelp, "H", [jbHelp], [nojbHelp], 4, 2, 30, 15
checkbox #main.fform, "F", [freeForm], [nofreeForm], 37, 2, 25, 15
checkbox #main.tutorial, "T", [tutorial], [noTutorial], 67, 2, 25, 15
checkbox #main.tuttext, "TT", [tuttext], [notuttext], 97, 2, 35, 15
checkbox #main.tutcode, "CT", [tutcode], [notutcode], 137, 2, 35, 15
checkbox #main.jbexamples, "CE", [jbexamples], [nojbexamples], 177, 2, 35, 15
checkbox #main.jbfunctions, "CF", [jbfunctions], [nojbfunctions], 217, 2, 35, 15
open "JB-Help-Search" for dialog as #main
#main "trapclose [quit]"
jbHelp = 1
#main.jbhelp "set"
#main.tb "!setfocus"'
wait
'The [Search] button was pressed, or after searching/changing font size etc, the program was directed back here.
[search]
#main.tb "!enable" : #main.tb "!selectall"
done = 0
count = 0
#main.tb "!setfocus"'
wait
[startSearching]
#main.tb "!disable"
redim searchList$(10)
if resultsOpen = 0 then gosub [results]
#main.tb "!contents? searchFor$"
if searchFor$ = "" then [search]
searchList$(0) = " "
searchList$(1) = " "
searchList$(2) = " Searching the - Just Basic v2.0 - Files"
searchList$(3) = " "
searchList$(4) = " For Files containing ";upper$(searchFor$)
searchList$(5) = " "
searchList$(6) = " "
searchList$(7) = " "
searchList$(8) = " "
searchList$(9) = " P L E A S E W A I T"
#results.listbox2 "reload"
'Uncomment the next lines if you want Main Help List or Tutorial List to close automatically when a search starts
'if mainListOpen =1 then close #mainList : mainListOpen = 0
'if tutorialListOpen =1 then close #tutorialList : tutorialListOpen = 0
searchFor$=trim$(searchFor$)
count = 3
cursor hourglass
redim searchList$(600)
redim oneOf$(2500)
'search jb help files
if jbHelp = 1 then
files helpFilePath$;"\html", info$()
numFiles = val(info$(0,0 ))
for i = 1 to numFiles
fileToOpen$ = info$(i, 0)
open helpFilePath$;"\html\"; fileToOpen$ for input as #2
contents$ = input$(#2, lof(#2)) : close #2
if instr(lower$(contents$), lower$(searchFor$)) then
x = 1
if lower$(searchFor$) = "and" then oneOf$(count) = "H_AND" : count = count + 1
if lower$(searchFor$) = "not" then oneOf$(count) = "H_NOT" : count = count + 1
if lower$(searchFor$) = "xor" then oneOf$(count) = "H_XOR" : count = count + 1
if lower$(searchFor$) = "or" then oneOf$(count) = "H_OR" : count = count + 1
listName$ = helpFilePath$;"\html\"; fileToOpen$
open listName$ for input as #1 : isOpen = 1
while not(eof(#1))
scan
line input #1, name$
if x = 5 and lower$(left$(name$, 7)) = lower$("<TITLE>") then
name3$ = mid$(name$, 8, len(name$)-15) : if right$(name3$, 4) = "Etc." then name3$ = left$(name3$, len(name3$) - 1)
oneOf$(count) = "H_";name3$ : count = count + 1
end if'
if x = 8 and left$(lower$(name$), 7) = lower$("<TITLE>") then
name5$ = mid$(name$, 8, len(name$)-15)
oneOf$(count) = "H_";name5$ : count = count + 1
end if
if x = 12 and left$(name$ , 5) = "<P><A" then
name8$ = word$(name$, 2, "</A><B>") : name8$ = left$(name8$, len(name8$)-8)
oneOf$(count) = "H_";name8$ : count = count + 1
end if
if x = 14 and left$(name$ , 3) = "<P>" then
name7$ = mid$(name$, 4, len(name$)-7)
oneOf$(count) = "H_";name7$ : count = count + 1
end if
if x = 15 and right$(name$, 8) = "</B></P>" then
name11$ =word$(name$, 2, "B>") : name11$ = left$(name11$, len(name11$)-2)
oneOf$(count) = "H_";name11$ : count = count + 1
exit while
end if
if x = 15 then exit while
x = x + 1
wend
if isOpen = 1 then close #1 : isOpen = 0
end if
next i
end if
'Search the Freeform help files
if freeForm = 1 then
files freeformPath$, info$()
numFiles = val(info$(0,0 ))
for i = 1 to numFiles
fileToOpen$ = info$(i, 0)
open freeformPath$;"\"; fileToOpen$ for input as #2
contents$ = input$(#2, lof(#2)) : close #2
if instr(lower$(contents$), lower$(searchFor$)) then
listName$ = freeformPath$;"\"; fileToOpen$
open listName$ for input as #1 : isOpen = 1
for x = 1 to 8
line input #1, name$
if x = 7 and left$(lower$(name$), 7) = lower$("<TITLE>") then
name4$ = mid$(name$, 8, len(name$)-15)
oneOf$(count) = "F_";name4$ : count = count + 1
end if
if x = 8 and left$(lower$(name$), 7) = lower$("<TITLE>") then
name9$ = mid$(name$, 8, len(name$)-15)
oneOf$(count) = "F_";name9$ : count = count + 1
end if
next x
if isOpen = 1 then close #1 : isOpen = 0
end if
next i
end if
'search the Tutorial Help files
if tutorial = 1 then
files tutorialPath$, info$()
numFiles = val(info$(0,0 ))
for i = 1 to numFiles
x = 1
fileToOpen$ = info$(i, 0)
open tutorialPath$;"\";fileToOpen$ for input as #2
contents$ = input$(#2, lof(#2)) : close #2
if instr(lower$(contents$), lower$(searchFor$)) then
listName$ = tutorialPath$;"\"; fileToOpen$
open listName$ for input as #1
while not(eof(#1))
scan
line input #1, name$ : name$ = trim$(name$)
if x = 18 and left$(name$, 6) = "<p><b>"then
name12$ = mid$(name$, 7, len(name$)-14)
oneOf$(count) = "T_";name12$ : count = count + 1
end if
if x = 19 and left$(name$, 6) = "<p><b>"then
name6$ = upper$(left$(fileToOpen$, len(fileToOpen$)-5))
oneOf$(count) = "T_";name6$ : count = count + 1
end if
if x = 20 and left$(name$, 6) = "<p><b>"then
name15$ = upper$(left$(fileToOpen$, len(fileToOpen$)-5))
oneOf$(count) = "T_";name15$ : count = count + 1
exit while
end if
if x = 20 then exit while
x = x + 1
wend
close #1
end if
next i
end if
'search the Tutorial HomeWork pages
if tutcode = 1 then
files homeWork$, info$()
numFiles = val(info$(0,0 ))
for i = 1 to numFiles
x = 1
fileToOpen$ = info$(i, 0)
open homeWork$;"\";fileToOpen$ for input as #2
contents$ = input$(#2, lof(#2)) : close #2
if instr(lower$(contents$), lower$(searchFor$)) then
if right$(fileToOpen$, 4) = ".BAS" then
name14$ = left$(fileToOpen$, len(fileToOpen$) - 4)
oneOf$(count) = "CT_";name14$ : count = count + 1
end if
end if
next i
end if
if tuttext = 1 then
files homeWork$, info$()
numFiles = val(info$(0,0 ))
for i = 1 to numFiles
x = 1
fileToOpen$ = info$(i, 0)
open homeWork$;"\";fileToOpen$ for input as #2
contents$ = input$(#2, lof(#2)) : close #2
if instr(lower$(contents$), lower$(searchFor$)) then
if right$(fileToOpen$, 4) = ".TXT" then
name16$ = left$(fileToOpen$, len(fileToOpen$) - 4)
oneOf$(count) = "TT_";name16$ : count = count + 1
x = x + 1
end if
end if
next i
end if
'Search the JB Examples Files
if jbexamples = 1 then
files uAppPath$, "*.bas", info$()
numFiles = val(info$(0,0 ))
for i = 1 to numFiles
fileToOpen$ = info$(i, 0)
open uAppPath$;"\";fileToOpen$ for input as #2
contents$ = input$(#2, lof(#2)) : close #2
if instr(lower$(contents$), lower$(searchFor$)) then
name$ = upper$(fileToOpen$)
name20$ = left$(name$, len(name$)-4)
oneOf$(count) = "CE_";name20$ : count = count + 1
end if
next i
end if
'search the jb functions files
if jbfunctions = 1 then
files uAppPath$;"\FFFunctions", info$()
numFiles = val(info$(0,0 ))
for i = 1 to numFiles
fileToOpen$ = info$(i, 0)
open uAppPath$;"\FFFunctions\";fileToOpen$ for input as #2
contents$ = input$(#2, lof(#2)) : close #2
if instr(lower$(contents$), lower$(searchFor$)) then
name$ = upper$(fileToOpen$)
name$ = left$(name$, len(name$)-4)
oneOf$(count) = "CF_";name$ : count = count + 1
end if
next i
end if
'if no search results found
if count < 4 then
searchList$(0) = " "
searchList$(1) = " "
searchList$(2) = " "
searchList$(3) = " Nothing found for: ";upper$(searchFor$)
searchList$(4) = " "
searchList$(5) = " "
searchList$(6) = " "
searchList$(7) = " Try Adding more Categories "
searchList$(8) = " "
searchList$(9) = " To the Search Engine"
searchList$(10) = " "
searchList$(11) = " Using the CheckBoxes"
searchList$(12) = " "
searchList$(13) = " "
searchList$(14) = " "
searchList$(15) = " If text doesn't Appear when Typed"
searchList$(16) = " "
searchList$(17) = " Click Go"
searchList$(18) = " or"
searchList$(19) = " Press the [Enter] Key"
searchList$(20) = " "
searchList$(21) = " "
searchList$(22) = " "
searchList$(23) = " To Visit the Just Basic Forums"
searchList$(24) = " "
searchList$(25) = " Just Click the Link Below"
searchList$(26) = " "
searchList$(27) = " https://justbasiccom.proboards.com/"
searchList$(28) = " "
searchList$(29) = " "
searchList$(30) = " "
#results.listbox2 "reload"
cursor normal
goto [search]
end if
'sort the list of possible results
sort oneOf$(), 0, count
dim b$(count+1)
happened$="|"
K = 0
'filter out the false Titles (Due to differences in html help pages source code - Title not on same line in all files)
for i = 0 to count
name$ = oneOf$(i)
if right$(name$, 1) = ">" or right$(name$, 6) = "window" or left$(name$, 5) = "H_ame" or right$(name$, 8) = "position"_
or left$(name$, 5) = "H_GCO" or right$(name$, 1) = ":" or left$(name$, 3) = "H_<" _
or left$(name$, 3) = "H_"+chr$(39) or right$(name$, 1) = "." or right$(name$, 1) = " " or right$(name$, 8) = "[branch]"_
or right$(name$, 3) = "] )" or right$(name$, 3) = "] ]" or right$(name$, 6) = "items)" or name$ = "H_WHILE...WEND"_
or right$(name$, 5) = "size)" or right$(name$, 1) = ";" or right$(name$, 5) = "LEN=n" or right$(name$, 7) = "number)" _
or right$(name$, 7) = "#handle" or right$(name$, 4) = "varN" or right$(name$, 4) = "...)" or right$(name$, 2) = "];" _
or right$(name$, 1) = "v" or right$(name$, 8) = "fontSpec" or right$(name$, 7) = "expr2 )" or right$(name$, 2) = "))"_
or right$(name$, 12) = "variableName" or right$(name$, 4) = "num2"or right$(name$, 5) = ".bmp"+chr$(34)_
or right$(name$, 2) = chr$(34)+")" or right$(name$, 4) = "var"+chr$(36) or right$(name$, 4) = ",n])"_
or right$(name$, 4) = "expr" or right$(name$, 4) = "num2" or right$(name$, 9) = chr$(34)+"refresh"+chr$(34)_
or right$(name$, 3) = "g])" or right$(name$, 6) = "Label]" or right$(name$, 8) = "#handle)" or right$(name$, 9) = "String$ )"_
or right$(name$, 11) = "Expression)" or right$(name$, 10) = "expression" or right$(name$, 9) = "[number])"_
or right$(name$, 7) = "struct)" or right$(name$, 7) = "comment" or right$(name$, 12) = "recordNumber"_
or right$(name$, 5) = "size)" or right$(name$, 6) = "follow" or right$(name$, 6) = "mode ]" or right$(name$, 8) = "number )" or name$ = "H_TRACE number"_
or right$(name$, 8) = "[column]" or right$(name$, 10) = "#handle, n" or right$(name$, 2) = " 1" or right$((left$(name$, 7)), 5) = chr$(34)+"Font"_
or right$(name$, 9) = "{LEN = n}" or right$(name$, 5) = "Expr2" or right$(name$, 6) = "length"_
or right$(name$, 10) = "#newHandle" or right$(name$, 12) = "columns rows" or right$(name$, 5) = "Expr$"_
or left$(name$, 4) = "var =" or right$(name$, 6) = "xpr2 )" or left$(name$, 3) = "H_(" or right$(name$, 6) = chr$(34)+"name"+chr$(34) _
or right$(name$, 4) = "#h )" or right$(name$, 9) = "#handle )" or right$(name$, 1) = "€" or right$(name$, 1) = "."_
or name$ = "H_DO LOOP" or name$ = "H_FOR...NEXT" or name$ = "H_IF...THEN" or name$ = "H_Winstring" or right$(name$, 8) = "value"+chr$(34)+" )"_
or right$(name$,1) = "?" or right$(name$,3) = "c$)" or right$(name$,8) = "Keywords" or name$ ="H_BOOLEAN"_
or left$(name$, 3) = "H_&" or left$(name$, 11) = "H_Uninstall" or name$ = "H_" or name$= "H_var = MIDIPOS( )" or nmae$ = "H_TRACE ( number )"_
or name$ = "H_StartupDir" or name$ = "H_EVAL" or name$ = "H_EVAL$" or right$(name$, 4) = "face"_
or name$ = "H_REPLSTR" or name$ = "H_UPPER$(s)" or name$ = "H_LOWER$(s$)" then
oneOf$(i) = ""
end if
'remove any duplicates from search list (Thanks to tsh73)
if instr(oneOf$(i), "Liberty") then oneOf$(i) = replace$(name$, "Liberty", "Just")
if lower$(nameLast$) = lower$(name$) then oneOf$(i) = ""
if instr(happened$, "|";oneOf$(i);"|")=0 then
happened$=happened$;oneOf$(i);"|"
K=K+1: b$(K)=oneOf$(i)
end if
nameLast$ = name$
next i
'Create final list of search results
for x = 0 to K
if lower$(word$(b$(x), 2, "_")) = lower$(searchFor$) then match$ = b$(x)
if instr(lower$(b$(x)), lower$(searchFor$)) _
and lower$(mid$(b$(x), 3, len(searchFor$))) = lower$(searchFor$)_
or lower$(mid$(b$(x), 4, len(searchFor$))) = lower$(searchFor$) then_
searchList$(u+7) = b$(x) : u = u+1
next x
for t = 0 to K
if instr(lower$(b$(t)), lower$(searchFor$)) then
if lower$(mid$(b$(t), 3, len(searchFor$))) <> lower$(searchFor$)_
and lower$(mid$(b$(t), 4, len(searchFor$))) <> lower$(searchFor$) then
searchList$(u+v+16) = b$(t) : v = v+1
end if
end if
next t
for a = 0 to K
if not(instr(lower$(b$(a)), lower$(searchFor$))) then_
searchList$(u+v+w+23) = b$(a) : w = w+1
next a
'manage the headers
searchList$(0) = " Search Results"
searchList$(1) = " "
searchList$(2) = " ";u+v;" Titles Containing ";q$;upper$(searchFor$);q$
if u+v <> 0 then searchList$(3) = " "
if u+v = 0 then searchList$(2) = " No Titles Found for ";q$;upper$(searchFor$);q$';" Found"
searchList$(4) = " "
if u <> 0 and v<>0 then searchList$(5) = " ";u;" Top Picks For ";q$;upper$(searchFor$);q$
searchList$(u+11) =" "
if v <> 0 and v<>u+v then searchList$(u+13) = " ";v;" Remaining Titles "'
if v <> 0 then searchList$(u+14) =" "
if v <> 0 then searchList$(v+u+19) = " "
if w-2 <> 0 then searchList$(v+u+20) = " ";w-2;" Other Pages Containing ";upper$(searchFor$)
if u+v = 0 then searchList$(v+u+20) = " ";w-2;" Pages Containing ";upper$(searchFor$)
searchList$(v+u+21) = " "
searchList$(v+u+w+22) = " "
searchList$(v+u+w+23) = " If you need more information "
searchList$(v+u+w+24) = " on "
searchList$(v+u+w+25) = " Just Basic v2.0 Coding "
searchList$(v+u+w+26) = " "
searchList$(v+u+w+27) = " Please Visit"
searchList$(v+u+w+28) = " "
searchList$(v+u+w+29) = " The Just Basic Forums by"
searchList$(v+u+w+30) = " "
searchList$(v+u+w+31) = " Clicking the link Below"
searchList$(v+u+w+32) = " "
searchList$(v+u+w+33) = " https://justbasiccom.proboards.com/"
searchList$(v+u+w+34) = " "
searchList$(v+u+w+35) = " If your text Does Not appear when typed"
searchList$(v+u+w+36) = " "
searchList$(v+u+w+37) = " Click Go"
searchList$(v+u+w+38) = " or"
searchList$(v+u+w+39) = " Press the [Enter] Key"
searchList$(v+u+w+40) = " "
searchList$(v+u+w+41) = " "
searchList$(v+u+w+42) = " Or you can type into the textbox manually"
searchList$(v+u+w+43) = " "
searchList$(v+u+w+44) = " "
'if there is a match with the search result
if match$ <> "" then searchList$(4) = " 1 Match "
#results.listbox2 "reload"
'finished displaying results - reset variables - cursor back to normal
[doneSearching]
u = 0 : v = 0 : w = 0 : match$ = "" : count = 0
cursor normal
goto [search]
'One of the Help Search results was Selected - Open the Help File in user's default browser
[openFile]
if jbHelp = 1 then
#results.listbox2 "selection? selectionH$"
selectionH$ = right$(selectionH$, len(selectionH$) - 2)
if selectionH$ = "XOR" or selectionH$ = "AND" or selectionH$ = "NOT" or selectionH$ = "OR" then
run "explorer.exe ";helpFilePath$;"\html\libe0azy.htm"
goto [search]
end if
files helpFilePath$;"\html", info$()
numFiles = val(info$(0,0 ))
for i = 1 to numFiles
fileToOpen$ = info$(i, 0)
open helpFilePath$;"\html\";fileToOpen$ for input as #3
contents$ = input$(#3, lof(#3)) : close #3
if instr(lower$(contents$), lower$("<title>";selectionH$;"</TITLE>")) then
if fileToOpen$ = "idecode451.html" then fileToOpen$ = "libe0ze8.htm"
if fileExists(DefaultDir$, "htmlviewer.exe") <> 0 then run "htmlviewer.exe ";helpFilePath$;"\html\";fileToOpen$ : done = 1_
else_
run "explorer.exe ";helpFilePath$;"\html\";fileToOpen$ : done = 1
if done = 1 then exit for
else
if done = 1 then [search]
if instr(lower$(contents$), lower$("</A><B>";selectionH$;"</B></P>")) then
if fileExists(DefaultDir$, "htmlviewer.exe") <> 0 then run "htmlviewer.exe ";helpFilePath$;"\html\";fileToOpen$ : done = 1_
else_
run "explorer.exe ";helpFilePath$;"\html\";fileToOpen$ : done = 1
if done = 1 then exit for
end if
end if
next i
if done = 1 then [search]
end if
'if a tutorial file was selected
if tutorial = 1 then
#results.listbox2 "selection? selectionT$" : print selectionT$
selectionT$ = right$(selectionT$, len(selectionT$) - 2)
if selectionT$ = "Let's Write a Program - HILO.BAS" then selectionT$ = "lets_write_hilo"
if fileExists(tutorialPath$, selectionT$;".html") then
run "explorer.exe ";tutorialPath$;"\";selectionT$;".html" : goto [search]
end if
end if
if tuttext = 1 then
#results.listbox2 "selection? selectionT$" : print selectionT$
selectionT$ = right$(selectionT$, len(selectionT$) - 3)
if fileExists(tutorialEditPage$, selectionT$;".TXT") then
run "C:\Program Files\Windows NT\Accessories\wordpad.exe ";q$;tutorialEditPage$;"\";selectionT$;".TXT";q$ : goto [search]
end if
end if
if tutcode = 1 then
#results.listbox2 "selection? selectionT$" : print selectionT$
selectionT$ = right$(selectionT$, len(selectionT$) - 3)
if fileExists(tutorialEditPage$, selectionT$;".BAS") then
run jbexe$;" ";tutorialEditPage$;"\";selectionT$;".BAS": goto [search]
end if
end if
'if a freeform help file was selected
if freeForm = 1 then
#results.listbox2 "selection? selectionF$"
selectionF$ = right$(selectionF$, len(selectionF$) - 2)
files freeformPath$, info$()
numFiles = val(info$(0,0 ))
for i = 1 to numFiles
x = 1
fileToOpen$ = info$(i, 0)
open freeformPath$;"\";fileToOpen$ for input as #3
contents$ = input$(#3, lof(#3)) : close #3
if instr(lower$(contents$), lower$("<title>";selectionF$;"</title>")) then
if fileExists(DefaultDir$, "htmlviewer.exe") <> 0 then run "htmlviewer.exe ";freeformPath$; "\"; fileToOpen$_
else_
run "explorer.exe ";freeformPath$;"\";fileToOpen$ : done = 1
end if
if done = 1 then exit for
next i
if done = 1 then [search]
end if
'if a Code Example file was selected
if jbexamples = 1 then
#results.listbox2 "selection? selectionCE$"
selectionCE$ = right$(selectionCE$, len(selectionCE$) - 3)
if fileExists(DefaultDir$;"\Just Basic v2.0", selectionCE$;".bas") then
run jbexe$;" ";DefaultDir$;"\Just Basic v2.0\";selectionCE$;".bas" : goto [search]
end if
end if
'if a Code Function file was selected
if jbfunctions = 1 then
#results.listbox2 "selection? selectionCF$"
selectionCF$ = right$(selectionCF$, len(selectionCF$) - 3)
if fileExists(DefaultDir$;"\Just Basic v2.0\FFFunctions", selectionCF$;".txt") <> 0 then
run jbexe$;" ";DefaultDir$;"\Just Basic v2.0\FFFunctions\";selectionCF$;".txt" : goto [search]
end if
end if
'if the link to the Just basic Forums is clicked (link at bottom of search results)
#results.listbox2 "selection? selection$"
if selection$ = " https://justbasiccom.proboards.com/" then_
selection$ = right$(selection$, len(selection$)-9) : run "explorer ";selection$ : goto [search]
goto [search]
[mainList]
#mainList.listbox1 "selection? h$"
fileToOpen$= word$( h$,2,chr$(0))
fileToOpen$=replace$( fileToOpen$ , "/", "\" )
if fileExists(DefaultDir$, "htmlviewer.exe") <> 0 then run "htmlviewer.exe ";helpFilePath$; "\"; fileToOpen$_
else_
if fileExists(helpFilePath$, fileToOpen$) <> 0 then run "explorer.exe ";helpFilePath$; "\"; fileToOpen$
goto [search]
[tutorialList]
#tutorialList.listbox3 "selection? h$"
fileToOpen$= word$( h$,2,chr$(0))
fileToOpen$=replace$( fileToOpen$ , "/", "\" ) :print fileToOpen$
if fileExists(DefaultDir$, "htmlviewer.exe") <> 0 then run "htmlviewer.exe ";tutorialPath$; "\"; fileToOpen$_
else_
if fileExists(tutorialPath$, fileToOpen$) <> 0 then run "explorer.exe ";tutorialPath$; "\"; fileToOpen$
goto [search]
'show results
[results]
if resultsOpen = 1 then return
WindowWidth = 255 : WindowHeight = 500
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2+25)
listbox #results.listbox2, searchList$(, [openFile], 0, 0, 261, 600
button #results.default, "&GO", [search], UL, 0, 0, 0, 0
Open "JB HELP SEARCH RESULTS" for dialog as #results
resultsOpen = 1
#results "trapclose [quitResults]"
#results.listbox2 "reload"
#results.listbox2 "singleclickselect"
if fontsize <> 0 then fontsize = fontsize else fontsize = 9
#results.listbox2 "font Arial 0 ";fontsize+6
return
'show JB Help Menu
[Contents]
if mainListOpen = 1 then #mainList.default "!setfocus" : goto [search]
WindowWidth = 255 : WindowHeight = 500
UpperLeftX=int((DisplayWidth-WindowWidth)/2 - 275)
UpperLeftY=int((DisplayHeight-WindowHeight)/2 +25)
listbox #mainList.listbox1, mainList$(, [mainList], 0, 0, 261, 600
button #mainList.default, "&GO", [search], UL, 0, 0, 0, 0
Open "Just Basic v2.0 Help Menu" for dialog as #mainList
mainListOpen = 1
#mainList "trapclose [quitMainList]"
#mainList.listbox1 "singleclickselect"
#mainList.listbox1 "reload"
if fontsize <> 0 then fontsize = fontsize else fontsize = 9
#mainList.listbox1 "font Arial 0 ";fontsize+6
#main.tb "!setfocus"
wait
'show JB Tutorial
[jbtutorial]
redim tutorialList$(1000)
tutorialPath$ = jbPath$;"\jbtutorial"
tutorialFileMenu$ = "index.html"
open tutorialPath$; "\";tutorialFileMenu$ for input as #1
txt$ = input$(#1, lof(#1))
close #1
'Load the "Tutorial" menu list array
lowerTxt$= lower$(txt$)
while 1
scan
startAt = c+1
a = instr(lowerTxt$, "href",startAt)
b = instr(lowerTxt$, ">",a+1)
c = instr(lowerTxt$, "</a>",b+1)
if a=0 or b=0 or c= 0 then exit while
hrefA= instr(lowerTxt$,chr$(34),a+1)
hrefB= instr(lowerTxt$,chr$(34),hrefA+1)
idx = idx +1
tutorialList$(idx)= trim$(mid$(txt$,b+1,c-b-1));chr$(0);_
trim$(mid$(txt$,hrefA+1,hrefB-hrefA-1))
wend
if tutorialListOpen = 1 then #mainList.default "!setfocus" : goto [search]
WindowWidth = 255 : WindowHeight = 500
UpperLeftX=int((DisplayWidth-WindowWidth)/2 + 275)
UpperLeftY=int((DisplayHeight-WindowHeight)/2 +25)
listbox #tutorialList.listbox3, tutorialList$(, [tutorialList], 0, 0, 261, 600
button #tutorialList.default, "&GO", [search], UL, 0, 0, 0, 0
Open "Just Basic Tutorial Menu" for dialog as #tutorialList
tutorialListOpen = 1
#tutorialList "trapclose [quittutorialList]"
#tutorialList.listbox3 "singleclickselect"
#tutorialList.listbox3 "reload"
if fontsize <> 0 then fontsize = fontsize else fontsize = 9
#tutorialList.listbox3 "font Arial 0 ";fontsize+6
#main.tb "!setfocus"
wait
'resize window font - sets all Listbox fonts equal
[incFont]
fontsize = fontsize + 1
if resultsOpen = 1 then #results.listbox2 "font Arial 0 ";fontsize+6 : #main.tb "!setfocus"
if mainListOpen = 1 then #mainList.listbox1 "font Arial 0 ";fontsize+6 : #main.tb "!setfocus"
if tutorialListOpen = 1 then #tutorialList.listbox3 "font Arial 0 ";fontsize+6 : #main.tb "!setfocus"
wait
[decFont]
fontsize = fontsize - 1
if resultsOpen = 1 then #results.listbox2 "font Arial 0 ";fontsize+6 : #main.tb "!setfocus"
if mainListOpen = 1 then #mainList.listbox1 "font Arial 0 ";fontsize+6 : #main.tb "!setfocus"
if tutorialListOpen = 1 then #tutorialList.listbox3 "font Arial 0 ";fontsize+6 : #main.tb "!setfocus"
wait
'set and reset checkboxes for search categories
[freeForm] freeForm = 1 : #main.tb "!setfocus" : wait
[nofreeForm] freeForm = 0 : #main.tb "!setfocus" : wait
[jbHelp] jbHelp = 1 : #main.tb "!setfocus" : wait
[nojbHelp] jbHelp = 0 : #main.tb "!setfocus" : wait
[tutorial] tutorial = 1 : #main.tb "!setfocus" : wait
[noTutorial] tutorial = 0 : #main.tb "!setfocus" : wait'
[tutcode] tutcode = 1 : #main.tb "!setfocus" : wait
[notutcode] tutcode = 0 : #main.tb "!setfocus" : wait
[tuttext] tuttext = 1 : #main.tb "!setfocus" : wait
[notuttext] tuttext = 0 : #main.tb "!setfocus" : wait
[jbexamples] jbexamples = 1 : #main.tb "!setfocus" : wait
[nojbexamples] jbexamples = 0 : #main.tb "!setfocus" : wait
[jbfunctions] jbfunctions = 1 : #main.tb "!setfocus" : wait
[nojbfunctions] jbfunctions = 0 : #main.tb "!setfocus" : wait
[codebank] codebank = 1 : #main.tb "!setfocus" : wait
[nocodebank] codebank = 0 : #main.tb "!setfocus" : wait
'The [Help] - help button for this program was pressed
[help]
notice " Tiny JB-Search Help File";_
CHR$(13);CHR$(13);_
"Type your Search Word ( no char minimum ), and hit [Enter]";_
" If your text doesn't appear at any time, just hit [Enter] and start typing agin";_
CHR$(13);_
" No Need to place the cursor in the Search box. - Repeat the above for Next Search";_
CHR$(13);_
"Search results are marked to indicate the category they represent";_
CHR$(13);_
CHR$(13);" CHECKBOXES and CATEGORIES: ";_
CHR$(13);_
"H= JB Help, T= JB Tutorial, F= JB Freeform, CF= JB Code Functions, CE= JB Code Examples,";_
CHR$(13);_
CHR$(13);_
"CT= JB Tutorial HomeWork Code pages, TT= JB Tutorial HomeWork Text Pages";_
CHR$(13);_
"Results marked H T & F open help pages in your default browser";_
CHR$(13);_
"C stands for code - Results marked CE, CF and CT open in Just Basic";_
CHR$(13);CHR$(13);_
"Results marked TT - open in Wordpad.";_
CHR$(13);CHR$(13);_
"Escape Key closes the open window with focus(focus remains with small window";_
" unless another window is clicked on, including the windows scroll bar)";_
CHR$(13);CHR$(13);_
"If Results Window is Open, + or - to Adjust Font Size or *";_
CHR$(13);CHR$(13);_
CHR$(13);CHR$(13);" ADDING TO the JUST BASIC RUN MENU";_
CHR$(13);CHR$(13);_
"How to ADD to the Just BASIC menu under - Run > External Programs for easy access.";_
CHR$(13);_
"1) To Make the TKN file goto: Run menu > Make *.tkn File.";_
" Use any name for the file when the -File Save As- window opens";_
" Remember the File Location, and Name of the File.";_
CHR$(13);_
"2) In Just Basic Select the menu item: Setup > External Programs";_
CHR$(13);_
"3) Click on the New button, choose a name of your liking to create a new item.";_
" This is the name that will appear under JB's Run menu. Choose a descriptive name.";_
CHR$(13);_
"4) Select Created item.";_
CHR$(13);_
"5) Click on the Browse Button, then navigate to the .tkn File created in step 1.";_
CHR$(13);_
"6) Just BASIC will inform you changes take effect after restarting Just Basic."
#main.tb "!setfocus"
wait
[quittutorialList]
close #tutorialList : tutorialListOpen = 0
goto [search]
[quitMainList]
close #mainList : mainListOpen = 0
goto [search]
'close results window
[quitResults]
close #results : resultsOpen = 0
goto [search]
'end program - close all open windows
[quit]
if tutorialListOpen = 1 then close #tutorialList : tutorialListOpen = 0
if resultsOpen = 1 then close #results : resultsOpen = 0
if mainListOpen = 1 then close #mainList : mainListOpen = 0
close #main
end
'get users homepath = aka %userprofile% = "c:\users\xxxxx" (5 characters long normally Win 10)
sub getUserPath
run "cmd.exe /c echo %userprofile% >UserHomePath.txt", HIDE
do
scan
loop until fileExists(DefaultDir$, "UserHomePath.txt")
open "UserHomePath.txt" for input as #1
upath$ = input$(#1, lof(#1))
close #1
if upath$ = "" then notice "Sorry, can't find user path " : end
kill DefaultDir$;"\UserHomePath.txt"
end sub
'create a pause subroutine
sub pause mil
t=time$("ms")+mil
while time$("ms")<t
scan
wend
end sub
'function for checking folder existence
function pathExists(path$)
pathExists = (mkdir(path$)=183)
end function
'Verify file existence function
function fileExists(path$, filename$)
dim fileExistsInfo$(0,0)
files path$, filename$, fileExistsInfo$()
fileExists = val(fileExistsInfo$(0, 0)) 'non zero is true
end function
'Replace a word in a string function
function replace$( text$ , this$, tothis$ )
while 1
if instr(text$, this$) then
f = instr(text$, this$)
lenght=len(this$)
text$ = mid$(text$,1,f-1);_
tothis$;mid$(text$,f+lenght)
else
exit while
end if
wend
replace$=text$
end function
' Copy Folder Function - Can't pin down the author = Probably Stefan Pendl or Mark Parkinson
' Possibly originally written by McKurt for Liberty Basic - edited by the others (including myself xxgeek)
' Found here - http://libertybasic.fr/forum/search.php?token=9a4c973fae57752e (French LB Forum)
function CopyFolder(StartFolder$, EndFolder$)
dim Info$(1,1)
call SearchFolders StartFolder$, EndFolder$
end function
sub SearchFolders Folder$, Folder2$
'prevent copying help folder for XP
if ndswith(Folder$,"\jb2help") or ndswith(Folder$,"\jbtutorial") then exit sub
'same for the JB bak folder
if ndswith(Folder$,"\bak") then exit sub
files Folder$, Info$(
numSubFolders = val(Info$(0,1))
numFiles = val(Info$(0,0))
for count = 1 to numSubFolders
if FoundFolders$ = "" then
CopyFolders$ = Folder2$; "\" ; Info$(numFiles + count,1)
FoundFolders$ = Info$(0,2); Info$(0,3); Info$(numFiles + count,1)
else
FoundFolders$ = FoundFolders$; ";" ; Info$(0,2); Info$(0,3); Info$(numFiles + count,1)
CopyFolders$ = CopyFolders$; ";" ; Folder2$ ; "\" ; Info$(numFiles + count,1)
end if
next
for count = 1 to numFiles
if FoundFiles$ = "" then
CopyFiles$ = Folder2$; "\" ; Info$(count,0)
FoundFiles$ = Info$(0,2); Info$(0,3); Info$(count,0)
else
FoundFiles$ = FoundFiles$; ";" ; Info$(0,2); Info$(0,3); Info$(count,0)
CopyFiles$ = CopyFiles$; ";" ; Folder2$ ; "\" ; Info$(count,0)
end if
next
leftFolders = numSubFolders
while leftFolders > 0
call SearchFolders word$(FoundFolders$, leftFolders, ";" ), word$(CopyFolders$, leftFolders, ";" )
leftFolders = leftFolders - 1
wend
call CreateDir Folder2$
call CopyFile FoundFiles$, CopyFiles$, numFiles
end sub
sub CreateDir dPath$
[loop]
result=instr(dPath$, "\" ,result+1)
if result<>0 then
temp$=left$(dPath$,result)
r=mkdir(temp$)
goto [loop]
end if
r=mkdir(dPath$)
end sub
sub CopyFile sFiles$, dFiles$, numF
while numF > 0
FileS$ = word$(sFiles$, numF, ";" )
FileD$ = word$(dFiles$, numF, ";" )
call copy FileS$, FileD$
numF = numF - 1
wend
end sub
sub copy filepath$, newFilepath$
'skip EXE DLL SLL (for XP, it's in the same folder with examples)
if ndswith(filepath$,"exe") or ndswith(filepath$,"dll") or ndswith(filepath$,"sll")then exit sub
open filepath$ for input as #source
open newFilepath$ for output as #dest
#dest input$(#source, lof(#source))
close #source : close #dest
end sub
'When creating a file using CMD or a Visual Basic Script- file existence verification function
function waitForFile(path$, fileName$, timeOutMS)
dMS = 350
do while timeOutMS >0
call doDelay dMS
if fileExists(path$, fileName$) then
if val(fileExistsInfo$(1, 1))>0 then
waitForFile = 1: exit function
end if
end if
timeOutMS = timeOutMS - dMS
loop
waitForFile = 0
end function
'another delay sub
sub doDelay ms
timer ms, [delay] 'delay
wait
[delay]
timer 0
end sub
'Get the users system environment variables
function getEnvVar$(EnvVar$)
getEnvVar$ = ""
if fileExists(DefaultDir$, "env.txt") then kill "env.txt"
run "cmd.exe /c echo %"+EnvVar$+"% > env.txt", hide
if waitForFile(DefaultDir$, "env.txt", 2000) then 'Waiting for CMD to create the file env.txt
open "env.txt" for input as #1
line input #1, out$
close #1
getEnvVar$ = trim$(out$)
else
print "Sorry - was not able to get var value"
exit function
end if
kill DefaultDir$;"\env.txt"
end function
'get Windows version
function getWinVersion$()
getWinVersion$ = ""
if fileExists(DefaultDir$, "env.txt") then kill "env.txt"
run "cmd.exe /c ver > env.txt", hide
if waitForFile(DefaultDir$, "env.txt", 2000) then
open "env.txt" for input as #1
out$ = input$(#1,lof(#1)) '! this command outputs empty line first !
close #1
getWinVersion$ = trim$(out$)
else
print "Sorry - was not able to get var value"
exit function
end if
end function
function ndswith(path$,end$)
ndswith = right$(path$, len(end$)) = end$
end function