|
Post by xxgeek on Aug 17, 2023 19:01:00 GMT -5
Thanks Walt, I missed that. I did have an ini created to save the LBpath$, I must have removed it on my version and forgot to put it back. I'm waiting for tsh73 to tell me it won't work in Windows 1.0 Not sure what you mean here Walt. There is no 'files' button, and the only other button like 'files' is the 'File' button on the top menu. I tried it and it's working ok for me. Or is it the New (from file) button? That seems to be working too. Please elaborate on this. Again not sure what you mean. What file? All data from the texteditor gets saved on exit to the appropriate 'dictionary' file, and everytime you see 'call saveValue' in the code, which happens anytime a new radiobutton is chosen among other times.. I've been trying to keep everything automated, with minimal user intervention, to avoid file placement errors etc. I want all files and folders created in the DefaultDir$, and I want the app to know where things are without having to look around for them. Best way I know of doing that is have the app control where they go. Users can always do what they want aside from the app. As for (4) on error is there until codeTank passes the 'stable' and working test. So far it's just been myself doing any testing, when/if I run into an issue. Walt, is there a way using API/DLL or any native code to auto [Enter] for the 2 Windows that come up when creating a TKN file. ('save as' dialog, and Information on where the TKN is saved.) Currently codeTank writes a VB script and RUNs it to achieve this. Try this updated code, it now checks for an ini file with LBpath$ written to it, and if not it exists creates it for next RUN(s). LB Pro version only. I assume you have Pro? 'CodeTank Plus v1.0 'created by xxgeek Aug 2023 'This app uses "Dictionary" code, written by Carl Gundel, at it's core - edited to suit this app
'Purposes - ' (1) To create reservoir(s) of code, subs, functions, scripts and example programs with ability to share_ '_ with others each category file, to merge with their own reservoir(s).
' (2) To automate the collection of support dll and sll files along with TKN file creation and renaming_ '_ of the run451.exe
' (3) To create dated\timestamped backups of each .bas file, and a .tkn backup file of each .bas_ '_ file to 'Revert' back if\when needed.
' Please Note: ' When selecting a .bas file to create a New Project, or Program....... ' Make sure the .bas file is a known good one, and runs/starts ok in the LB IDE ' If the .bas file cannot pass the compiler's check, it can cause havoc with the automation ' process, and probably crash CodeTank.
'For help using CodeTank visit the Liberty Basic forums ' @ https://libertybasiccom.proboards.com/
on error goto [abort] nomainwin global selectedKey$, fixeddate$, fixedtime$, project, fnamenobas$, DestPath$, DestPath1$, FolderDialog$, JBexe$, _LBpath$, dictionary$, keyCount, q$, lastKey$, categorie$, selectedpath$, upath$, folder$ call getUserPath uAppPath$ = upath$;"\AppData\Roaming\Liberty Basic Pro v4.5.1" if fileExists(DefaultDir$, "codetankPro.ini") then open "codetankPro.ini" for input as #1 line input #1, LBpath$ : close #1 LBpath$ = trim$(LBpath$) goto [start] end if LBpath$="c:\Program Files (x86)\Liberty Basic Pro v4.5.1" 'if Liberty Basic v4.5.1 is NOT installed to it's Default Install Dir, get Path from User using folder dialog if pathExists(LBpath$) <> 0 then [start] else notice chr$(13)+" Liberty Basic Pro v4.5.1 was not installed to the default install folder." +chr$(13)+"Hit [ok], then Select the Folder Liberty Basic v4.5.1 is Installed" caption$ = "Select your Liberty Basic Pro v4.5.1 install Dir" a$ = FolderDialog$(caption$) if right$(FolderDialog$, 1) = "\" then FolderDialog$ = left$(FolderDialog$, len(FolderDialog$)-1) if FolderDialog$ = "" then notice "Liberty Basic must be installed to continue" : end LBpath$ = FolderDialog$ open "codetankPro.ini" for output as #1 #1 LBpath$ : close #1 [start] 'dim arrays for key$ and info$ dim key$(1000) dim info$(500, 500) 'declare variables q$ = chr$(34) LBexe$ = "lbpro.exe" : LBruntime$ = "run451.exe" DllList$="vbas31w.sll vgui31w.sll voflr31w.sll vthk31w.dll vtk1631w.dll vtk3231w.dll vvm31w.dll vvmt31w.dll" savedProjects$ = "savedProjects" MyProjects$ = "MyProjects" MyBackups$ = "MyBackups" programs$ = "Programs" vbs$ = "VBS-Scripts" cmd$ = "CMD-Scripts" examples$ = "Examples" snippets$ = "Snippets" lbExamples$ = "LB-Examples" lbBakFiles$ = "LB-BAK-Files" subroutines$ = "Subroutines" functions$ = "Functions"
'Create the form - open the window - set some fonts WindowWidth = 1000 : WindowHeight = 600 UpperLeftX= int((DisplayWidth-WindowWidth)/2) UpperLeftY= int((DisplayHeight-WindowHeight)/2) BackgroundColor$ = "lightgray" ForegroundColor$ = "black"
'top menu menu #CodeTank, "File" , "Open Liberty Basic", [openlb], "Open a File in Liberty Basic", [openlbFile], "Exit", [quit.CodeTank] menu #CodeTank, "Edit" menu #CodeTank, "Browse" , "My Projects", [projectsDir], ".TKN Files", [tknDir], ".BAS Files", [basFiles],"DefaultDir$", [defaultDir],"LB Pro Example Files", [lbexamplesDir] menu #CodeTank, "Help" , "Liberty Basic Forums", [forumlink], "Help", [CodeTankHelp], "About", [about]
texteditor #CodeTank.value, 400, 25, 575, 475 listbox #CodeTank.keys, keys$(), [keySelected], 90, 25, 310, 370
'category radio buttons radiobutton #CodeTank.savedprojects, MyProjects$, [projs], resetHandler, 5, 75, 75, 20 radiobutton #CodeTank.programs, "My";programs$, [progs], resetHandler, 5, 95, 75, 20 radiobutton #CodeTank.backups, MyBackups$, [mybackups], resetHandler, 5, 115, 75, 20 radiobutton #CodeTank.examples, examples$, [exams], resetHandler, 5, 165, 80, 20 radiobutton #CodeTank.snippets, snippets$, [snipps], resetHandler, 5, 185, 80, 20 radiobutton #CodeTank.subroutines, subroutines$, [subroutines], resetHandler, 5, 205, 80, 20 radiobutton #CodeTank.functions, functions$, [functions], resetHandler, 5, 225, 80, 20 radiobutton #CodeTank.VBS, vbs$, [vbs], resetHandler, 5, 245, 80, 20 radiobutton #CodeTank.CMD, cmd$, [cmd], resetHandler, 5, 265, 80, 20 radiobutton #CodeTank.lbexamples, lbExamples$, [lbCodeExamples], resetHandler, 5, 315, 80, 20 radiobutton #CodeTank.lbbakfiles, lbBakFiles$, [lbbakfiles], resetHandler, 5, 335, 80, 20 radiobutton #CodeTank.folderChoice, "Any Folder", [folderChoice], resetHandler, 5, 375, 80, 20 'buttons bottom left , top, and middle button #CodeTank.addListing, "New ";left$(categorie$, (len(categorie$) - 1)), [newKey], ul, 245, 405, 140, 20 button #CodeTank.fromFile, "&New from &File", [makeproject], ul, 95, 405, 140, 20 button #CodeTank.remakeproject, "&Update TKN File", [remakeproject], ul, 95, 455, 140, 20 button #CodeTank.runlb, "&Edit in Liberty Basic", [edit_In_LB_IDE], ul, 95, 430, 140, 20 button #CodeTank.merge, "&Merge Shared File ";categorie$, [mergeFile], ul, 245, 455, 140, 20 button #CodeTank.runListing, "&Run", [runKey], ul, 245, 430, 140, 20 button #CodeTank.revert, "Re&vert to Backup", [revert], ul, 95, 480, 140, 20 button #CodeTank.deleteListing, " &Delete ", [deleteKey], ul, 245, 480, 140, 20 textbox #CodeTank.filePath, 190,2, 785, 22 statictext #CodeTank.categories, "Categories", 10, 40, 75, 15 statictext #CodeTank.pathText, "Currently Viewing", 100, 8, 95, 15 button #CodeTank.incFont, "&+", [incFont], UL, 25, 470, 20, 23 button #CodeTank.decFont, "&-", [decFont], UL, 50, 470, 20, 23 open " CodeTank Plus v1.0 " for window as #CodeTank #CodeTank "trapclose [quit.CodeTank]" #CodeTank.categories "!font arial 10 bold" #CodeTank.addListing "!disable" #CodeTank.deleteListing "!disable" #CodeTank.remakeproject "!disable" #CodeTank.runListing "!disable" #CodeTank.runlb "!disable" #CodeTank.fromFile "!disable" #CodeTank.merge "!disable" #CodeTank.revert "!disable" #CodeTank.keys "singleclickselect" #CodeTank.value "!autoresize" CodeTankOpen = 1 wait
[abort] text$ = "An Error Has Occured";chr$(13);"Error #";Err;" ";Err$;" ";chr$(13);chr$(13);"CodeTank will need to Shutdown" a$ = custcon$(text$) goto [quit.CodeTank]
[newKey] 'ask the user for a name for the new listing call saveValue newKey$ = "" if len(left$(categorie$, (len(categorie$) - 1))) < 4 then [notPlural] prompt "Enter a Name (or Title) for the New " + left$(categorie$,(len(categorie$)-1)); newKey$ if newKey$ <> "" then [continue] else wait
[notPlural] prompt "Enter a Name (or Title) for the New "+categorie$+" Script"; newKey$ if newKey$ = "" then wait
'if user selects 'New From File' instead of New (copy/paste) to add new Project, or new Program [continue] if newKey$ <> "" then call setValueByName newKey$, "" call loadKeys #CodeTank.keys "select "; newKey$ #CodeTank.value "!cls"; call collectGarbage call writeDictionary lastKey$ = newKey$ end if if tkn = 2 or tkn = 4 then open fname$ for input as #1 open categorie$ for append as #2 #2 input$(#1, lof(#1)); close #1 close #2 call cleanup tkn = 0 end if call saveValue call readDictionary call loadKeys #CodeTank.keys "select 0" #CodeTank.value "!setfocus" if pleasewaitOpen = 1 then close #pleasewait : pleasewaitOpen = 0 wait
'an item in the list was selected [keySelected] call saveValue #CodeTank.keys "selection? selectedKey$" if categorie$ = examples$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";examples$;" Section - ";selectedKey$ if categorie$ = snippets$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";snippets$;" Section - ";selectedKey$ if categorie$ = cmd$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";cmd$;" Section - ";selectedKey$ if categorie$ = vbs$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";vbs$;" Section - ";selectedKey$ if categorie$ = subroutines$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";subroutines$;" Section - ";selectedKey$ if categorie$ = functions$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";functions$;" Section - ";selectedKey$ if categorie$ = MyProjects$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";MyProjects$;" File - ";savedProjects$;"\";selectedKey$;"\";selectedKey$;".bas" #CodeTank.value "!cls" if fileExists(savedProjects$;"\";selectedKey$, selectedKey$;".bas") then open savedProjects$;"\";selectedKey$;"\";selectedKey$;".bas" for input as #1 code$ = input$(#1, lof(#1)) #CodeTank.value "!contents code$"; close #1 else goto [getCode] end if #CodeTank.value, "!origin 0 0" wait end if if categorie$ = programs$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";programs$;" File - ";savedProjects$;"\";selectedKey$;"\";selectedKey$;".bas" #CodeTank.value "!cls" if fileExists(DefaultDir$;"\";savedProjects$;"\";selectedKey$, selectedKey$;".bas") then open DefaultDir$;"\";savedProjects$;"\";selectedKey$;"\";selectedKey$;".bas" for input as #1 code$ = input$(#1, lof(#1)) close #1 #CodeTank.value "!contents code$"; else goto [getCode] end if #CodeTank.value, "!origin 0 0" wait end if if categorie$ = lbExamples$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";lbExamples$;" File - ";upath$;"\Application Data\Liberty Basic v4.5.1\";selectedKey$;".bas" open upath$;"\Application Data\Liberty Basic v4.5.1\";selectedKey$;".bas" for input as #1 code$ = input$(#1, lof(#1)) #CodeTank.value "!contents code$"; close #1 #CodeTank.value, "!origin 0 0" wait end if if categorie$ = lbBakFiles$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";lbBakFiles$;" File - ";upath$;"\Application Data\Liberty Basic v4.5.1\;bak\";selectedKey$;".bak" #CodeTank.value "!cls" open upath$;"\Application Data\Liberty Basic v4.5.1\bak\";selectedKey$;".bak" for input as #1 code$ = input$(#1, lof(#1)) close #1 #CodeTank.value "!contents code$"; #CodeTank.value, "!origin 0 0" wait end if if categorie$ = folderChoice$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";folderChoice$;" File - ";folderpath$;"\";selectedKey$;".bas" #CodeTank.value "!cls" open folderpath$;"\";selectedKey$;".bas" for input as #1 code$ = input$(#1, lof(#1)) close #1 #CodeTank.value "!contents code$"; #CodeTank.value, "!origin 0 0" wait end if if categorie$ = MyBackups$ then #CodeTank.filePath "cls" : #CodeTank.filePath "Reading List ";MyBackups$;" File - ";"BAS\";selectedKey$;".bas" #CodeTank.value "!cls" open DefaultDir$;"\";"BAS\";selectedKey$;".bas" for input as #1 code$ = input$(#1, lof(#1)) close #1 #CodeTank.value "!contents code$" #CodeTank.value, "!origin 0 0" wait end if [getCode] selectedValue$ = getValue$(selectedKey$) #CodeTank.value "!contents selectedValue$"; lastKey$ = selectedKey$ #CodeTank.value, "!origin 0 0" wait
'delete a Listing [deleteKey] #CodeTank.keys "selection? selectedKey$" if selectedKey$ = "" then notice "Select an item from list, try again" : cursor normal : wait cursor hourglass call pleasewait : pleasewaitOpen = 1 conanswer$ = "" #CodeTank.filePath "cls" : #CodeTank.filePath "Erasing ";selectedKey$;" code from - ";categorie$ #CodeTank.value, "!selectall" #CodeTank.value, "!cut" #pleasewait.fake "!setfocus" call saveValue open categorie$ for input as #1 tempfile$ = "tempfile" open tempfile$ for output as #2 word1$ = chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134) + selectedKey$ + chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134) while eof(#1) = 0 line input #1, line$ if line$ = word1$ then [dontSave] #2, line$ [dontSave] wend close #1 close #2 if fileExists(DefaultDir$, categorie$) then kill DefaultDir$;"\";categorie$ name tempfile$ as categorie$ lastKey$ = "" call readDictionary call loadKeys call saveValue #CodeTank.keys "select 0" if pleasewaitOpen = 1 then pleasewaitOpen = 0 : close #pleasewait cursor normal if pathExists(DefaultDir$;"\";savedProjects$;"\";selectedKey$) <> 0 then folder$ = DefaultDir$;"\";savedProjects$;"\";selectedKey$ text$ = "Title: "+selectedKey$+chr$(13)+" Has been Deleted"+chr$(13)+chr$(13)+"Do you wish to delete the project folder as well?" a$ = custcon$(text$) if conanswer$ <> "yes" then wait a$ = delete$(folder$) end if wait
'run selected MyProjects, or MyProgram [runKey] if selectedKey$ = "" then notice "Select an item from list, try again" : wait if categorie$ = lbExamples$ then run LBpath$;"\";LBexe$;" -R -A ";uAppPath$;"\";selectedKey$;".bas" : wait if categorie$ <> MyProjects$ and fileExists(DefaultDir$;"\";savedProjects$;"\";selectedKey$, selectedKey$;".bas") <> 0 then runFile$ = DefaultDir$;"\";savedProjects$;"\";selectedKey$;"\";selectedKey$;".bas" run LBpath$;"\";LBexe$;" -R -A ";runFile$ wait end if if categorie$ = MyProjects$ and fileExists(DefaultDir$;"\";savedProjects$;"\";selectedKey$, selectedKey$;".exe") <> 0 then runFile$ = DefaultDir$;"\";savedProjects$;"\";selectedKey$;"\";selectedKey$;".exe" #CodeTank.filePath "cls" : #CodeTank.filePath "Running - ";DefaultDir$;"\";savedProjects$;"\";selectedKey$;"\";selectedKey$;".exe" run runFile$ else notice "Cannot be RUN"+chr$(13)+"This Title was Created Manually"+chr$(13)+selectedKey$+chr$(13)_ +" Not created using 'New from File'"+chr$(13)+chr$(13)_ +"Edit with Liberty Basic and save it as the same name."+chr$(13)+"Select Radio Button "+categorie$+chr$(13)+"Select Button [New from File]"+chr$(13)_ +"Select the .bas file you just saved."+chr$(13)+" It will be available to RUN from then on" end if #CodeTank.value "!cls" #CodeTank.keys "select 0" wait
'open selected listing in just Basic IDE [edit_In_LB_IDE] if selectedKey$ = "" then notice "Select an item from a list, try again" : wait runFile$ = DefaultDir$;"\";savedProjects$;"\";selectedKey$;"\";selectedKey$;".bas" res = fileExists(DefaultDir$;"\";savedProjects$;"\";selectedKey$, selectedKey$;".bas") if res then #CodeTank.filePath "cls" : #CodeTank.filePath "Editing ";runFile$;" in Liberty Basic Editor" run LBpath$;"\";LBexe$;" ";q$;runFile$;q$ else #CodeTank.value, "!contents? valueNow$"; open "untitled.bas" for output as #1 #1, valueNow$ close #1 tempfile$ = DefaultDir$;"\untitled.bas" run LBpath$;"\";LBexe$;" ";q$;tempfile$;q$ #CodeTank.filePath "cls" : #CodeTank.filePath "Editing ";tempfile$;" in Liberty Basic Editor" end if #CodeTank.keys "select 0" wait
[mergeFile] desktop$ = upath$;"\Desktop" filedialog "Select a ";categorie$ ;" file to merge ",desktop$; "\*.*", mergefile$ if mergefile$ = "" then wait answer$ = "no" a$ = GetFilename$(mergefile$) if a$ <> categorie$ then prompt " Categories Don't Match "+chr$(13)+a$+" and "+ categorie$+" Merge Anyway?" ; answer$ if answer$ <> "yes" then wait end if open mergefile$ for input as #1 line input #1, dataline$ : close #1 if mid$(dataline$, 4, 3) <> "key" then notice "Merge with ";categorie$+" Issue"+chr$(13)+chr$(13)+"Unable to Merge File named "+chr$(13)+a$+chr$(13)+"The formatting of file "+a$+" is incompatible" : wait call pleasewait : cursor hourglass open mergefile$ for input as #1 open DefaultDir$;"\";categorie$ for append as #2 #2 input$(#1, lof(#1)); close #2 : close #1 call readDictionary call collectGarbage call writeDictionary call loadKeys close #pleasewait cursor normal #codeTank.keys "select 0" wait
[CodeTankHelp] notice "CodeTank is curently in development, For Help, please visit the LB forums";chr$(13);chr$(13);"@ https://libertybasiccom.proboards.com/" wait
[about] notice "CodeTank is curently in development. Please Visit ";chr$(13);chr$(13);"https://libertybasiccom.proboards.com/" wait
[revert] #CodeTank.keys "selection? name$" if name$ = "" then notice "Select an item from list, try again" : wait filedialog "Open a 'KNOWN WORKING' Source File (.bas) ", DefaultDir$;"\BAS"; "\*.bas", fname$ if fname$ = "" then notice "No file selected" : wait open fname$ for input as #1 fnamenobas$ = word$(fname$, 2, "--") : fnamenobas$ = left$(fnamenobas$, len(fnamenobas$) - 4) open DefaultDir$;"\";savedProjects$;"\";name$;"\";name$;".bas" for output as #2 #2 input$(#1, lof(#1)) : close #1 : close#2 #CodeTank.keys "select name$" goto [remakeproject] wait
[openlb] run LBpath$;"\";LBexe$ wait
'top menu "Open File in LB IDE" [openlbFile] filedialog "Open \ Select a Liberty Basic Source File (.bas) ", upath$; "\*.bas", openFilename$ if openFilename$ = "" then wait #CodeTank.filePath "cls" : #CodeTank.filePath "File Opened in Liberty Basic - ";openFilename$ run LBpath$;"\";LBexe$;" ";openFilename$ wait
[basFiles] run "explorer.exe ";q$;DefaultDir$;"\";"BAS";q$ wait
'open the following in Windows Explorer [projectsDir] run "explorer.exe ";q$;DefaultDir$;"\";"savedProjects";q$ wait
[tknDir] a$ = DefaultDir$;"\TKN" run "explorer.exe ";q$;a$;q$ wait
[lbexamplesDir] if pathExists(uAppPath$) <> 0 then run "explorer.exe ";q$;uAppPath$;q$ else if pathExists(upath$;"\Application Data\Liberty Basic Pro v4.5.1") <> 0 then run "explorer.exe ";q$;upath$;"\Application Data\Liberty Basic Pro v4.5.1";q$ end if wait
[defaultDir] run "explorer.exe ";q$;DefaultDir$;q$ wait
'radio button selections from MyProjects to Help [projs] #CodeTank.runListing, "!enable" #CodeTank.remakeproject, "!enable" #CodeTank.runlb, "!enable" #CodeTank.addListing, "!enable" #CodeTank.deleteListing, "!enable" #CodeTank.fromFile, "!enable" #CodeTank.merge "!enable" #CodeTank.merge "!enable" #CodeTank.revert, "!enable" call saveValue #CodeTank.value, "!cls" categorie$ = MyProjects$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions category$ = categorie$ category$= left$(category$, (len(category$) - 1)) category$ = right$(category$,7) #CodeTank.addListing, "&New ";category$;" (Copy/Paste)" #CodeTank.fromFile, "&New ";category$;" (From File)" wait
[progs] #CodeTank.runListing, "!enable" #CodeTank.remakeproject, "!enable" #CodeTank.runlb, "!enable" #CodeTank.addListing, "!enable" #CodeTank.deleteListing, "!enable" #CodeTank.fromFile, "!enable" #CodeTank.merge, "!enable" #CodeTank.revert, "!enable" call saveValue #CodeTank.value, "!cls" categorie$ = programs$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions category$ = categorie$ category$= left$(category$, (len(category$) - 1)) #CodeTank.keys "singleclickselect" #CodeTank.addListing, "&New ";category$;" (Copy/Paste)" #CodeTank.fromFile, "&New ";category$;" (From File)" wait
[exams] #CodeTank.runListing, "!enable" #CodeTank.runlb, "!enable" #CodeTank.addListing, "!enable" #CodeTank.deleteListing, "!enable" #CodeTank.remakeproject, "!disable" #CodeTank.fromFile, "!disable" #CodeTank.merge, "!enable" #CodeTank.revert, "!disable" call saveValue #CodeTank.value, "!cls" categorie$ = examples$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions #CodeTank.addListing, "&New ";left$(categorie$, (len(categorie$) - 1)) category$ = categorie$ category$= left$(category$, (len(category$) - 1)) #CodeTank.addListing, "&New ";category$;" (Copy/Paste)" wait
[snipps] #CodeTank.remakeproject, "!disable" #CodeTank.runlb, "!enable" #CodeTank.runListing, "!enable" #CodeTank.addListing, "!enable" #CodeTank.deleteListing, "!enable" #CodeTank.fromFile, "!disable" #CodeTank.merge, "!enable" #CodeTank.revert, "!disable" call saveValue #CodeTank.value, "!cls" categorie$ = snippets$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions category$ = categorie$ category$= left$(category$, (len(category$) - 1)) #CodeTank.addListing, "&New ";left$(categorie$, (len(categorie$) - 1)) wait
[subroutines] #CodeTank.runListing, "!enable" #CodeTank.remakeproject, "!disable" #CodeTank.runlb, "!enable" #CodeTank.addListing, "!enable" #CodeTank.deleteListing, "!enable" #CodeTank.fromFile, "!disable" #CodeTank.merge, "!enable" #CodeTank.revert, "!disable" call saveValue #CodeTank.value, "!cls" categorie$ = subroutines$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions category$ = categorie$ category$= left$(category$, (len(category$) - 1)) #CodeTank.addListing, "&New ";category$ wait
[functions] #CodeTank.runListing, "!enable" #CodeTank.remakeproject, "!disable" #CodeTank.runlb, "!enable" #CodeTank.addListing, "!enable" #CodeTank.deleteListing, "!enable" #CodeTank.fromFile, "!disable" #CodeTank.merge, "!enable" #CodeTank.revert, "!disable" call saveValue #CodeTank.value, "!cls" categorie$ = functions$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions #CodeTank.addListing, "&New ";left$(categorie$, (len(categorie$) - 1)) category$= left$(categorie$, (len(categorie$) - 1)) wait
[vbs] #CodeTank.runListing, "!enable" #CodeTank.remakeproject, "!disable" #CodeTank.runlb, "!enable" #CodeTank.addListing, "!enable" #CodeTank.deleteListing, "!enable" #CodeTank.fromFile, "!disable" #CodeTank.merge, "!enable" #CodeTank.revert, "!disable" call saveValue #CodeTank.value, "!cls" categorie$ = vbs$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions #CodeTank.addListing, "&New ";left$(categorie$, len(categorie$)-1) category$ = categorie$ wait
[cmd] #CodeTank.runListing, "!enable" #CodeTank.remakeproject, "!disable" #CodeTank.addListing, "!enable" #CodeTank.deleteListing, "!enable" #CodeTank.runlb, "!enable" #CodeTank.fromFile, "!disable" #CodeTank.merge, "!enable" #CodeTank.revert, "!disable" call saveValue #CodeTank.value, "!cls" categorie$ = cmd$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions #CodeTank.addListing, "&New ";left$(categorie$, len(categorie$)-1) category$ = categorie$ wait
[lbCodeExamples] if fileExists(DefaultDir$, lbExamples$) <> 0 then kill DefaultDir$;"\";lbExamples$ #CodeTank.runListing, "!enable" #CodeTank.runlb, "!enable" #CodeTank.remakeproject, "!disable" #CodeTank.addListing, "!disable" #CodeTank.deleteListing, "!disable" #CodeTank.fromFile, "!disable" #CodeTank.merge, "!disable" #CodeTank.revert, "!disable" call saveValue #CodeTank.value, "!cls" categorie$ = lbExamples$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions dim folderInfo$(1, 1) files upath$;"\Application Data\Liberty Basic v4.5.1\", folderInfo$() numExamps = val(folderInfo$(0, 0)) dim lbExamplesList$(numExamps) open lbExamples$ for append as #1 x = 0 [skipp] x = x + 1 if x > numExamps then close #1 : call readDictionary : call loadKeys : wait filename$ = folderInfo$(x, 0) if right$(filename$, 3) <> "bas" then [skipp] lbExamplesList$(x) = left$(filename$, len(filename$) - 4) newKey$ = lbExamplesList$(x) word1$ = chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134) + newKey$ + chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134) #1 word1$ goto [skipp]
[lbbakfiles] if fileExists(DefaultDir$, lbBakFiles$) <> 0 then kill DefaultDir$;"\"; lbBakFiles$ #CodeTank.runListing, "!disable" #CodeTank.runlb, "!enable" #CodeTank.remakeproject, "!disable" #CodeTank.addListing, "!disable" #CodeTank.deleteListing, "!disable" #CodeTank.fromFile, "!disable" #CodeTank.merge, "!disable" #CodeTank.revert, "!disable" call saveValue #CodeTank.value, "!cls" categorie$ = lbBakFiles$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions dim folderInfo$(1, 1) files uAppPath$;"\bak\", info$() numExamps = val(info$(0, 0)) dim lbBakFilesList$(numExamps) open lbBakFiles$ for append as #1 x = 0 [skipit] x = x + 1 if x > numExamps then close #1 : call readDictionary : call loadKeys : wait filename$ = info$(x, 0) if right$(filename$, 3) <> "bak" then [skipit] lbBakFilesList$(x) = left$(filename$, len(filename$) - 4) newKey$ = lbBakFilesList$(x) word1$ = chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134) + newKey$ + chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134) #1 word1$ goto [skipit]
[mybackups] if fileExists(DefaultDir$, MyBackups$) <> 0 then kill DefaultDir$;"\";MyBackups$ #CodeTank.runListing, "!disable" #CodeTank.runlb, "!enable" #CodeTank.remakeproject, "!disable" #CodeTank.addListing, "!disable" #CodeTank.deleteListing, "!disable" #CodeTank.fromFile, "!disable" #CodeTank.merge, "!disable" #CodeTank.revert, "!disable" call saveValue #CodeTank.value, "!cls" categorie$ = MyBackups$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions gettingMybackupFiles = 1 dim folderInfo$(1, 1) files DefaultDir$;"\";"BAS", folderInfo$() numExamps = val(folderInfo$(0, 0)) dim MyBackupsList$(numExamps) open categorie$ for append as #1 x = 0 [skiphere] x = x + 1 if x > numExamps then close #1 : call readDictionary : call loadKeys : wait filename$ = folderInfo$(x, 0) if right$(filename$, 3) <> "bas" then [skiphere] MyBackupsList$(x) = left$(filename$, len(filename$) - 4) newKey$ = MyBackupsList$(x) word1$ = chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134) + newKey$ + chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134) #1 word1$ goto [skiphere]
[folderChoice] folderChoice$ = "folderChoice.txt" if fileExists(DefaultDir$, folderChoice$) <> 0 then kill DefaultDir$;"\";folderChoice$ #CodeTank.runListing, "!disable" #CodeTank.runlb, "!enable" #CodeTank.remakeproject, "!disable" #CodeTank.addListing, "!disable" #CodeTank.deleteListing, "!disable" #CodeTank.fromFile, "!disable" #CodeTank.merge, "!disable" #CodeTank.revert, "!disable" call saveValue caption$ = "Select a Folder containing .bas Files" a$ = FolderDialog$(caption$) if right$(FolderDialog$,1) = "\" then FolderDialog$ = left$(FolderDialog$, len(FolderDialog$)-1) if FolderDialog$ = "" then notice "No Folder Selected" : wait if len(FolderDialog$) = 2 then notice "Drive ";left$(FolderDialog$, 2);" Selected - You MUST Select a Folder" : goto [folderChoice] folderpath$ = FolderDialog$ #CodeTank.value, "!cls" categorie$ = folderChoice$ #CodeTank.filePath "cls" : #CodeTank.filePath "Reading - ";categorie$ call resetRadioOptions redim folderInfo$(1, 1) files folderpath$, folderInfo$() numExamps = val(folderInfo$(0, 0)) redim folderList$(numExamps) open folderChoice$ for append as #1 x = 0 [skipnow] x = x + 1 if x > numExamps then close #1 : call readDictionary : call loadKeys : wait filename$ = folderInfo$(x, 0) if right$(filename$, 3) <> "bas" then [skipnow] folderList$(x) = left$(filename$, len(filename$) - 4) newKey$ = folderList$(x) word1$ = chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134) + newKey$ + chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134) #1 word1$ goto [skipnow]
[forumlink] run "explorer.exe https://libertybasiccom.proboards.com/" wait
'resize window font - sets all Listbox fonts equal [incFont] fontsize = fontsize + 1 if mainListOpen = 1 then #CodeTankList.listbox1 "font Arial 0 ";fontsize+6 #CodeTank.keys "font Arial 0 ";fontsize+14 #CodeTank.value "!font Arial 0 ";fontsize+14 wait
[decFont] fontsize = fontsize - 1 if mainListOpen = 1 then #CodeTankList.listbox1 "font Arial 0 ";fontsize+6 #CodeTank.keys "font Arial 0 ";fontsize+14 #CodeTank.value "!font Arial 0 ";fontsize+14 wait
'create a project and tkn file and add it to the MyProjects List [makeproject] call saveValue call pleasewait : pleasewaitOpen = 1 #pleasewait.fake "!setfocus" #CodeTank.filePath "cls" : #CodeTank.filePath "Creating Project ";DefaultDir$;"\";savedProjects$;"\";selectedKey$;"\";selectedKey$;".bas" tkn = 2 if categorie$ <> MyProjects$ then tkn = 4 goto [defaultClick]
[remakeproject] call saveValue if selectedKey$ = "" then notice "Select an item from list, try again" : wait if fileExists(DefaultDir$;"\";savedProjects$;"\";selectedKey$,selectedKey$;".bas") = 0 then notice "Cannot be Updated - Title Created Manually"+chr$(13)+selectedKey$+chr$(13)_ +" Wasn't created using a File"+chr$(13)+chr$(13)_ +"Edit with Liberty Basic and save it."+chr$(13)+"Select Radio Button "+categorie$+chr$(13)+"Select Button [New from File]"+chr$(13)_ +"Select the appropriate .bas file."+chr$(13)+" It will be available for Updating" #CodeTank.keys "select 0" #CodeTank.value "!cls" wait end if tkn = 4 fname$ = DefaultDir$;"\";savedProjects$;"\";selectedKey$;"\";selectedKey$;".bas" #CodeTank.filePath "cls" : #CodeTank.filePath "Updating ";fname$ if tkn = 4 then [makeTKN] [defaultClick] 'Checking all paths and file locations for existence (dll's, sll's, lbasic.exe, and lbrun2.exe) res=fileExists(LBpath$, LBexe$) if res then a = a + 1 else notice LBexe$;" Does not exist in ";LBpath$;" Closing Program" : goto [quit.CodeTank] res=fileExists(LBpath$,LBruntime$) if res then a = a + 1 else notice LBrun$;" Does not exist in ";LBpath$;" Closing Program" : goto [quit.CodeTank] res=fileExists(LBpath$,"vbas31w.sll") if res then a = a + 1 else notice " vbas31w.sll Does not exist in ";LBpath$;" Closing Program" : goto [quit.CodeTank] res=fileExists(LBpath$,"vgui31w.sll") if res then a = a + 1 else notice " vgui31w.sll Does not exist in ";LBpath$;" Closing Program" : goto [quit.CodeTank] res=fileExists(LBpath$,"voflr31w.sll") if res then a = a + 1 else notice " voflr31w.sll Does not exist in ";LBpath$;" Closing Program" : goto [quit.CodeTank] res=fileExists(LBpath$,"vthk31w.dll") if res then a = a + 1 else notice " vthk31w.dll Does not exist in ";LBpath$;" Closing Program" : goto [quit.CodeTank] res=fileExists(LBpath$,"vtk1631w.dll") if res then a = a + 1 else notice " vtk1631w.dll Does not exist in ";LBpath$;" Closing Program" : goto [quit.CodeTank] res=fileExists(LBpath$,"vtk3231w.dll") if res then a = a + 1 else notice " vtk3231w.dll Does not exist in ";LBpath$;" Closing Program" : goto [quit.CodeTank] res=fileExists(LBpath$,"vvm31w.dll") if res then a = a + 1 else notice " vvm31w.dll Does not exist in ";LBpath$;" Closing Program" : goto [quit.CodeTank] res=fileExists(LBpath$,"vvmt31w.dll") if res then a = a + 1 else notice " vvmt31w.dll Does not exist in ";LBpath$;" Closing Program": goto [quit.CodeTank]
' Use the filedialog function to allow user to select a source file (.bas) [filediag] 'open file dialog to choose a .bas file for exe conversion filedialog "Open a 'KNOWN WORKING' Source File (.bas) ", DefaultDir$; "\*.bas", fname$ if fname$ = "" then notice "No file selected" : wait #CodeTank.filePath "cls" : #CodeTank.filePath "Creating tkn file for - ";fname$ [makeTKN] 'Separate path from selected filename, and extension from selected filename for var1 = len(fname$) to 1 step -1 if mid$(fname$, var1, 1) = "\" then var2 = var1 -1 : var3 = var2 - ((len(fname$))) : exit for next var1 var3 = abs(var3) orig$ = left$(fname$, var2) fname0$ = right$(fname$, var3 -1)
'finish separating filename from extension for var4 = len(fname0$) to 1 step -1 if mid$(fname0$, var4, 1) = "." then var5 = var4 -1 : var6 = var5 - ((len(fname0$))) : exit for next var4 var6 = abs(var6) fnamenobas$ = left$(fname0$, var5) ' fname$ = Full Path of User Selected .bas file (including the filename.bas) ' fname0$ = Name of the Selected .bas File Only - eg ; filename.bas ' fnamenobas$ = Name of the Selected .bas File (without the .bas) - eg: filename
[begin] 'define Destpath1$ as LB Projects\Current Project Folder DestPath$=DefaultDir$ 'Where this file is RUN from DestPathU$ = DestPath$;"\";savedProjects$ 'Projects Folder DestPath1$=DestPathU$;"\";fnamenobas$ 'Current created Project Folder
'Make Folders for Liberty Basic Projects, EXE files, TKN files, BAS files, SED files and Current Projects res = mkdir(DestPathU$) 'projects dir res = mkdir(DestPath1$) 'new project dir = name of selected bas file (no .bas) in Projects Dir res = mkdir(DefaultDir$;"\";"TKN") 'tkn files saved here res= mkdir(DefaultDir$;"\";"BAS") 'selected bas file saved here (includes password code if exe was passworded)
'make sure Folders were actually created res=pathExists(DestPathU$) if res then a=a+1 else notice "savedProjects folder was NOT Created in ";DestPath$;" CodeTank Closing" : goto [quit.CodeTank] if res then a=a+1 else notice "New Folder ";fnamenobas$;" was NOT Created in ";DestPath1$;" CodeTank Closing" : goto [quit.CodeTank] tknFolder$=DefaultDir$;"\";"TKN" res=pathExists(tknFolder$) if res then a=a+1 else notice "TKN Folder was NOT Created in ";DestPath$;" CodeTank Closing" : goto [quit.CodeTank] basFolder$=DefaultDir$;"\";"BAS" res=pathExists(basFolder$) if res then a=a+1 else notice "BAS Folder was NOT Created in ";DestPath$;" CodeTank Closing" : goto [quit.CodeTank]
'copy selected bas file to Projects\current project folder open fname$ for input as #1 data$ = input$(#1,lof(#1)) : close #1 open DestPath1$;"\";fname0$ for output as #2 #2 data$ close #2
'check if the current project .bas file was copied to new dir if fileExists(DestPath1$,fname0$) = 0 then notice fname0$; " Was not copied to ";DestPath1$;" CodeTank Closing" : goto [quit.CodeTank] if tkn = 4 then [tknOnly] 'bypass for Categorie Programs and Updates - tkn and bas file only needed
'Copy the needed DLL and SLL files from Liberty Basic dir to projects\projectname Dir 'runtimeSupportFile$ = "" i = 0 while 1 i = i + 1 runtimeSupportFile$=word$(DllList$,i) if runtimeSupportFile$ ="" then exit while sourceFile$=LBpath$;"\";runtimeSupportFile$ destinationFile$=DestPath1$;"\";runtimeSupportFile$
'don't copy runtime files if they already exists if fileExists(DestPath1$, runtimeSupportFile$) <> 0 then [fileExists] open sourceFile$ for input as #file open destinationFile$ for output as #1 #1 input$(#file, lof(#file)); close #file close #1 [fileExists] wend
'verify dll's and sll's were copied to new project folder res=fileExists(DestPath1$,"vbas31w.sll") if res then a = a + 1 else notice " vbas31w.sll Was not created in --> ";DestPath1$;" Closing Program" : goto [quit.CodeTank] res=fileExists(DestPath1$,"vgui31w.sll") if res then a = a + 1 else notice " vgui31w.sll Was not created in --> ";DestPath1$;" Closing Program" : goto [quit.CodeTank] res=fileExists(DestPath1$,"voflr31w.sll") if res then a = a + 1 else notice " voflr31w.sll Was not created in --> ";DestPath1$;" Closing Program" : goto [quit.CodeTank] res=fileExists(DestPath1$,"vthk31w.dll") if res then a = a + 1 else notice " vthk31w.dll Was not created in --> ";DestPath1$;" Closing Program" : goto [quit.CodeTank] res=fileExists(DestPath1$,"vtk1631w.dll") if res then a = a + 1 else notice " vtk1631w.dll Was not created in --> ";DestPath1$;" Closing Program" : goto [quit.CodeTank] res=fileExists(DestPath1$,"vtk3231w.dll") if res then a = a + 1 else notice " vtk3231w.dll Was not created in --> ";DestPath1$;" Closing Program" : goto [quit.CodeTank] res=fileExists(DestPath1$,"vvm31w.dll") if res then a = a + 1 else notice " vvm31w.dll Was not created in --> ";DestPath1$;" Closing Program" : goto [quit.CodeTank] res=fileExists(DestPath1$,"vvmt31w.dll") if res then a = a + 1 else notice " vvmt31w.dll Was not created in --> ";DestPath1$;" Closing Program" : goto [quit.CodeTank] 'remove any left over existing lbrun2.exe from new project before creating new one 'Liberty Basic can't create\rename a file that exists, so if it does already exist - kill it (delete it) if fileExists(DestPath1$, LBruntime$) <> 0 then kill DestPath1$;"\"; LBruntime$
'copy lbrun2.exe to Current Project Folder open LBpath$;"\";LBruntime$ for input as #file open DestPath1$;"\";fnamenobas$;".exe" for output as #1 #1 input$(#file, lof(#file)); close #file close #1
'check new exe (renamed lbrun2.exe) file for existence in current project Folder ) if fileExists(DestPath1$,fnamenobas$;".exe") = 0 then notice "lbrun2.exe not copied or renamed - EXITING Program": goto [quit.CodeTank]
[tknOnly] call fixtime call fixdate
'copy selected .bas file to BAS dir and date it open DestPath1$;"\";fname0$ for input as #file open DestPath$;"\BAS\";fixeddate$;fixedtime$;"-";fnamenobas$;".bas" for output as #1 #1 input$(#file, lof(#file)); close #file close #1
'remove any existing tkn of same name in TKN dir if fileExists(DestPath1$, fnamenobas$;".tkn") <> 0 then kill DestPath1$;"\";fnamenobas$;".tkn"
call writeAutoSave 'loop until autoSave$ File is verified while fileExists(DefaultDir$, autoSave$) = 0 : scan : wend run "wscript ";autoSave$ '####################################################################### 'Create the TKN file in Projects\current project folder. RUN LBpath$;"\";LBexe$;" -T -A ";DestPath1$;"\";fname0$ 'run the script to close the "save" dialog, and the follow up notice of creation automatically
'loop until TKN File is verified while www = 0 if fileExists(DestPath1$,fnamenobas$;".tkn") <> 0 then exit while scan wend call pause 1500
'copy TKN$ file to TKN dir, and date it open DestPath1$;"\";fnamenobas$;".tkn" for input as #file open DefaultDir$;"\TKN\";fixeddate$;fixedtime$;"-";fnamenobas$;".tkn" for output as #1 #1 input$(#file, lof(#file)); close #file close #1
if fileExists (DefaultDir$;"\TKN", fixeddate$;fixedtime$;"-";fnamenobas$;".tkn") = 0 then notice fixeddate$;fixedtime$;"-";fnamenobas$;".tkn";" was NOT created in ";DefaultDir$;"\TKN" : wait
[continueOn] 'check what tkn value =, and continue to create the 'new key' if tkn = 2 or tkn = 4 then newKey$ = fnamenobas$ goto [continue]
sub pleasewait WindowWidth = 150 : WindowHeight = 150 UpperLeftX=int((DisplayWidth-WindowWidth)/2)'-100 UpperLeftY=int((DisplayHeight-WindowHeight)/2)'-500 statictext #pleasewait.text, "Please Wait", 30, 20, 100, 20 statictext #pleasewait.text2, "This Can", 40, 50, 100, 20 statictext #pleasewait.text3, "Take a While", 20, 80, 100, 20 button #pleasewait.fake, "", [quit.pleasewait], ul, 0, 0, 0, 0 Open "untiltled" for dialog_popup as #pleasewait #pleasewait "trapclose [quit.pleasewait]" #pleasewait "font arial 12 bold" end sub
sub cleanup ' Delete .vbs files and temp .txt if fileExists(DefaultDir$,"temp.txt") <> 0 then kill "temp.txt" if fileExists(DefaultDir$, "FolderDialog.vbs") <> 0 then kill "FolderDialog.vbs" if fileExists(DefaultDir$,"autoSave.vbs") <> 0 then kill DefaultDir$;"\";"autoSave.vbs" if fileExists(DefaultDir$;"\EXE", "~";fnamenobas$;".CAB") <> 0 then kill DefaultDir$;"\EXE\~";fnamenobas$;".CAB" if fileExists(DefaultDir$;"\EXE", "~";fnamenobas$;".DDF") <> 0 then kill DefaultDir$;"\EXE\~";fnamenobas$;".DDF" if fileExists(DefaultDir$;"\EXE", "~";fnamenobas$;".RPT") <> 0 then kill DefaultDir$;"\EXE\~";fnamenobas$;".RPT" if fileExists(DefaultDir$;"\EXE", "~";fnamenobas$;"_LAYOUT.INF") <> 0 then kill DefaultDir$;"\EXE\~";fnamenobas$;"_LAYOUT.INF" end sub
sub writeAutoSave global autoSave$ autoSave$ = "autoSave.vbs" open autoSave$ for output as #1 #1 "Set WshShell = WScript.CreateObject(";q$;"WScript.Shell";q$;")" #1, "Do While Not WshShell.AppActivate(";q$;"Save *.TKN File As...";q$;")" #1, "Loop" #1, "Wscript.Sleep(500)"'- this delay may need adjusting on your pc #1, "WshShell.SendKeys ";q$;"{ENTER}";q$ #1, "Do While Not WshShell.AppActivate(";q$;"Information";q$;")" #1, "Loop" #1, "Wscript.Sleep(500)"'- this delay may need adjusting on your pc #1, "WshShell.SendKeys ";q$;"{ENTER}";q$ close #1 end sub
sub getUserPath x=0 run "cmd.exe /c echo %userprofile% >UserHomePath.txt", HIDE do scan if x = 10 then [timesUp] call pause 500 x=x+1 loop until fileExists(DefaultDir$, "UserHomePath.txt") <> 0 open "UserHomePath.txt" for input as #1 upath$ = input$(#1, lof(#1)) close #1 [timesUp] if upath$ = "" then notice "User HomePath Problem";chr$(13);"Sorry, can't find the Users Homepath ";chr$(13);chr$(13);"CodeTank will need to close" : end kill DefaultDir$;"\UserHomePath.txt" upath$=trim$(upath$) end sub
'xxgeek code 'edit date$() return for use in filenames sub fixdate fixDate$ = Date$() 'set up a date format that works with a filename(remove the /) fix1$ =word$(fixDate$, 1, " ") ' = Month, fix2$ = word$(fixDate$, 2, " ") ' = Month fix2$ = left$(fix2$, len(fix2$)-1) ' = Number of day fix3$ = word$(fixDate$, 3 ," ") ' = Year - 4 digits fix3$ = right$(fix3$, 2) ' = Year - 2 digits fixeddate$ = fix1$;"-";fix2$;"-";fix3$ ' = Month-NumberOfDay-Year end sub
'editTime$() return for use in filenames sub fixtime fixTime$ = Time$() 'set up a time format that works with a filename(remove the /) fix1$ = word$(fixTime$, 1, ":")' - remove the "." 's fix2$ = word$(fixTime$, 2 ,":") fixedtime$ = "-";fix1$;"-";fix2$;"-"' ' add dashes - end sub
sub resetRadioOptions dictionary$ = "" : keyCount = 0 : lastKey$ = "" : selectedKey$ = "" call readDictionary call loadKeys #CodeTank.value, "!origin 0, 0 " #CodeTank.keys "select 0" end sub
'function for checking file existence function fileExists(path$, filename$) dim info$(0, 0) files path$, filename$, info$() fileExists = val(info$(0, 0)) 'non zero is true end function
'function for checking folder existence function pathExists(path$) pathExists = (mkdir(path$)=183) end function
'functions for making the folder dialog window function FolderDialog$(caption$) WindowWidth = 600 WindowHeight = 370 UpperLeftX=INT((DisplayWidth-WindowWidth)/2) UpperLeftY=INT((DisplayHeight-WindowHeight)/2) BackgroundColor$ = "lightgray" ForegroundColor$ = "black" gosub [FolderDlgGetDrives] statictext #folderdlg.S, "Note: - Only Drives and Folders Appear Below - No Files Appear", 95, 15, 550, 25 statictext #folderdlg.S, "Select a Folder From the List", 185, 40, 350, 25 statictext #folderdlg.D, " (Single Click to Select or Navigate)", 185, 77, 325, 15 listbox #folderdlg.list, FolderList$(, [FolderDlgSelect], 22, 90, 550, 130 button #folderdlg.default, "Ok", [FolderDlgOk], UL, 190, 293, 85, 35 button #folderdlg.B, "Back", [FolderDlgBack], UL, 20, 45, 80, 30 button #folderdlg.C, "Cancel", [FolderDlgCancel], UL, 290, 293, 85, 35 textbox #folderdlg.text, 42, 225, 510, 30 statictext #folderdlg.path, "Selected Drive or Folder Path Appears Here", 130, 258, 400, 20 open caption$ for dialog_modal as #folderdlg #folderdlg, "trapclose [FolderDlgCancel]" #folderdlg.default, "!font Arial 8 bold" #folderdlg, "font Arial 10 bold" #folderdlg.S, "!font Arial 14 bold" #folderdlg.path, "!font Arial 10 bold" #folderdlg.list, "font Arial 10 bold" #folderdlg.C, "!font Arial 10 bold" #folderdlg.D, "!font Arial 8 bold" #folderdlg.text, "!font Arial 10 bold" #folderdlg.list "singleclickselect" wait [FolderDlgSelect] #folderdlg.list, "selection? temp$" if temp$ <> "" then level = level+1 folder$ = folder$; temp$; "\" #folderdlg.text, folder$ gosub [FolderDlgGetDir] #folderdlg.list, "reload" end if wait [FolderDlgBack] if level > 0 then level = level-1 if level = 0 then folder$ = "" gosub [FolderDlgGetDrives] else i = len(folder$)-1 while mid$(folder$, i, 1) <> "\" and mid$(folder$, i, 1) <> "" i = i-1 wend folder$ = left$(folder$, i) gosub [FolderDlgGetDir] end if #folderdlg.text, folder$ #folderdlg.list, "reload" end if wait [FolderDlgGetDrives] c = 1 while word$(Drives$, c) <> "" c = c+1 wend redim FolderList$(c) for i = 1 to c FolderList$(i) = word$(Drives$, i) next i return [FolderDlgGetDir] files folder$, info$( s = val(info$(0,0)) t = val(info$(0,1)) redim FolderList$(t) for i = 1 to t FolderList$(i) = info$(i+s, 1) next i return [FolderDlgOk] #folderdlg.text, "!contents? FolderDialog$" If right$(FolderDialog$,1) = "\" then FolderDialog$ = left$(FolderDialog$, len(FolderDialog$) - 1) [FolderDlgCancel] close #folderdlg end function
'quit program [quit.CodeTank] if CodeTankOpen = 1 then call saveValue call cleanup close #CodeTank CodeTankOpen = 0 end if end
'sub to create pauses in program sub pause mil t=time$("ms")+mil while time$("ms")<t scan wend end sub
'sub to save current Dictionary Listings and text in texeditor sub saveValue 'if the value is changed, save it if lastKey$ <> "" then #CodeTank.value "!modified? modified$"; if modified$ = "true" then #CodeTank.value "!contents? saveThisValue$"; call setValueByName lastKey$, saveThisValue$ call collectGarbage call writeDictionary end if end if end sub
'function to get selected Listing function getKeys$(delimiter$) global keyCount pointer = 1 while pointer <> 0 'get the next key pointer = instr(dictionary$, chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134), pointer) if pointer then keyPointer = pointer + 9 pointer = instr(dictionary$, chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134), pointer) key$ = mid$(dictionary$, keyPointer, pointer - keyPointer) if instr(keyList$, chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134) + key$ + chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134)) = 0 then getKeys$ = getKeys$ + key$ + delimiter$ keyList$ = keyList$ + chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134) + key$ keyCount = keyCount + 1 end if end if wend end function
'sub to write each Listing to corresponding file sub writeDictionary open categorie$ for output as #writeDict #writeDict, dictionary$ close #writeDict end sub
'sub to read each Listing from corresponding file sub readDictionary if fileExists(DefaultDir$, categorie$) <> 0 then open categorie$ for input as #readDict length = lof(#readDict) dictionary$ = input$(#readDict, length) close #readDict else end if end sub
'sub to cleanup any mess in the dictionary text sub collectGarbage pointer = 1 while pointer > 0 'get the next key pointer = instr(dictionary$, chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134), pointer) if pointer then keyPointer = pointer + 9 pointer = instr(dictionary$, chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134), pointer) key$ = mid$(dictionary$, keyPointer, pointer - keyPointer) if instr(keyList$, chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134) + key$ + chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134)) = 0 then value$ = getValue$(key$) newDictionary$ = chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134) + key$ + chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134) + value$ + newDictionary$ keyList$ = keyList$ + chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134) + key$ + chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134) end if end if wend dictionary$ = newDictionary$ end sub
sub setValueByName key$, value$ dictionary$ = chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134);key$;chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134)+value$+dictionary$ end sub
'function to get info from selected Listing function getValue$(key$) getValue$ = chr$(0) keyPosition = instr(dictionary$, chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134)+key$+chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134)) if keyPosition > 0 then keyPosition = keyPosition + 9 'skip over key tag valuePosition = instr(dictionary$, chr$(134);chr$(165);chr$(134);"value";chr$(134);chr$(165);chr$(134), keyPosition) if valuePosition > 0 then valuePosition = valuePosition + 11 'skip over value tag endPosition = instr(dictionary$, chr$(134);chr$(165);chr$(134);"key";chr$(134);chr$(165);chr$(134), valuePosition) if endPosition > 0 then getValue$ = mid$(dictionary$, valuePosition, endPosition - valuePosition) else getValue$ = mid$(dictionary$, valuePosition) end if end if end if end function
'sub to load selected categorie List sub loadKeys keyList$ = getKeys$(chr$(134);chr$(165);chr$(134)) redim keys$(keyCount) for item = 1 to keyCount keys$(item-1) = word$(keyList$, item, chr$(134);chr$(165);chr$(134)) next item sort keys$(), 0, keyCount #CodeTank.keys "reload" keyCount = 0 end sub
'function to separate filename from full path to file function GetFilename$(fileName$) i = len(fileName$) while mid$(fileName$, i, 1) <> "\" and mid$(fileName$, i, 1) <> "" i = i-1 wend GetFilename$ = mid$(fileName$, i+1) end function
'function to delete entire folder (including sub folders and files) function delete$(folder$) print folder$ run "cmd.exe /c rd /s /q ";q$;folder$;q$, HIDE end function
'function makes customized confirmation window function custcon$(text$) global text$, conanswer$ WindowWidth = 540 : WindowHeight = 300 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) statictext #customconfirm.text text$, 40, 60, 490, 200 statictext #customconfirm.header "Please Confirm", 220, 10, 130, 30 button #customconfirm.yes " &Yes", [confirmYes], ul, 130, 180, 105, 40 button #customconfirm.no " &No", [confirmNo], ul, 280, 180, 115, 40 open "Confirmation Required" for window_nf as #customconfirm #customconfirm "trapclose [endFunction]" #customconfirm "font arial 12" #customconfirm.no "!setfocus" wait [confirmYes] conanswer$ = "yes" goto [endFunction] [confirmNo] conanswer$ = "no" [endFunction] close #customconfirm closing = 1 end function '
|
|