Post by xxgeek on Jul 31, 2021 2:22:34 GMT
Version 1.8 -
Should work in Linux if the instructions are followed, it's working for me on Linux Mint 20. (something)
It also works in Windows 10 here. Probably works in Win 7 and 8, but I doubt XP because the scripting host may be too early a version.
PLEASE, give me feedback on how this is working, and on what Operating system you're using.
Almost have a multifile select dialog working too. Well the multifile part is working as a function, but still trying to get the list of files to copy over to another folder without problems. Darn run command on the copy script makes it difficult since the program flow continues on when I need it to stop for a few seconds. Trying different techniques....
Should work in Linux if the instructions are followed, it's working for me on Linux Mint 20. (something)
It also works in Windows 10 here. Probably works in Win 7 and 8, but I doubt XP because the scripting host may be too early a version.
PLEASE, give me feedback on how this is working, and on what Operating system you're using.
Almost have a multifile select dialog working too. Well the multifile part is working as a function, but still trying to get the list of files to copy over to another folder without problems. Darn run command on the copy script makes it difficult since the program flow continues on when I need it to stop for a few seconds. Trying different techniques....
'BAS2EXE Version v1.8 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, and C:\Windows\SysWOW64
'You can install the WSH57 using winetricks "install a component" option >wsh57
'The webstract.exe file can be found on the XP install CD,
' or the ISO. In the i386 dir named
'webstract.ex_ It is an archive, so extract webstract.exe, place it in C:\Windows\System32,
'and C:\Windows\SysWOW64
'iexpress.ex_ is in the i386 dir too, do the same as done for webstract.ex_ if needed
'Place this bas file in it's own folder as it will create some folders and temp files as well as the above
'Choose 32bit exe or 64 bit exe - defaults to 64 bit if no selection made
'Option to password the EXE file. Check off the checkbox, [Select File] and enter a password when
' prompted. When bas2exe opens a filedialog to choose a bas file choose a bas file that is a
'good working bas file (or there will be trouble with the debugger) hit [ENTER]
'The "Save tkn" dialog and "saved as" dialog close automatically and save the tkn file to where it is needed.
'The next window is a Prompt to keep the project folder - or not
' If you keep the project folder you will have a "projects" folder with each saved project which
'includes the dll, sll files and jbrun2.exe(renamed), and the tkn file.
'The EXE File is saved to the EXE folder in the same folder as this program is located.
' Next Window is to choose to Run the EXE or choose to view the EXE Files Created by this Program
'
'Note - For standalone bas files only with no dependent files or folders - at this time
'If the .bas file you select runs in the JB IDE, the EXE will be made. If there are programming
'runtime errors your EXE could still crash at some point (Not BAS2EXE's fault)
'if it won't run in the JB IDE there will be an error reported by the JB debugger, and the JB window that
'opens will stay opened, close it manually.
'IMPORTANT INFORMATION
'To make an EXE of THIS BAS file, make a copy of it, and select that copy when you run THIS BAS file.
'Keep in mind that when you make an exe and run the exe it will run from a temp folder in folder
'C:\Users\YOURUSERNAME\Temp\IXP000.tmp (or very similar, like IXP001.tmp IXP002.tmp etc)
'This temp folder is where it unpacks the dll's,sll's, the renamed jbrun file, and tkn file
'This folder usually gets deleted when the program contained within is closed
'Again, the temp folder is where YOUR Windows Temp files are located in a folder named
'IXP000.tmp (or very similar, like IXP001.tmp IXP002.tmp etc)
'OR
'Better off using the TKN and add the tkn to the EXTERNAL PROGRAMS under Setup>Externals
' in JB IDE. That way there's no need to deal with the temp dir BS
'The EXE, TKN, BAS Folder, and Projects Folder will be in the same dir as the tkn file is run from.
'Don't put the tkn in a folder protected by Windows security.
'Enjoy
global selectedpath$
p = 0 'passworded exe defaults to false
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$
'[checkjbpath]
'check Just Basic v2.0 Default Install Dir for existence
JBpath$ = "c:\Program Files (x86)\Just Basic v2.0"
res=pathExists(JBpath$)
'if Just Basic v2.0 is NOT installed to it's Default Install Dir, get Path from User using folder dialog
if res then [go] else notice chr$(13)+" Just Basic v2.0 was not installed to the default install folder." +chr$(13)+"Hit [ok], then Select the Folder Just Basic v2.0 is Installed"
'if folder path chosen by user for Just Basic install is wrong catch error later with check for jbrun2.exe
a$ = getFolder$(a$)
JBpath$ = selectedpath$
[go]
' setup a Window for User to Select a .bas File to Make a Project with
nomainwin
WindowWidth = 600
WindowHeight = 380
UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
UpperLeftY=INT((DisplayHeight-WindowHeight)/2)
BackgroundColor$ = "lightgray"
ForegroundColor$ = "black"
'add some text ,some buttons, and checkboxes to the Window
statictext #pick.header, "BAS <2> EXE", 190, 20, 590, 45
statictext #pick.exe, "EXE FILE", 15, 70, 105, 30
statictext #pick.temp, "Temp Files", 390, 70, 105, 30
statictext #pick.datedtext, "Dated Files", 190, 70, 105, 30
statictext #pick.info, "Select a working Just Basic Source Code File (.bas)", 30, 220, 590, 30
statictext #pick.jbforums, "Visit the Just Basic Forums @ https://justbasiccom.proboards.com/", 90, 335, 590, 20
checkbox #pick.password, "Passworded", [yespass], [nopass], 20, 180, 140, 20
checkbox #pick.bit32, "32 Bit", [bit32], [nobit32], 20, 105, 80, 20
checkbox #pick.bit64, "64 Bit", [bit64], [nobit64], 20, 130, 80, 20
checkbox #pick.incbas, "Include Source", [incsource], [noincsource], 20, 155, 140, 20
checkbox #pick.sed, "Keep SED", [sed], [nosed], 400, 105, 140, 20
checkbox #pick.vbs, "Keep VBS", [vbs], [novbs], 400, 130, 140, 20
checkbox #pick.project, "Keep Project Dir", [project], [noproject], 400, 155, 160, 20
checkbox #pick.TKN, "Don't SaveTKN", [noTKN], [yesTKN], 200, 105, 140, 20
checkbox #pick.BAS,"Don't Save BAS", [noBAS], [yesBAS], 200, 130, 140, 20
button #pick.default, "Select File", [defaultClick],UL 140, 270, 135, 35
button #pick.32, "Cancel", [cancel],UL 320, 270, 135, 35
'open the Window, and set some Fonts for each statictext, and buttons
open "BAS2EXE v1.8" for window_nf as #pick
#pick, "trapclose [quit.pick]"
#pick, "font Arial 10 bold"
#pick.header, "!font Arial 24 bold"
#pick.exe, "!font Arial 14 bold"
#pick.temp, "!font Arial 14 bold"
#pick.datedtext, "!font Arial 14 bold"
#pick.sed, "font Arial 12 bold"
#pick.vbs, "font Arial 12 bold"
#pick.project, "font Arial 12 bold"
#pick.TKN, "font Arial 12 bold"
#pick.BAS, "font Arial 12 bold"
#pick.password, "font Arial 12 bold"
#pick.info, "!font Arial 18 bold"
#pick.jbforums "!font Arial 10 bold"
#pick.32, "!font Arial 12 bold"
#pick.bit64, "font Arial 12 bold"
#pick.bit32, "font Arial 12 bold"
#pick.incbas, "font Arial 12 bold"
#pick.default, "!font Arial 12 bold"
#pick.default, "!setfocus"
wait
''temp files saved or not (user choice)
[incsource]
incbas = 1
wait
[noincsource]
incbas = 0
wait
[sed]
sed = 1
wait
[nosed]
sed = 0
wait
[vbs]
vbs = 1
wait
[novbs]
vbs = 0
wait
[project]
project = 1
wait
[noproject]
project = 0
wait
[yesTKN]
tkn = 0
wait
[noTKN]
tkn = 1
wait
[yesBAS]
bas=0
wait
[noBAS]
bas = 1
wait
' passworded exe is true(user selected)
[yespass]
p=1
wait
'passworded exe is faulse, default
[nopass]
p=0
wait
'make 32 bit exe = true(user selected)
[bit32]
bit=32
#pick.bit64, "hide"
wait
'make 64 bit exe, default
[bit64]
bit=64
#pick.bit32, "hide"
wait
[nobit32]
bit=64
#pick.bit64, "show"
wait
[nobit64]
bit=0
#pick.bit32, "show"
wait
'close the opening window for Selecting bas file
[defaultClick]
close #pick
'check existence and JBPath$ (Just Basic default install dir)
res = pathExists(JBpath$)
if res then a = a + 1 else notice " Just Basic v2.0 was not was not found in ";JBpath$;" Restart BAS2EXE - Try Again":end
' Just Basic 2 is installed - continue on
'define some variables
'p=0 'passworded exe = false
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"
'Checking all paths and file locations for existence (dll's, sll's, jbasic.exe, and jbrun2.exe)
res=fileExists(JBpath$,JBexe$)
if res then a = a + 1 else notice JBexe$;" Does not exist in ";JBpath$;" Closing BAS2EXE" : end
res=fileExists(JBpath$,JBruntime$)
if res then a = a + 1 else notice JBrun$;" Does not exist in ";JBpath$;" Closing BAS2EXE" : end
res=fileExists(JBpath$,"vbas31w.sll")
if res then a = a + 1 else notice " vbas31w.sll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
res=fileExists(JBpath$,"vgui31w.sll")
if res then a = a + 1 else notice " vgui31w.sll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
res=fileExists(JBpath$,"voflr31w.sll")
if res then a = a + 1 else notice " voflr31w.sll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
res=fileExists(JBpath$,"vthk31w.dll")
if res then a = a + 1 else notice " vthk31w.dll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
res=fileExists(JBpath$,"vtk1631w.dll")
if res then a = a + 1 else notice " vtk1631w.dll Does not exist in ";JBpath$;" BAS2EXE" : end
res=fileExists(JBpath$,"vtk3231w.dll")
if res then a = a + 1 else notice " vtk3231w.dll Does not exist in ";JBpath$;" BAS2EXE" : end
res=fileExists(JBpath$,"vvm31w.dll")
if res then a = a + 1 else notice " vvm31w.dll Does not exist in ";JBpath$;" BAS2EXE" : end
res=fileExists(JBpath$,"vvmt31w.dll")
if res then a = a + 1 else notice " vvmt31w.dll Does not exist in ";JBpath$;" Closing BAS2EXE":end
' all needed files accounted for
'prompt user for a password to start the created EXE File
if p=0 then [filediag]
if p= 1 then Prompt "TYPE a PASSWORD"+chr$(13)+ "Password for EXE file is: (no spaces)";passwerd$
if passwerd$ = "" then notice "BAS2EXE will continue, without placing a password on the EXE file created"
' 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)
res= mkdir(DefaultDir$;"\";"SED") ' saves the created SED file (self extracting directive)
res= mkdir(DefaultDir$;"\";"VBS") ' saves VBS file (.vbs script that auto clicks `save tkn`, and `saved as` buttons)
'make sure Folders were actually created
res=pathExists(DestPathU$)
if res then a=a+1 else notice "Projects folder was NOT Created in ";DestPath$ : end
res=pathExists(DestPath1$)
if res then a=a+1 else notice "New Folder ";fnamenobas$;" was NOT Created in ";DestPath1$ : end
tknFolder$=DefaultDir$;"\";"TKN"
res=pathExists(tknFolder$)
if res then a=a+1 else notice "TKN Folder was NOT Created in ";DestPath$ : end
basFolder$=DefaultDir$;"\";"BAS"
res=pathExists(basFolder$)
if res then a=a+1 else notice "BAS Folder was NOT Created in ";DestPath$ : end
'remove existing fname0$ from dir before creating new one
res = fileExists(DestPath1$, fname0$)
if res then kill DestPath1$;"\";fname0$
'copy selected bas file to Projects\current project folder
q$= chr$(34)
open fname$ for input as #fname
fnameTemp$="tempBas.bas"
open fnameTemp$ for output as #2
'add a password prompt to the begining of the temp bas file(to be added to the exe)
if p=0 then [nopasswerd] '
print #2, "prompt ";q$;"Enter the Password";q$;";";"passwerd$"
print #2, "if passwerd$ <> ";q$;passwerd$;q$;" then end"
[nopasswerd]
print #2, input$(#fname, lof(#fname));
close #fname
close #2
'copy temp.bas file to current project folder
open fnameTemp$ 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$;" P.O. will now close" : close #main : end
'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")
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
'verify dll's and sll's were copied to temp folder
res=fileExists(DestPath1$,"vbas31w.sll")
if res then a = a + 1 else notice " vbas31w.sll Was not created in --> ";DestPath1$;" bas2exe will now close":end
res=fileExists(DestPath1$,"vgui31w.sll")
if res then a = a + 1 else notice " vgui31w.sll Was not created in --> ";DestPath1$;" bas2exe will now close":end
res=fileExists(DestPath1$,"voflr31w.sll")
if res then a = a + 1 else notice " voflr31w.sll Was not created in --> ";DestPath1$;" bas2exe will now close":end
res=fileExists(DestPath1$,"vthk31w.dll")
if res then a = a + 1 else notice " vthk31w.dll Was not created in --> ";DestPath1$;" bas2exe will now close":end
res=fileExists(DestPath1$,"vtk1631w.dll")
if res then a = a + 1 else notice " vtk1631w.dll Was not created in --> ";DestPath1$;" bas2exe will now close":end
res=fileExists(DestPath1$,"vtk3231w.dll")
if res then a = a + 1 else notice " vtk3231w.dll Was not created in --> ";DestPath1$;" bas2exe will now close":end
res=fileExists(DestPath1$,"vvm31w.dll")
if res then a = a + 1 else notice " vvm31w.dll Was not created in --> ";DestPath1$;" bas2exe will now close":end
res=fileExists(DestPath1$,"vvmt31w.dll")
if res then a = a + 1 else notice " vvmt31w.dll Was not created in --> ";DestPath1$;" bas2exe will now close":end
'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 500
' 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 IExpress(after each update)"
wait
[makeexe]
'makes 64 bit exe
if bit=32 then [do32bit]
'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]
'makes 32 bit exe
[do32bit]
if bit = 64 or bit = 0 then [verifyEXE]
express32$ = "C:\Windows\SysWOW64"
res=fileExists(express32$,"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 4000
[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"
'keep sed file if user chose to
res = fileExists(DefaultDir$, fnamenobas$;".sed")
if res and sed = 1 then
open fnamenobas$;".sed" for input as #file
open DestPath$;"\";"SED";"\";fnamenobas$;".sed" for output as #1
print #1, input$(#file, lof(#file));
close #file
close #1
end if
'keep autosave vbs script if user cose to
res = fileExists(DefaultDir$, autoSave$)
if res and sed = 1 then
open autoSave$ for input as #file
open DestPath$;"\";"VBS";"\";autoSave$ for output as #1
print #1, input$(#file, lof(#file));
close #file
close #1
end if
[main]
'create a window with 2 buttons for options to view or run the new exe file.
nomainwin
WindowWidth = 400
WindowHeight = 320
UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
UpperLeftY=INT((DisplayHeight-WindowHeight)/2)
BackgroundColor$ = "lightgray"
ForegroundColor$ = "black"
statictext #main.jbforums, "Visit https://justbasiccom.proboards.com/", 70, 240, 450, 35
button #main.browseN, "View EXE Files", [browseN],UL 120, 100, 150, 35
button #main.run, "Run EXE File", [progrun],UL 120, 160, 150, 35
'Set Font's for this window, statictext, and buttons
open "Two Options" for window_nf as #main
#main, "trapclose [quit.main]"
#main, "font Arial 10 bold"
#main.browseN, "!font Arial 12 bold"
#main.run, "!font Arial 12 bold"
wait
'open Windows explorer to the EXE Files
[browseN]
run "explorer.exe ";DestPath$;"\EXE"
wait
'Run the created exe file
[progrun]
do
res=fileExists(DestPath$;"\";"EXE", fnamenobas$;".exe")
if res then exit do
scan
loop until res
'run the new exe file to test it
res = fileExists(DestPath$;"\";"EXE", fnamenobas$;".exe")
if res then run DestPath$;"\";"EXE";"\";fnamenobas$;".exe" else notice fnamenobas$;".exe";" Does Not Exist in ";DestPath$;"\EXE"
wait
[quit.main]
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(if user chose to)
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$
res = fileExists(DestPath$;"\TKN", fnamenobas$;fixedDate$;".tkn")
if res and tkn = 1 then kill DestPath$;"\TKN\";fnamenobas$;fixedDate$;".tkn"
res = fileExists(DestPath$;"\BAS", fnamenobas$;fixedDate$;".bas")
if res and bas = 1 then kill DestPath$;"\BAS\"; fnamenobas$;fixedDate$;".bas"
remove = 1
'delete the current project dir and files files (copied bas file, tkn file, sll,dll, jbrun2.exe(renamed file)
'if user chose to "not include" this project dir
'[remprogdir]
if project = 0 and remove = 1 then
kill DestPath1$;"\";"vbas31w.sll"
kill DestPath1$;"\";"vgui31w.sll"
kill DestPath1$;"\";"voflr31w.sll"
kill DestPath1$;"\";"vthk31w.dll"
kill DestPath1$;"\";"vtk1631w.dll"
kill DestPath1$;"\";"vtk3231w.dll"
kill DestPath1$;"\";"vvm31w.dll"
kill DestPath1$;"\";"vvmt31w.dll"
kill DestPath1$;"\";exe$
kill DestPath1$;"\";fnamenobas$;".tkn"
kill DestPath1$;"\";fnamenobas$;".bas"
'kill DestPath1$;"\";fname0$
end if
'delete the current project dir
if pathExists(DestPath1$) then deldir = rmdir(DestPath1$)
close #main
end
[quit.pick]
close #pick
end
[cancel]
close #pick
end
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
'functions for making the folder dialog window
'Must add selectedpath$ to "global" at top of your bas file eg: global selectedpath$
function getFolder$(a$)
q$ = chr$(34) ' quotes
'write the following vbs script to temp file named FolderDialog.vbs
folderDialog$ = "FolderDialog.vbs"
open folderDialog$ for output as #1
'print each line to file (FolderDialog.vbs)
#1,"Function BrowseFolder( myStartLocation, blnSimpleDialog )"
#1,"Const MY_COMPUTER = &H11&"
#1,"Const WINDOW_HANDLE = 0"
#1,"Dim numOptions, objFolder, objFolderItem"
#1,"Dim objPath, objShell, strPath, strPrompt"
#1,"strPrompt = ";q$;"Select Just Basic v2.0 Install Folder ";q$ 'destination dialog
#1,"If blnSimpleDialog = True Then"
#1,"numOptions = 0"
#1,"Else"
#1,"numOptions = &H10&"
#1,"End If"
#1,"Set objShell = CreateObject( ";q$;"Shell.Application";q$;" )"
#1,"If UCase( myStartLocation ) = ";q$;"MY COMPUTER";q$;" Then"
#1,"Set objFolder = objShell.Namespace( MY_COMPUTER )"
#1,"Set objFolderItem = objFolder.Self"
#1,"strPath = objFolderItem.Path"
#1,"Else"
#1,"strPath = myStartLocation"
#1,"End If"
#1,"Set objFolder = objShell.BrowseForFolder( WINDOW_HANDLE, strPrompt, _"
#1,"numOptions, strPath )"
#1,"If objFolder Is Nothing Then"
#1,"BrowseFolder = ";q$;q$
#1,"Exit Function"
#1,"End If"
#1,"Set objFolderItem = objFolder.Self"
#1,"objPath = objFolderItem.Path"
#1,"BrowseFolder = objPath"
#1,"End Function"
#1,"Dim bf"
#1,"bf = BrowseFolder( ";q$;"My Computer";q$;", False )"
#1,"Dim fso : Set fso = CreateObject(";q$;"Scripting.FileSystemObject";q$;")"
#1,"Dim sp : sp = fso.GetFile(Wscript.ScriptFullName)"
#1,"Dim fp: fp = fso.GetParentFolderName(sp) & ";q$;"\FolderPath.txt";q$
#1,"Dim f : Set f = fso.CreateTextFile(fp)"
#1,"f.WriteLine bf"
#1,"f.Close"
close #1
'loop until FolderDialog.vbs existence is verified
do
res = fileExists(DefaultDir$,folderDialog$)
if res then exit do
scan
loop until res
'run the script (creates temp file FolderPath.txt)
run "wscript ";"FolderDialog.vbs"
'loop until the selected folder path is written to temp file (FolderPath.txt)
do
folderpath$ = "FolderPath.txt"
res = fileExists(DefaultDir$,folderpath$)
if res then exit do
scan
loop until res
'get the text in FolderPath.txt (the selected path of folder)
open folderpath$ for input as #1
line input #1, line$(x)
selectedpath$ = line$(x)
kill folderpath$
close #1
if selectedpath$ = "" or left$(selectedpath$,1) = ":" or left$(selectedpath$,1) = "\" then notice "No Folder selected" : wait
end function