Post by xxgeek on Jul 31, 2021 5:36:17 GMT
This is the version I use. I've bee testing it, and using it for quite some time and it's pretty stable. No Windows popping up, and no messages unless errors occur.
(Usually bad coding of the selected bas file (my bad coding). Stalls getting debugged, and leaves the opened JB IDE window opened, sometimes empty lol)
Opens directly to the file dialog to select a bas file.
If JB 2 is installed to a folder other than the default, instructions at the top of this file.
Fast efficient, no nonsense. Creates 4 folders, BAS, TKN EXE, and Projects on first run.
Saves the TKN, EXE and selected BAS file to respective folders and dates the files.
The Projects folder has the dll's sll' tkn ( + renamed jbrun2.exe) and selected bas file.'None of these are dated.
It's been an excellent resource for me as I test. If I'm really busy testing - running attempt after attempt to solve a puzzle, I append the Time$() to the files as well so I can go back to a working copy anytime I screw up. (oh, boy do I screw up)
I got an idea from a friend to adapt this for the commandline, like: RUN "BAS2EXE ";"Myfile.bas"
Excellent idea, I'll have to look into it. I was already about to look into adding it to the right click menu when a bas file is selected in Windows context menu. Right click myfile.bas - Make Self Extracting EXE
'BAS2EXE Authors copy For Linux/WINE, Windows 10 (possibly XP, Win 7, 8)
'Date = July 2021
'Title - BAS2EXE v1.8
'Author - xxgeek, a member of the justbasiccom.proboards.com/ forums
'{Purpose} - To automate bas file to exe file (self extracting exe) creation quick and easy while
'storing dated copies of every selected bas file, the created tkn, and the created exe (self extracting)
'exe file containing the dll fiiles, sll files, jbrun2.exe(renamed to same name as .bas file selected)
'Along with that there is a project folder created holding the same files as the exe that gets updated
'if and when the same bas file is selected, Note, the dated files are in there appropriate folders,
' EXE, TKN, and BAS, and they will be overwritten if the same .bas file is selected on the same day
'[Linux Users running WINE]
'You need to install the Windows Scripting Host to get this working along with wextract.exe
'You may need iexpress.exe as well. Put in C:\Windows\System32 dir
'You can install the WSH57 using winetricks "install a component" option >wsh57
'You'll need wextract.exe as wellThe webstract.exe file can be found on the XP install CD,
'or the ISO. In the i386 dir named wexstract.ex_ It is an archive. Extract wexstract.exe, place it in C:\Windows\System32 dir
'iexpress.ex_ is in the i386 dir too, do the same as done for webstract.ex_ if needed
'This is a stripped down version of BAS2EXE on steroids. No windows or messages.
'It opens directly to the file dialog to select a bas file, then does it's thing without another word and ends.
'It's my own version and it's fast.
'If you installed Just Basic v2.0 to a directory other than the default dir, then change this line
'JBpath$ = "c:\Program Files (x86)\Just Basic v2.0" to your own install dir path (about 10 lines down)
nomainwin
titlebar$ = "BAS2EXE v1.8"
fixDate$ = Date$("yyyy/mm/dd") 'set up the date format that works with a filename(remove the /)
fix1$ = word$(fixDate$, 1, "/")
fix2$ = word$(fixDate$, 2 ,"/")
fix3$ = word$(fixDate$, 3 ,"/")
fixedDate$ = "-";fix1$;"-";fix2$;"-";fix3$
'Just Basic v2.0 Default install dir
JBpath$ = "c:\Program Files (x86)\Just Basic v2.0"
[go]
JBexe$ = "jbasic.exe"
JBruntime$ = "jbrun2.exe"
DllList$="vbas31w.sll vgui31w.sll voflr31w.sll vthk31w.dll vtk1631w.dll vtk3231w.dll vvm31w.dll vvmt31w.dll"
projects$ = "Projects"
' 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 \ Select a Just Basic Source File (.bas) ", DefaultDir$; "\*.bas", fname$
if fname$ = "" then notice "No file selected, BAS2EXE will now close" : end
'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)
'remove any spaces from filename
dim s$(250)
for x = len(fname0$) to 1 step -1
s$(x) = mid$(fname0$,x, 1)
s$=s$(x)
if s$ <> " " then s2$ = s$;s2$
s$=s2$
next x
fname0$ = s$
'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 JB Projects\Current Project Folder
DestPath$=DefaultDir$ 'Where this file is RUN from
DestPathU$ = DestPath$;"\";projects$ 'Projects Folder
DestPath1$=DestPathU$;"\";fnamenobas$ 'Current Project Folder
'Make Folders for Just 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$;"\";"EXE") 'exe files saved here
res = mkdir(DefaultDir$;"\";"TKN") 'tkn files saved here
res= mkdir(DefaultDir$;"\";"BAS") 'selected bas file saved here (includes password code if exe was passworded)
'remove existing fname0$ from dir before creating new one
res = fileExists(DestPath1$, fname0$)
if res then kill DestPath1$;"\";fname0$
'copy .bas file to current project folder
open fname$ for input as #fnameTemp
open DestPath1$;"\";fname0$ for output as #1
print #1, input$(#fnameTemp, lof(#fnameTemp));
close #1
close #fnameTemp
'check if the current project .bas file was copied to new dir
res=fileExists(DestPath1$,fname0$)
if res then a = a + 1 else notice fname0$; " Was not copied to ";DestPath1$;" BAS2EXE will now close" : end
print "fname0$ = ";fname0$
'copy selected .bas file to BAS dir and date it
open DestPath1$;"\";fname0$ for input as #file
open DestPath$;"\";"BAS\";fnamenobas$;fixedDate$;".bas" for output as #1
print #1, input$(#file, lof(#file));
close #file
close #1
'remove any existing exe of same name as bas file selected only if created on same date
res = fileExists(DestPath$;"\EXE",fnamenobas$;fixedDate$;".exe")'easy to append Time$() if desired
if res then kill DestPath$;"\";"EXE";"\";fnamenobas$;fixedDate$;".exe"
'Copy the needed DLL and SLL files from Just Basic dir to projects\projectname Dir
w$ = ""
i = 0
while 1
i = i + 1
w$=word$(DllList$,i)
if w$="" then exit while
from$=JBpath$;"\";w$
to$=DestPath1$;"\";w$
if fileExists(DestPath1$,w$) then kill DestPath1$;"\";w$ 'remove any existing
open from$ for input as #file
open to$ for output as #1
print #1, input$(#file, lof(#file));
close #file
close #1
wend
'remove existing jbrun2.exe from new project before creating new one
if fileExists(DestPath1$, JBruntime$) then kill DestPath1$;"\"; JBruntime$
'copy jbrun2.exe to current project Folder
open JBpath$;"\";JBruntime$ for input as #file
open DestPath1$;"\";JBruntime$ for output as #1
print #1, input$(#file, lof(#file));
close #file
close #1
'Just Basic can't create\rename a file that exists, so if it does already exist - kill it (delete it)
if fileExists(DestPath1$, fnamenobas$ + ".exe") then kill DestPath1$;"\";fnamenobas$ + ".exe"
'rename jbrun2.exe to name of User Selected .bas File - .bas +.exe
name DestPath1$;"\";JBruntime$ as DestPath1$;"\";fnamenobas$ + ".exe"
'check new exe (renamed jbrun2.exe) file for existence in current project Folder
res=fileExists(DestPath1$,fnamenobas$;".exe")
if res then a=a+1 else notice "jbrun2.exe not copied or renamed - EXITING Program": end
'check for tkn existence, delete if true
res=fileExists(DestPath1$,fnamenobas$;".tkn")
if res then kill DestPath1$;"\";fnamenobas$;".tkn"
'#######################################################################
'make the sed file for iexpress to read and create the (Self Extracting Directorate) exe file
[makeSed]
'can't write text to files that include quotes, so use the characters so they will print without syntax errors
q$=chr$(34) ' double quotes to be printed around files and paths in sed file text"
sq$=chr$(39) 'single quote used in writing text with single quote to file
sedfile$=fnamenobas$;".sed"
open sedfile$ for output as #sed
#sed "[Version]"
#sed "Class=IEXPRESS"
#sed "SEDVersion=3"
#sed "[Options]"
#sed "PackagePurpose=InstallApp"
#sed "ShowInstallProgramWindow=1"
#sed "HideExtractAnimation=1"
#sed "UseLongFileName=1"
#sed "InsideCompressed=0"
#sed "CAB_FixedSize=0"
#sed "CAB_ResvCodeSigning=0"
#sed "RebootMode=N"
#sed "InstallPrompt=%InstallPrompt%"
#sed "DisplayLicense=%DisplayLicense%"
#sed "FinishMessage=%FinishMessage%"
#sed "TargetName=%TargetName%"
#sed "FriendlyName=%FriendlyName%"
#sed "AppLaunched=%AppLaunched%"
#sed "PostInstallCmd=%PostInstallCmd%"
#sed "AdminQuietInstCmd=%AdminQuietInstCmd%"
#sed "UserQuietInstCmd=%UserQuietInstCmd%"
#sed "SourceFiles=SourceFiles"
#sed "[Strings]"
#sed "InstallPrompt="
#sed "DisplayLicense="
#sed "FinishMessage="
exe$=fnamenobas$;".exe"
#sed "TargetName=";q$;DefaultDir$;"\EXE\";exe$;q$
#sed "FriendlyName=";q$;fnamenobas$;q$
#sed "AppLaunched=";q$;exe$;q$
#sed "PostInstallCmd=<None>"
#sed "AdminQuietInstCmd="
#sed "UserQuietInstCmd="
#sed "FILE0=";q$;exe$;q$
sedtkn$=fnamenobas$;".tkn"
#sed "FILE1=";q$;sedtkn$;q$
sll1$="vbas31w.sll"
sll2$="vgui31w.sll"
sll3$="voflr31w.sll"
dll1$="vthk31w.dll"
dll2$="vtk1631w.dll"
dll3$="vtk3231w.dll"
dll4$="vvm31w.dll"
dll5$="vvmt31w.dll"
#sed "FILE2=";q$;sll1$;q$
#sed "FILE3=";q$;sll2$;q$
#sed "FILE4=";q$;sll3$;q$
#sed "FILE5=";q$;dll1$;q$
#sed "FILE6=";q$;dll2$;q$
#sed "FILE7=";q$;dll3$;q$
#sed "FILE8=";q$;dll4$;q$
#sed "FILE9=";q$;dll5$;q$
#sed "[SourceFiles]"
#sed "SourceFiles0=";q$;DestPath1$;q$
#sed "[SourceFiles0]"
#sed "%FILE0%="
#sed "%FILE1%="
#sed "%FILE2%="
#sed "%FILE3%="
#sed "%FILE4%="
#sed "%FILE5%="
#sed "%FILE6%="
#sed "%FILE7%="
#sed "%FILE8%="
#sed "%FILE9%="
close #sed
'verify sed file existence before proceeding
do
res = fileExists(DestPath$,fnamenobas$;".sed")
if res then exit do
scan
loop until res
'Write script to a .vbs file (Visual Basic Script)
autoSave$ = "autoSave.vbs"
open autoSave$ for output as #1
print #1, "Set WshShell = WScript.CreateObject(";q$;"WScript.Shell";q$;")"
#1, "WshShell.AppActivate ";q$;"Save *.TKN File As...";q$
'#1, "Wscript.Sleep(200)" - keeping for testing
#1, "WshShell.SendKeys ";q$;"{ENTER}";q$
#1, "Wscript.Sleep(360)" 'this delay may need adjusting according to selected bas file size
#1, "WshShell.AppActivate ";q$;"saved as";q$
#1, "WshShell.SendKeys ";q$;"{ENTER}";q$
close #1
'loop until autoSave$ File is verified
do
res = fileExists(DestPath$,autoSave$)
if res then exit do
scan
loop until res
'#######################################################################
'Create the TKN file in Projects\current project folder.
RUN JBpath$;"\";JBexe$;" -T -A ";DestPath1$;"\";fname0$
'give time for the save TKN window to appear
for x = 1 to 550000
next x
'#######################################################################
'run the script to close the "save" dialog and the follow up notice of creation, automatically
run "wscript ";autoSave$
'#######################################################################
'loop until TKN File is verified saved
do
res = fileExists(DestPath1$,fnamenobas$;".tkn")
if res then exit do
scan
loop until res
call pause 1500
' copy TKN$ file to TKN dir, and date it
open DestPath1$;"\";fnamenobas$;".tkn" for input as #file
open DestPath$;"\";"TKN";"\";fnamenobas$;fixedDate$;".tkn" for output as #1
print #1, input$(#file, lof(#file));
close #file
close #1
'Check if iexpress.exe is installed (a built in Windows Install Maker = Self Extracting exe File)
[makeinst]
res=fileExists("c:\windows\system32","iexpress.exe")
if res then [makeexe] else notice "Cannot find file --> iexpress.exe in c:\windows\system32"+chr$(13)+"Known issue for users of WINE in Linux"+chr$(13)+"Check WINE Tricks for Adding the Windows Scripting host (wsh57) near the bottom of the list in Select Component or Dll.Get iexpress from the XP CD in i386 dir, named iepress,ex_ (extract iexpress.exe, place it in C:\Windows\System32, do the same for wextract.ex_ "
wait
[makeexe]
'makes 64 bit exe
'run iexpress commandline using the sed file created (sort of like an ini file)
express64$ = "C:\Windows\System32"
res=fileExists(express64$,"iexpress.exe")
if res then run "iexpress /N /q ";sedfile$ else noiex=1 : goto [noiex]
[verifyEXE]
'verify the exe file was created loop until it exists
do
res = fileExists(DestPath$;"\";"EXE",exe$)
if res then exit do
scan
loop until res
call pause 1500
[noiex]
' Delete .vbs file temp .txt and temp .bas files
res=fileExists(DefaultDir$,fnameTemp$)
if res then kill fnameTemp$
res=fileExists(DefaultDir$,"temp.txt")
if res then kill "temp.txt"
if fileExists(DestPath$;"\";"EXE", fnamenobas$;".exe") then a = a + 1 else [delete]
exefilename$ = DestPath$;"\";"EXE";"\";fnamenobas$;fixedDate$;".exe"
name DestPath$;"\";"EXE";"\";fnamenobas$;".exe" as DestPath$;"\";"EXE";"\";fnamenobas$;fixedDate$;".exe"
res=fileExists(DestPath$;"\EXE",exefilename$)
if res then a = a + 1 else notice exefilename$;" Does Not Exist in ";DestPath$;"\EXE"
[delete]
'delete the root sed file, FolderDialog.vbs script file and the autosave script file
res = fileExists(DefaultDir$,fnamenobas$;".sed")
if res then kill DefaultDir$;"\";fnamenobas$;".sed"
'delete folderdialog vbs script
if fileExists(DefaultDir$, "FolderDialog.vbs") then kill "FolderDialog.vbs"
'delete autosave.vbs
res=fileExists(DefaultDir$,autoSave$)
if res then kill autoSave$
end
'subs, and function below this line
'####################################################################################
sub pause mil
t=time$("ms")+mil
while time$("ms")<t
scan
wend
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