Each EXE file is appended with the date/time and placed in a folder named BAS2EXE which is created in DefaultDir$ on first use.
Then Explorer opens to the location of the new EXE file.
Please read the top of the code and follow any instructions.
Code: Select all
'QuickEXE using LB Booster (Automated) - now Automates downloading the LBB.exe file
'No longer need to - Download LBB.exe and LBRUN.exe from this page - http://lbbooster.com/
'No longer need to - Save them to the same folder as this file RUN's from (DefaultDir$)
'created by xxgeek
'Sept 2023
'Edited Nov 2023 - added ability to download LBB.exe (User is given a choice)
'Edited Mar 2024 - changed EXE location to BAS2EXE dir (created on first use)
' - can now choose .bas files in DefaultDir$ too.
' - added date/time to EXE filename_
' - _no longer a worry of overwrites when quick testing
'BE AWARE
'Copy this code to a file in a folder of it's own before RUN'ing (QuickEXE will create files in it's folder)
'QuickEXE:
'Copies the selected .bas file to BAS2EXE dir, then automates LBB exe file creation to create the new EXE file in DefaultDir$(same folder this code is RUN'ing from)
'Overwrites any existing .bas file of same name in BAS2EXE dir. Does not affect Original file
'If existing EXE file of same name resides in BAS2EXE dir Automation Stops
'_ and the User is asked to Overwrite. Does not affect Original unless confirmed by user.
'_ the User must manually close the Information window showing the path to "Saved As" file
'There may be a window pop up asking to overwrite an existing exe file of same name
'The automation takes care of that too after a couple of seconds, defaulted to "No" by design" :)
'Please Wait Long Enough
'If you wait, and no existing filename of the new exe file exists, all open windows will/should close eventually. No need to start closing windows manually, and if you do will most likely cause a crash, or no exe file.
'Very tricky timing things in the code to suit any file size, or any old PC.
'If you have issues, we can try to work them out.
'NOTE: If your .bas won't pass the LB Booster compiler check, creating the exe won't work.
nomainwin
if fileExists(DefaultDir$, "LBB.exe") = 0 then
confirm "You will need the LB Booster Executable File"+chr$(13)+chr$(13)+"Download LBB.exe Now?";answer$
If answer$<>"yes" then end
cursor hourglass
run "curl -O https://lbbooster.com/LBB.exe",hide
WindowWidth = 250:WindowHeight = 53
UpperLeftX= int((DisplayWidth-WindowWidth)/2)
UpperLeftY= int((DisplayHeight-DisplayHeight))+155
statictext #down.text, "Downloading LBB.exe", 30,20,240,20
open "Downloading LBB.exe" for window_popup as #down
#down "font arial_14 bold"
#down.text "Downloading LBB.exe"
downOpen=1
counter=0
do
counter=counter+1
if counter>50000 then exit do
loop until fileExists(DefaultDir$, "LBB.exe")
if fileExists(DefaultDir$, "LBB.exe") = 0 then
notice "LBB.exe was NOT Downloaded";chr$(13);chr$(13);"Restart BAS2EXE and Try Again"
close #down
downOpen=0
end
end if
call pause 300
if downOpen=1 then close #down :downOpen=0
cursor normal
end if
[LBB_EXE]
filedialog "Open a Liberty Basic Source File (.bas) ", "c:\*.bas", fname$
if fname$ = "" then wait
cursor hourglass
res = mkDir("BAS2EXE")
call fixdate
call fixtime
dt$ = fixeddate$;"-";fixedtime$
LBB$ = DefaultDir$;"\LBB.exe"
fname0$ = GetFilename$(fname$)
fname0$ = left$(fname0$,len(fname0$)-4)
open fname$ for input as #1
open "BAS2EXE\";fname0$;dt$;".bas" for output as #2
#2 input$(#1, lof(#1))
close #1
close #2
call writeAutoSaveLBB
run "wscript ";autoSaveLBB$
run LBB$;" -C -M -A ";DefaultDir$;"\BAS2EXE\";fname0$;dt$;".bas"
selected$ = fname0$
do
scan
loop until fileExists(DefaultDir$;"\BAS2EXE", selected$;dt$;".exe")
do
scan
loop until fileExists(DefaultDir$;"\BAS2EXE", selected$;dt$;".exe")
if fileExists(DefaultDir$;"\BAS2EXE", selected$;dt$;".exe") then
run "explorer /select, ";DefaultDir$;"\BAS2EXE\";selected$;dt$;".exe"
else
notice selected$;".exe was NOT Created in ";chr$(34);chr$(34);DefaultDir$;"\BAS2EXE"
end if
cursor normal
end
sub writeAutoSaveLBB
q$ = chr$(34)
global autoSaveLBB$
autoSaveLBB$ = "autoSaveLBB.vbs"
open autoSaveLBB$ for output as #1
#1 "Set WshShell = WScript.CreateObject(";q$;"WScript.Shell";q$;")"
#1 "Do While Not WshShell.AppActivate(";q$;"Save standalone executable";q$;")"
#1 "Loop"
#1 "WshShell.AppActivate(";q$;"Save standalone executable";q$;")"
#1 "WshShell.SendKeys ";q$;"{ENTER}";q$
#1 "Wscript.Sleep(10000)"
#1 "WshShell.SendKeys ";q$;"{ENTER}";q$
#1 "Set WshShell = nothing"
close #1
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 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
'sub to create pauses in program
sub pause mil
t=time$("ms")+mil
while time$("ms")<t
scan
wend
end sub
'edit date$() return for use in filenames
sub fixdate
global fixeddate$
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) ' = Day
fix3$ = word$(fixDate$, 3 ," ") ' = Year - 4 digits
fix3$ = right$(fix3$, 2) ' = Year - 2 digits
fixeddate$ = "-";fix1$;"-";fix2$;"-";fix3$ ' = -Month-Day-Year
end sub
'edit Time$() return for use in filenames
sub fixtime
global fixedtime$
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$
end sub