Post by xxgeek on Jul 1, 2021 1:06:43 GMT
EDIT - I will update these 2 files in this First post to avoid any confusion whenever updates are made.
Probably only works in Win 10, but may work in other OS's I can't test it on. If iexpress exists this will most likely work.
I have managed to use iexpress in Windows 10 to create the exe file. Basically a self extracting file that executes an exe file created by renaming the JB runtime file.
Place this bas file into a folder to run it, it creates some files and a folder itself in same dir it is run from
When BAS2EXE opens it opens directly to the filedialog to select a bas file.
It then copies the dll, and sll files along with jbrun.exe (and renames it) to a temp folder in same dir as this file is run from.
It creates a sed file needed by the iexpress commandline to use.
Once done it pops up a notice to delete the temp files. (If you want to keep all the temp files (which are in a projects folder in same dir as this bas file is run from) just comment out the lines.
It also deletes the sed file so same instructions apply if you want to keep it.
Before you OK the Notice, you can goto the dir this bas file is running from and copy them if desired.
I haven't been doing much programming lately, but thought some of you might like this little app I created for Project Organizer.
EDIT - Changed the Notice to a Prompt (I hate the sound a Notice makes)
- Forgot to mention - This works with standalone bas files at this time. No support yet for dependent files like .bmp wav or other files and folders.
Edit - Updated code documentation for clarity
Added a switch to iexpress command to run quietly, no more window popping up showing progress (black window)
Edit - Found and fixed a problem with hanging when there are spaces in the selected bas file name.
Updated both passworded, and non passworded exe file code. see code for both below.
If your selected bas file has spaces in it the finished product will be the same name, but without the spaces.
BAS2EXE (Without Passworded EXE File)
BAS2EXE-P (With Passworded EXE File)
Probably only works in Win 10, but may work in other OS's I can't test it on. If iexpress exists this will most likely work.
I have managed to use iexpress in Windows 10 to create the exe file. Basically a self extracting file that executes an exe file created by renaming the JB runtime file.
Place this bas file into a folder to run it, it creates some files and a folder itself in same dir it is run from
When BAS2EXE opens it opens directly to the filedialog to select a bas file.
It then copies the dll, and sll files along with jbrun.exe (and renames it) to a temp folder in same dir as this file is run from.
It creates a sed file needed by the iexpress commandline to use.
Once done it pops up a notice to delete the temp files. (If you want to keep all the temp files (which are in a projects folder in same dir as this bas file is run from) just comment out the lines.
It also deletes the sed file so same instructions apply if you want to keep it.
Before you OK the Notice, you can goto the dir this bas file is running from and copy them if desired.
I haven't been doing much programming lately, but thought some of you might like this little app I created for Project Organizer.
EDIT - Changed the Notice to a Prompt (I hate the sound a Notice makes)
- Forgot to mention - This works with standalone bas files at this time. No support yet for dependent files like .bmp wav or other files and folders.
Edit - Updated code documentation for clarity
Added a switch to iexpress command to run quietly, no more window popping up showing progress (black window)
Edit - Found and fixed a problem with hanging when there are spaces in the selected bas file name.
Updated both passworded, and non passworded exe file code. see code for both below.
If your selected bas file has spaces in it the finished product will be the same name, but without the spaces.
BAS2EXE (Without Passworded EXE File)
'Title - BAS2EXE
'Author - xxgeek, a member of the justbasiccom.proboards.com/ forums
'When Run, 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]
'When the next dialog window appears, hit[ENTER] or Click SAVE (saves the tkn file to where it is needed)
'The next window is a Notice (needed to stall the process) and deletes the temp files when clicked.
'The EXE File is saved to the sane dir as this program is located.
'Choose to Run the EXE or Choose to view the EXE Files Created by this Program
'Note - For standalone bas files with no dependent files or folders at this time
'Enjoy
titlebar "BAS2EXE"
projects$ = "projects"
[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
if res then [go] else notice " 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"
JBpath$ = FolderDialog$("Select the Folder Where You Installed Just Basic v2.0")
if JBpath$ = "" then notice "No path given - closing BAS2EXE" : end
'check existence and JBPath$
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
[go]
JBexe$ = "jbasic.exe"
JBruntime$ = "jbrun2.exe"
DllList$="vbas31w.sll vgui31w.sll voflr31w.sll vthk31w.dll vtk1631w.dll vtk3231w.dll vvm31w.dll vvmt31w.dll"
'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
'files accounted for -
' Use the filedialog function to allow user to select a source file (.bas)
[defaultClick]
filedialog "Open \ Select a Just Basic Source File (.bas) ", DefaultDir$; "\*.bas", fname$
if fname$ = "" then notice "No file selected, BAS2EXE will now close" : end
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)
open "temp.txt" for output as #1
for x = 1 to len(fname0$)
keeper$=mid$(fname0$, x, 1)
if keeper$ <> " " then print #1, keeper$;
next x
close #1
dim array$(250)
open "temp.txt" for input as #1
while eof(#1) = 0
line input #1, array$(x)
line$ = array$(x)
x = x + 1
fname0$ = line$
wend
close #1
kill "temp.txt"
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]
DestPath$=DefaultDir$
DestPathU$ = DestPath$;"\";projects$
'define Destpath1$ as JB Projects\Current Project Folder
DestPath1$=DestPathU$;"\";fnamenobas$
'Make Folders for Just Basic Projects and Current ProjectName
res = mkdir(DestPathU$)
res = mkdir( DestPath1$)
'make sure Folders were actuaally created
res=pathExists(DestPathU$)
if res then a = a + 1 else notice "Just Basic Projects Folder was NOT Created in ";DestPath$:close #main : end
res=pathExists(DestPath1$)
if res then a = a + 1 else notice "New Folder";fnamenobas$;" was NOT Created in ";DestPath1$:close #main : end
if fileExists(DestPath1$, fname0$) then kill DestPath1$;"\";fname0$
'copy the project .bas file to this projects dir
open fname$ for input as #fname
open DestPath1$;"\";fname0$ for output as #1
print #1, input$(#fname, lof(#fname));
close #fname
close #1
'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
'################################################################################
'Create the TKN file.
RUN JBpath$;"\";JBexe$;" -T -A ";DestPath1$;"\";fname0$
'loop until TKN File is saved
do
res = fileExists(DestPath1$,fnamenobas$;".tkn")
if res then exit do
scan
loop until res
'################################################################################
if fileExists(DestPath1$, JBruntime$) then kill DestPath1$;"\"; JBruntime$
'copy jbrun2.exe to Temporary 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
'rename jbrun2.exe to name of User Selected .bas File - .bas +.exe
if fileExists(DestPath1$, fnamenobas$ + ".exe") then kill DestPath1$;"\";fnamenobas$ + ".exe"
'Just Basic can't create\rename a file that exists, so if it does already exist - kill it (delete it)
name DestPath1$;"\";JBruntime$ as DestPath1$;"\";fnamenobas$ + ".exe"
'Copy the needed DLL and SLL files from Just Basic dir to Temp 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$
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 sll's and 'jbrun2.exe' were copied to temp folder, and jbrun2.exe renamed
if res then a = a + 1 else notice " jbrun2.exe Does not exist on the given path -> ";JBpath$;"\";JBruntime$;" bas2exe will now close":end
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
'check new exe and tkn files for existence in Temp Folder )
res=fileExists(DestPath1$,fnamenobas$;".exe")
if res then a=a+1 else notice "jbrun2.exe not copied or renamed - EXITING ": end
'Start iexpress.exe (a built in Windows Install Maker = Self Extracting exe File)
[makeinst]
res=fileExists("c:\windows\system32","iexpress.exe")
if res then [makeSed] 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
[makeSed]
q$=chr$(34) ' quotes
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$;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
'loop till tkn is verified
do
res = fileExists(DestPath1$,fnamenobas$;".tkn")
if res then exit do
scan
loop until res
'run iexpress commandline using the sed file created (sort of like an ini file)
run "iexpress /N /q ";sedfile$
'verify the exe file was created loop until it exists
newfile$=fnamenobas$;".exe"
do
res = fileExists(DestPath$,newfile$)
if res then exit do
scan
loop until res
'choice for user to keep or delete the temp files(saved projects folder and the sed file)
choice$="yes"
prompt "Delete Temp Files";choice$
if choice$="yes" then [remdir]
if choice$ <> "yes" then [main]
'delete all the temp files (copied bas file, tkn file, sll,dll, jbrun2.exe(renamed file) and the sed file
[remdir]
kill sedfile$
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$;"\";fname0$
kill DestPath1$;"\";sedtkn$
'delete the temp dir's
dirname$=DestPath$;"\";projects$;"\";fnamenobas$
dirname2$=DestPath$;"\";projects$
deldir = rmdir(dirname$)
deldir2=rmdir(dirname2$)
newfile$=fnamenobas$;".exe"
'create a window with 2 buttons for options to view or run the new exe file.
[main]
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$
wait
'Run the created exe file
[progrun]
res=fileExists(DestPath$,fnamenobas$;".exe")
if res then run DestPath$;"\";fnamenobas$;".exe" else notice fnamenobas$;" Does Not Exist in ";DestPath$
wait
[quit.main]
close #main
end
'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", 45, 15, 550, 25
statictext #folderdlg.S, "Select a Drive or a Folder From the List", 175, 40, 300, 25
statictext #folderdlg.D, " (Double Click Drive Letters and Folders to Select or Navigate)", 85, 70, 395, 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, 490, 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 10 bold"
#folderdlg, "font Arial 10 bold"
#folderdlg.S, "!font Arial 10 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"
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
BAS2EXE-P (With Passworded EXE File)
'Title - BAS2EXE-P
'Created July 2021
'Author - xxgeek, a member of the - justbasiccom.proboards.com/ - forums
'When Run, 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]
'When the next dialog window appears, hit[ENTER] or Click SAVE (saves the tkn file to where it is needed)
'The next window is a Notice (needed to stall the process) and deletes the temp files when clicked.
'The EXE File is saved to the same dir as this program is located.
'Choose to Run the EXE or Choose to view the EXE Files Created by this Program
'Note - For standalone bas files - with no support for dependent files or folders at this time
'to change the password - Find this line - print #2, "if password$ <> ";q$;"xxgeek";q$;" then end"
'change xxgeek to whatever you like (don't forget your new password).
'use a stronger password like q3h%C83N!lHQ59T~
'The exe will NOT run without the password entered first.
'Enjoy
titlebar "BAS2EXE"
projects$ = "projects"
[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
if res then [go] else notice " 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"
JBpath$ = FolderDialog$("Select the Folder Where You Installed Just Basic v2.0")
if JBpath$ = "" then notice "No path given - closing BAS2EXE" : end
'check existence and JBPath$
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
[go]
JBexe$ = "jbasic.exe"
JBruntime$ = "jbrun2.exe"
DllList$="vbas31w.sll vgui31w.sll voflr31w.sll vthk31w.dll vtk1631w.dll vtk3231w.dll vvm31w.dll vvmt31w.dll"
'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
'files accounted for -
' Use the filedialog function to allow user to select a source file (.bas)
[defaultClick]
filedialog "Open \ Select a Just Basic Source File (.bas) ", DefaultDir$; "\*.bas", fname$
if fname$ = "" then notice "No file selected, BAS2EXE will now close" : end
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)
open "temp.txt" for output as #1
for x = 1 to len(fname0$)
keeper$=mid$(fname0$, x, 1)
if keeper$ <> " " then print #1, keeper$;
next x
close #1
dim array$(250)
open "temp.txt" for input as #1
while eof(#1) = 0
line input #1, array$(x)
line$ = array$(x)
x = x + 1
fname0$ = line$
wend
close #1
kill "temp.txt"
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]
DestPath$=DefaultDir$
DestPathU$ = DestPath$;"\";projects$
'define Destpath1$ as JB Projects\Current Project Folder
DestPath1$=DestPathU$;"\";fnamenobas$
'Make Temp Folders for Projects and Current basFileName
res = mkdir(DestPathU$)
res = mkdir( DestPath1$)
'make sure Folders were actually created
res=pathExists(DestPathU$)
if res then a = a + 1 else notice "Just Basic 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
if fileExists(DestPath1$, fname0$) then kill DestPath1$;"\";fname0$
'copy the project .bas file to this projects dir
q$= chr$(34)
open fname$ for input as #fname
fnameTemp$="tempBas.bas"
open fnameTemp$ for output as #2
print #2, "prompt ";q$;"Enter Password";q$;";";"password$"
print #2, "if password$ <> ";q$;"xxgeek";q$;" then end"
print #2, input$(#fname, lof(#fname));
close #fname
close #2
open fnameTemp$ for input as #fnameTemp
open DestPath1$;"\";fname0$ for output as #1
print #1, input$(#fnameTemp, lof(#fnameTemp));
close #1
close #fnameTemp
for pause = 1 to 3000
next pause
'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
'################################################################################
'Create the TKN file.
RUN JBpath$;"\";JBexe$;" -T -A ";DestPath1$;"\";fname0$
'loop until TKN File is saved
do
res = fileExists(DestPath1$,fnamenobas$;".tkn")
if res then exit do
scan
loop until res
'################################################################################
if fileExists(DestPath1$, JBruntime$) then kill DestPath1$;"\"; JBruntime$
'copy jbrun2.exe to Temporary 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
'rename jbrun2.exe to name of User Selected .bas File - .bas +.exe
if fileExists(DestPath1$, fnamenobas$ + ".exe") then kill DestPath1$;"\";fnamenobas$ + ".exe"
'Just Basic can't create\rename a file that exists, so if it does already exist - kill it (delete it)
name DestPath1$;"\";JBruntime$ as DestPath1$;"\";fnamenobas$ + ".exe"
'Copy the needed DLL and SLL files from Just Basic dir to Temp 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$
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 sll's and 'jbrun2.exe' were copied to temp folder, and jbrun2.exe renamed
if res then a = a + 1 else notice " jbrun2.exe Does not exist on the given path -> ";JBpath$;"\";JBruntime$;" bas2exe will now close":end
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
'check new exe and tkn files for existence in Temp Folder )
res=fileExists(DestPath1$,fnamenobas$;".exe")
if res then a=a+1 else notice "jbrun2.exe not copied or renamed - EXITING ": end
'Start iexpress.exe (a built in Windows Install Maker = Self Extracting exe File)
[makeinst]
res=fileExists("c:\windows\system32","iexpress.exe")
if res then [makeSed] 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
[makeSed]
q$=chr$(34) ' quotes
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$;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
'loop till tkn is verified
do
res = fileExists(DestPath1$,fnamenobas$;".tkn")
if res then exit do
scan
loop until res
do
res = fileExists(DefaultDir$,sedfile$)
if res then exit do
scan
loop until res
'run iexpress commandline using the sed file created (sort of like an ini file)
run "iexpress /N /q ";sedfile$
'verify the exe file was created loop until it exists
newfile$=fnamenobas$;".exe"
do
res = fileExists(DestPath$,newfile$)
if res then exit do
scan
loop until res
bas$=DestPath1$;"\";fname0$
kill bas$
kill "tempBas.bas"
'choice for user to keep or delete the temp files(saved projects folder and the sed file)
choice$="yes"
prompt "Delete Temp Files";choice$
if choice$="yes" then [remdir]
if choice$ <> "yes" then [main]
'delete all the temp files (copied bas file, tkn file, sll,dll, jbrun2.exe(renamed file) and the sed file
[remdir]
kill sedfile$
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$;"\";sedtkn$
'delete the temp dir's
dirname$=DestPath$;"\";projects$;"\";fnamenobas$
dirname2$=DestPath$;"\";projects$
deldir = rmdir(dirname$)
deldir2=rmdir(dirname2$)
newfile$=fnamenobas$;".exe"
'create a window with 2 buttons for options to view or run the new exe file.
[main]
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$
wait
'Run the created exe file
[progrun]
res=fileExists(DestPath$,fnamenobas$;".exe")
if res then run DestPath$;"\";fnamenobas$;".exe" else notice fnamenobas$;" Does Not Exist in ";DestPath$
wait
[quit.main]
close #main
end
'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", 45, 15, 550, 25
statictext #folderdlg.S, "Select a Drive or a Folder From the List", 175, 40, 300, 25
statictext #folderdlg.D, " (Double Click Drive Letters and Folders to Select or Navigate)", 85, 70, 395, 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, 490, 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 10 bold"
#folderdlg, "font Arial 10 bold"
#folderdlg.S, "!font Arial 10 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"
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