Post by xxgeek on Jan 29, 2023 23:06:59 GMT
The code below
1. Creates a single EXE file from a .bas file selected by the User.
2. Creates a Shortcut on the Desktop to itself after it is run
3. Creates a hotkey [cntrl]+[alt]+E to open itself in GUI mode
4. Adds command line support for BAS2EXE (open a command prompt and type b2e)
_ or type b2e -pathTo.basFile -destinationPath /bas /dt /kp/ pw /q /r /s /tkn /v'number /bit'number
More info on using the switches etc at the top of the code.
Instructions on first use.....
1 - Use the Copy Code link in this post (click on it)
2 - Open Just Basic v2.0
3 - Paste the copied code into the Just Basic IDE
4 - Save as b2e.bas (in a folder of it's own - very important)
5 - In Just Basic IDE goto the top menu and click on Run> Run
6 - After it completes and a Menu appears you can delete the folder and the b2e.bas file you created above.
Use the Desktop shortcut to Run this program in GUI mode.
Use [cntrl]+[alt]+E to Run this program in GUI mode.
Open a command prompt and type b2e to Run this program in GUI mode.
You can also pin the shortcut to the start menu or the taskbar by right clicking it and selecting either option.
To Run on the command line see the top of this code for information on the command line switches, and default settings.
VERY Important....
ONLY use proven .bas files
Proven = .bas files that have worked without errors in Just Basic v2.0 IDE
edit - New version # = v1.8.9c
- Hardened some more
- added option to view EXE on completion(GUI, and Command Modes)
- added ini file creation for users with non default JB install dir
-_ to save JB install path
- fixed shortcut icon
edit - New Version 1.9.0
' changed method of auto[enter] of TKN creation "save as" dialog, and "Information" notice
' changed file verification loops of created exe file and tkn file to allow escape from loop after a set time
' _ to avoid infinite looping with BAS2EXE running invisible, forcing user to use taskmanager to close
' _ when/if exe file or tkn file is NOT created for whatever reason
' added detection of spaces in filename. IEXPRESS will not create a file with spaces in the name of the
' _source file - BAS2EXE will give Notice, then close when Notice closes.
' Tested on files up to 3000 lines - User may need to increase the 2 largest pauses if files have
' _ 3000+ lines of code (look for 'call pause 1500') - 2 of them
1. Creates a single EXE file from a .bas file selected by the User.
2. Creates a Shortcut on the Desktop to itself after it is run
3. Creates a hotkey [cntrl]+[alt]+E to open itself in GUI mode
4. Adds command line support for BAS2EXE (open a command prompt and type b2e)
_ or type b2e -pathTo.basFile -destinationPath /bas /dt /kp/ pw /q /r /s /tkn /v'number /bit'number
More info on using the switches etc at the top of the code.
Instructions on first use.....
1 - Use the Copy Code link in this post (click on it)
2 - Open Just Basic v2.0
3 - Paste the copied code into the Just Basic IDE
4 - Save as b2e.bas (in a folder of it's own - very important)
5 - In Just Basic IDE goto the top menu and click on Run> Run
6 - After it completes and a Menu appears you can delete the folder and the b2e.bas file you created above.
Use the Desktop shortcut to Run this program in GUI mode.
Use [cntrl]+[alt]+E to Run this program in GUI mode.
Open a command prompt and type b2e to Run this program in GUI mode.
You can also pin the shortcut to the start menu or the taskbar by right clicking it and selecting either option.
To Run on the command line see the top of this code for information on the command line switches, and default settings.
VERY Important....
ONLY use proven .bas files
Proven = .bas files that have worked without errors in Just Basic v2.0 IDE
edit - New version # = v1.8.9c
- Hardened some more
- added option to view EXE on completion(GUI, and Command Modes)
- added ini file creation for users with non default JB install dir
-_ to save JB install path
- fixed shortcut icon
edit - New Version 1.9.0
' changed method of auto[enter] of TKN creation "save as" dialog, and "Information" notice
' changed file verification loops of created exe file and tkn file to allow escape from loop after a set time
' _ to avoid infinite looping with BAS2EXE running invisible, forcing user to use taskmanager to close
' _ when/if exe file or tkn file is NOT created for whatever reason
' added detection of spaces in filename. IEXPRESS will not create a file with spaces in the name of the
' _source file - BAS2EXE will give Notice, then close when Notice closes.
' Tested on files up to 3000 lines - User may need to increase the 2 largest pauses if files have
' _ 3000+ lines of code (look for 'call pause 1500') - 2 of them
' Use at your own risk - Author accepts NO liabilities
' Author = xxgeek - a member of the Just Basic Forums '########################################################################################
' IMPORTANT
' before running this code - save this code to a file named b2e.bas - (in a folder of it's own)
' If you do not wish to have commandline support, which copies the files of this app, along
' _with creating folders and new files, in the Users Home dir, you can delete or uncomment
' _the following 3 lines of code in the top 1st block of code..
'if not(fileExists(DefaultDir$, "b2e.exe")) then
'command = 1 : firstRun = 1 : project = 1 : fname$ = DefaultDir$;"\b2e.bas" : goto [checkjbpath]
'end if
'If you do the above, disregard deleting the folder after first run, it will be needed.
'You can run the .bas from there, or create the TKN file, and run it from there.
'Instructions on first use.....
'1 - Use the Copy Code link in this post (click on it)
'2 - Open Just Basic v2.0
'3 - Paste the copied code into the Just Basic IDE
'4 - Save as b2e.bas (in a folder of it's own - very important)
'5 - In Just Basic IDE goto the top menu and click on Run> Run
'6 - After it completes and a Menu appears you can delete the folder and '_the b2e.bas file you created above.
'There should be a shortcut named BAS2EXE on your desktop.
' Put it wherever you like, and use it to open BAS2EXE GUI.
'########################################################################################
'BAS2EXE Version v1.9.0c For Windows 10 (possibly XP, 7, 8 and 11) - try it and let me know
' Date Introduced to Public = Jan 29 2023
' Title - BAS2EXE v1.9.0c (with CommandLine support)
' Author - xxgeek, a member of the justbasiccom.proboards.com/ forums
' {Purpose} - To automate bas file to exe file (self extracting exe) making creation quick and easy while
' storing dated copies (users choice), of every selected bas file, the created tkn, and the created exe (self extracting)
' exe file containing the dll files, 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 their appropriate folders, EXE, TKN, and BAS
' NOTE -They will be overwritten if the same .bas file is selected on the same day within one minute
' The options are user generated by selecting the appropriate checkboxes (GUI)
' Or by Using the appropriate switches (Command Mode)
'GUI MODE
' Place this bas file in it's own folder as it will create some folders and temp files as well as the above
' IMPORTANT > Name this file b2e.bas (or it won't work)
' After first run, delete the folder, including the folders created, and the b2e.bas file
'_ they are no longer needed as this app copies it's files to the users home dir
' There will be a shortcut on the desktop created, use this to open BAS2EXE from now on.
' Note - The Home dir is used in order to make the command line work properly
' 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 compiler)
' Add a version number and or Date/Time stamp the EXE filename
' View the Menu after EXE file creation
'The "Save tkn" file dialog and the Information "saved as" dialog close automatically and save the tkn file to where it is needed.
' If you keep the project folders you will have a "project" folder with each saved project which
'_ includes the dll, sll files and jbrun2.exe(renamed), the selected .bas file and the tkn file.
'The EXE File is saved to the EXE folder in the same folder as this program is located.
' _unless otherwise specified for eg: when using the (CommandLine) and not the GUI (no GUI option for destination - v2.0 maybe )
' Next Window is to choose to Run the EXE or view the EXE Files Created by this Program
'_ or Make a New EXE
' Note - For standalone bas files only with no dependent files or folders - at this time (Maybe Version 2, we''ll see)
' If the .bas file you select runs in the JB IDE when RUN, 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 compiler when this app attempts to
'_ make the tkn file, and the JB window that opens showing the code for the selected bas file will stay opened
'_, close it manually.
'IMPORTANT INFORMATION
' This new version has CommandLine support, meaning it works from a command prompt.
' or it can be used in code projects with the Run command as well.
'COMMAND MODE
' Syntax for commandline:
' If using the EXE
' b2e -sourceFilePath\file.bas -destinationPath /bas /dt /kp /pw /r /s /tkn /v'number' /bit'number'
' or b2e.exe -sourceFilePath\file.bas -destinationPath /bas /dt /kp /pw /r /s /tkn /v'number' /bit'number'
' If using the TKN in code
' b2e.tkn -sourceFilePath\file.bas -destinationPath /bas /dt /kp /pw /r /s /tkn /v'number' /bit'number'
' if destinationPath is ommtted the default destinationPath is DefaultDir$\EXE
' If sourcePath\file.bas is ommitted BAS2EXE defaults to opening in GUI mode
' If no switches used, all switches defaults are false, 0 or "", except for the bit64 default
' Switches MUST be separated with a 'space'
' Switches are Optional
' Just typing b2e by itself BAS2EXE defaults to opening in GUI mode
'Switches
' /bas - saves a dated backup of the selected bas file
' /bit32 - creates a 32 bit exe file
' /bit64 - creates a 64 bit exe file (Defaults to 64bit EXE file if no swtich used)
' /dt - appends date/time to the created exe filename.
' /kp - saves the Project Folder (tkn, renamed jbrun2.exe dll and sll files) Created anyway - they are needed for the EXE file.
' /o - opens windows explorer with the created EXE file selected
' /pw - Prompts user for a password to open the created EXE file (If used the EXE file won't run without it, so save the password somewhere safe.)
' /q - Stops the "Please Wait" activity window from appearing while in command mode.
' /r - Runs the New EXE file after it is created
' /s - shows the Post Creation EXE Menu Window (GUI) to (View / Run / MakeNew - EXE file)
' /tkn - saves a dated backup of the tkn file.
' /v'number' - appends the EXE filename with a version number or text
' (No Spaces) examples: /v2.51 /v.001 /v123.Any_thing Note: The "v" is not included.
' If you want a v in your EXE filename then you must add one eg: /vv4.5.1 /vvTest123 etc
' Here are some examples of commandline use.
' eg: b2e (alone this opens the GUI)
' b2e -sourceFilePath\file.bas (Creates a single exe file in DefaultDir$\EXE) no project folder, no backups, no appended date/time, or version etc
' b2e -sourceFilePath\file.bas -f:\MyStuff\MyEXEcollection Creates a single 64bit EXE file in f:\MyStuff\MyEXEcollection
' b2e -sourceFilePath\file.bas /bas /bit32 /dt /kp /pw /q /r /s /tkn /vv1.0 (Creates a single 32bit exe file in DefaultDir$\EXE)
' _ including all the optional swtches
' Switches can be in ANY order as long as they preceed the -path(s)
' if -sourceFilePath\file.bas is a lone .bas file with no path, BAS2EXE assumes the file is in the DefaultDir$
' The dashes before the path(S) ARE necessaary
' the spaces between the switches ARE necessary
' Please NOTE - About the app and it's limitations
' This app uses a built in Windows app named IEXPRESS to create the EXE file by way of a SED(Self Extracting Dirctive) file.
' This app write the SED file, then IEXPRESS reads, and executes the instructions in it to create the EXE file.
' IEXPRESS has limits.
' It won't copy a folder, so for now this app can only create EXE files with the necessary runtime support files
' That means (for now anyway) the files needed to work (dll's, sll's tkn renamed jbrun2.exe and the bas file if user wants it.)
' If your .bas file uses any support files from the DefaultDir$ or sub folders of DefaultDir$ such as
' _bmp, txt, etc, they won't be in the EXE file when created.
' The app is great for testing, or for apps that need no support files (other than the jb dlls/slls the tkn and renamed jbrun2.exe )
' _and if your .bas doesn't create any files needed the next time it is opened.
' When an EXE that is created by IEXPRESS executes, it is unpacked in the users temp folder, into a folder
' _named IXP001.tmp, or the number can vary on each persons PC. IXP001......IXP00n (depends on other temp apps I guess)
' These temp folders get deleted when the app is finished doing it's thing as is closed.
' That means if your app saves any data to files in DefaultDir$, or copies any files\folders to DefaultDir$, they get deleted too.
' If the interest is there, and I get some feedback on this app I'll work on a version 2.
' Version 2 will have support for adding extra folders and files to the EXE
' It will also get around the temp folder issue. I have that part working already.
' It may also have an option to batch create the EXE files.
' By having .bas files in a folder, and executing a loop to create one after the other.
' Other suggestions are welcome
' If you use this, please take the time to give some feedback so I know what's up,
' Any issues, don't hesitate to report them
' This App is actually part of a larger app, and the defaults are set 'as is' to accomodate the larger app.
' I didn't want to re-write the whole thing for the 1 person that 'may' use it.
' This app is free to use, edit, and/or distibute. Feel free to make it work the way you want it to.
' New Version v1.8.9
' added ini file to hold Users JB install dir path when detected to be other than default
' added checkbox to allow showing created exe file in Windows Explorer when complete
' added onerror notice, and restart of BAS2EXE
' hardened some more
'New Version 1.9.0c
' changed method of auto[enter] of TKN creation "save as" dialog, and "Information" notice
' changed file verification loops of created exe file and tkn file to allow escape from loop after a set time
' _ to avoid infinite looping with BAS2EXE running invisible, forcing user to use taskmanager to close
' _ when/if exe file or tkn file is NOT created for whatever reason
' added detection of spaces in filename. IEXPRESS will not create a file with spaces in the name of the
' _source file - BAS2EXE will give Notice, then close when Notice closes.
' Tested on files up to 3000 lines - User may need to increase the 2 largest pauses if files have
' _ 3000+ lines of code (look for 'call pause 1500') - 2 of them
global q$, upath$, fixedDate$, fixedTime$, autoSave$
on error goto [abort]
nomainwin
call getUserPath
upath$ = trim$(upath$)
if not(fileExists(DefaultDir$, "b2e.exe")) then
command = 1 : firstRun = 1 : project = 1 : fname$ = DefaultDir$;"\b2e.bas" : goto [checkjbpath]
end if
[TOP]
if mainOpen = 1 then close #main : mainOpen = 0
command = 0 : s = 0 : openDest = 0 : runEXE = 0 : p = 0 : q = 0 : show = 0
tkn = 0 : bas = 0 : r = 0 : ve$ = "" : ve = 0 : project = 0 : dt = 0 : fname$ = ""
exeDest$ = "" : selectedpath$ = "" : fixedDate$ = "" : fixedTime$ = "" : exe$ = ""
q$ = chr$(34)
if CommandLine$ <> "" then
if not(instr(CommandLine$, ".bas")) then [GUI]
sourc3$ = word$(CommandLine$, 3)
sourc2$ = word$(CommandLine$, 2)
sourc1$ = word$(CommandLine$, 1)
sourc = 1
if instr(sourc1$, ".bas") then fname$ = word$(CommandLine$, 1) : goto [getDest]
sourc = 2
if instr(sourc2$, ".bas") then fname$ = word$(CommandLine$, 2) : goto [getDest]
sourc = 3
if instr(sourc3$, ".bas") then fname$ = word$(CommandLine$, 3)
[getDest]
fname$ = trim$(fname$)
if right$(fname$, 1) = chr$(34) then fname$ = left$(fname$, len(fname$)-1)
if left$(fname$, 1) = chr$(34) then fname$ = right$(fname$, len(fname$)-1)
if left$(fname$ ,1) = "-" then fname$ = right$(fname$, len(fname$)-1)
if left$(fname$ ,1) = "\" then fname$ = right$(fname$, len(fname$)-1)
fname$ = trim$(fname$)
if left$(fname$ ,1) = "\" then fname$ = right$(fname$, len(fname$)-1)
if not(instr(fname$, ":\")) and instr(fname$, ".bas") then fname$ = DefaultDir$;"\";fname$
dest$ = word$(CommandLine$, 2)
if instr(dest$, ":\") and sourc = 1 then exeDest$ = word$(CommandLine$, 2) : goto [gotDest]
dest$ = word$(CommandLine$, 3)
if instr(dest$, ":\") and sourc = 2 then exeDest$ = word$(CommandLine$, 3) : goto [gotDest]
dest$ = word$(CommandLine$, 4)
if instr(dest$, ":\") and sourc = 3 then exeDest$ = word$(CommandLine$, 4) : goto [gotDest]
exeDest$ = DefaultDir$;"\EXE"
[gotDest]
if left$(exeDest$ , 1) = "-" then exeDest$ = right$(exeDest$, len(exeDest$)-1)
if right$(exeDest$, 1) = chr$(34) then exeDest$ = left$(exeDest$, len(exeDest$)-1)
if left$(exeDest$, 1) = chr$(34) then exeDest$ = right$(exeDest$, len(exeDest$)-1)
if left$(exeDest$ , 1) = "-" then exeDest$ = right$(exeDest$, len(exeDest$)-1)
if instr(CommandLine$, "/bas") then bas = 1 'creates a dated backup of the user selected .BAS file in DefaultDir$\BAS
if instr(CommandLine$, "/dt") then dt = 1 'appends the date and time to the EXE file
if instr(CommandLine$, "/kp") then project = 1 'keep the project folder (temp project folder gets deleted by default in command mode)
if instr(CommandLine$, "/o") then openDest = 1 'opens windows explorer to the created EXE file when done
if instr(CommandLine$, "/pw") then p = 1 'password - adds password to bas file - if chosen, the EXE file won't run without it.
if instr(CommandLine$, "/q") then quiet = 1 'no "please wait" window will appear
if instr(CommandLine$, "/r") then runEXE = 1 'Run the newly created exe file.
if instr(CommandLine$, "/s") then show = 1 'show final options window (defaults to not show in command mode)
if instr(CommandLine$, "/tkn") then tkn = 1 'creates a dated backup of the user selected TKN file in DefaultDir$\TKN
if instr(CommandLine$, "/v") then 'ALL CommandLine options default to false, '0' , "", unless switch options are utilized
ve = 1 ' appends a version number to the EXE filename - defaults to false - 0
ve$ = word$(CommandLine$, 2 , "/v") : ve$ = word$(ve$, 1)
end if
bit = 64
if instr(CommandLine$, "/bit") then
bit$ = word$(CommandLine$, 2 , "/bit") : bit$ = word$(bit$, 1) : bit = val(bit$)
end if
JBpath$ = "C:\Program Files (x86)\Just BASIC v2.0"
command = 1 : goto [checkjbpath]
end if
[GUI]
exeDest$ = ""
titlebar$ = "BAS2EXE v1.9.0c"
[checkjbpath]
JBpath$ = "c:\Program Files (x86)\Just Basic v2.0"
'check Just Basic v2.0 Default Install Dir for existence
'if Just Basic v2.0 is NOT installed to it's Default Install Dir, get Path from User using folder dialog
if pathExists(JBpath$) then [go]
'get users saved JB install path from ini file if it exists
if fileExists(DefaultDir$, "b2e.ini") then
open "b2e.ini" for input as #1
JBpath$ = input$(#1,lof(#1))
JBpath$ = trim$(JBpath$)
close #1
goto [go]
end if
'if folder path chosen by user for Just Basic install is wrong catch error later with check for jbrun2.exe
a$ = FolderDialog$("Select Your Just Basic v2.0 Install Folder")
if a$ = "" then notice chr$(13);"Just Basic v2.0 must be installed to continue";chr$(13);chr$(13);"BAS2EXE will now close" : end
'create ini to hold users JB install dir path
JBpath$ = a$
open "b2e.ini" for output as #1
#1 a$ : close #1
[go]
if command = 1 then [commandPath]
' setup a Window for User to Select a .bas File, to select options for the EXE file.
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.exe, "EXE File", 35, 30, 95, 30
statictext #pick.head, "BAS2EXE v1.9.0c", 250, 25, 190, 30
statictext #pick.temp, "Project Files", 425, 100, 195, 30
statictext #pick.datedtext, "Dated Backups", 225, 100, 185, 30
statictext #pick.info, "Select a working Just Basic Source Code File (.bas)", 50, 235, 590, 30
button #pick.default, "Select File", [defaultClick],UL 140, 270, 135, 35
button #pick.jbforums, "Visit the Just Basic Forums @ https://justbasiccom.proboards.com/", [forumLink],UL 0, 325, 595, 25
checkbox #pick.opendest, "Show EXE File When Completed", [OpenDest], [noOpenDest], 20, 210, 250, 20
checkbox #pick.bit32, "32 Bit", [bit32], [nobit32], 20, 65, 50, 20
checkbox #pick.bit64, "64 Bit", [bit64], [nobit64], 75, 65, 50, 20
checkbox #pick.password, "Add a Password", [yespass], [nopass], 20, 90, 140, 20
checkbox #pick.appDT, "Append Date/Time", [appDT], [noappDT], 20, 115, 140, 20
checkbox #pick.appversion, "Append Version Number", [appVersion], [noappVersion], 20, 140, 140, 20
checkbox #pick.project, "Keep Project Dir", [project], [noproject], 430, 135, 160, 20
checkbox #pick.TKN, "SaveTKN File", [noTKN], [yesTKN], 250, 135, 140, 20
checkbox #pick.BAS,"Save BAS File", [noBAS], [yesBAS], 250, 160, 140, 20
checkbox #pick.ShowOptionsMenu,"Show Post Creation Options Menu", [yesShow], [noShow], 20, 190, 190, 20
button #pick.32, "Cancel", [cancel],UL 320, 270, 135, 35
statictext #pick.versionText, "Version #", 40, 170, 50, 20
textbox #pick.ve, 90, 165, 85, 20
'open the Window, and set some Fonts for each statictext, and buttons
open "BAS2EXE v1.9.0c (CommandLine Support)" for dialog as #pick : pickOpen = 1
#pick, "trapclose [cancel]"
#pick.exe, "!font Arial_bold"
#pick.temp, "!font Arial_bold"
#pick.datedtext, "!font Arial_bold"
#pick.info, "!font Arial_bold"
#pick.head "!font Arial_bold"
#pick.bit64, "set"
#pick.project, "set"
#pick.TKN "set"
#pick.BAS "set"
#pick.appDT "set"
#pick.ShowOptionsMenu "set"
#pick.versionText "!hide"
#pick.ve "!hide"
#pick.default, "!setfocus"
show = 1
project = 1
tkn = 1
bas = 1
bit = 64
dt = 1
wait
''temp files saved or not (user choice)
[OpenDest]
#pick.opendest "set"
openDest = 1
wait
[noOpenDest]
#pick.opendest "reset"
wait
[yesShow]
show = 1
wait
[noShow]
show = 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 false, default
[nopass]
p = 0
wait
'make 32 bit exe = true(user selected)
[bit32]
bit=32
#pick.bit64, "reset" : #pick.bit64 "hide"
wait
'make 64 bit exe, default
[bit64]
bit=64
#pick.bit32, "reset" : #pick.bit32 "hide"
wait
[nobit32]
bit=64
#pick.bit64, "show" : #pick.bit32 "hide"
wait
[nobit64]
bit=32
#pick.bit32, "show" : #pick.bit64 "hide"
wait
'append date/time to backed up tkn, and bas files - defaults to true
[appDT]
dt = 1
wait
[noappDT]
dt = 0
wait
[appVersion]
#pick.versionText "!show"
#pick.ve "!show" : #pick.ve "!setfocus"
ve = 1
wait
[noappVersion]
#pick.ve ""
#pick.versionText "!hide"
#pick.ve "!hide"
ve = 0
wait
[forumLink]
run "explorer https://justbasiccom.proboards.com"
wait
[defaultClick]
cursor hourglass
if ve = 1 then #pick.ve "!contents? ve$" : ve$ = "-";ve$
[commandPath]
'close the opening window for Selecting bas file
if pickOpen = 1 then close #pick : pickOpen = 0
'check existence and JBPath$ (Just Basic default install dir)
if pathExists(JBpath$) = 0 then notice " Just Basic v2.0 was not was not found in ";JBpath$;" Restart BAS2EXE - Try Again" : end
'define some variables
JBexe$ = "jbasic.exe"
JBruntime$ = "jbrun2.exe"
supportFileList$="jbrun2.exe vbas31w.sll vgui31w.sll voflr31w.sll vthk31w.dll vtk1631w.dll vtk3231w.dll vvm31w.dll vvmt31w.dll"
projects$ = "b2eProjects"
'make sure the support files exist
fileCount = 0
while 1
fileCount = fileCount + 1
runtimeSupportFile$ = word$(supportFileList$, fileCount)
if runtimeSupportFile$ = "" then exit while
if fileExists(JBpath$,runtimeSupportFile$) = 0 then notice "File doesn't Exist";chr$(13);JBpath$;"\";runtimeSupportFile$;chr$(13);"BAS2EXE will now Close" : end
wend
if command = 1 then [commandByPass]
' Use the filedialog function to allow user to select a source file (.bas)
[filediag]
filedialog "Open a Just Basic Source File (.bas) ", "*.bas", fname$
if fname$ = "" then notice "No file selected, BAS2EXE will now close" : end
[commandByPass]
if p = 1 then
Prompt "TYPE a PASSWORD"+chr$(13)+ "Password For Your EXE File is? : (no spaces)";passwerd$
if passwerd$ = "" then p = 0 : notice "BAS2EXE will continue, without placing a password on the EXE file created"
end if
'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)
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)
for x = 1 to len(fnamenobas$)
spaceCheck$ = mid$(fnamenobas$, x, 1)
if spaceCheck$ = " " then notice "No Spaces Allowed in File Name"+chr$(13)+"Space found in Selected Filename. Cannot Create EXE File."+chr$(13)+"BAS2EXE will now Close" : end
next x
' 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)
'make sure Folders were actually created
if pathExists(DestPathU$) = 0 then notice "Projects folder was NOT Created in ";DestPath$ : end
if pathExists(DestPath1$) = 0 then notice "New Folder ";fnamenobas$;" was NOT Created in ";DestPath1$ : end
if pathExists(DefaultDir$;"\";"TKN") = 0 then notice "TKN Folder was NOT Created in ";DestPath$ : end
if pathExists(DefaultDir$;"\";"BAS") = 0 then notice "BAS Folder was NOT Created in ";DestPath$ : end
if pathExists(DefaultDir$;"\";"EXE") = 0 then notice "EXE Folder was NOT Created in ";DestPath$ : end
'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] '
#2, "prompt ";q$;"Enter the Password to Run";q$;";";"passwerd$"
#2, "if passwerd$ <> ";q$;passwerd$;q$;" then end"
[nopasswerd]
#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
#1, input$(#fnameTemp, lof(#fnameTemp));
close #1
close #fnameTemp
if fileExists(DefaultDir$, fnameTemp$) then kill fnameTemp$
'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$;" BAS2EXE will now close" : end
'activity message to user - please wait message
if quiet = 0 then gosub [pleasewait]
'Check paths and file locations for existence (dll's, sll's, jbasic.exe, and jbrun2.exe)
if fileExists(JBpath$, JBexe$) = 0 then notice " jbasic.exe Does not exist in ";JBpath$;" Closing BAS2EXE":end
if fileExists(JBpath$,JBruntime$) = 0 then notice " jbrun2.exe Does not exist in ";JBpath$;" Closing BAS2EXE" : end
if fileExists(JBpath$,"vvmt31w.dll") = 0 then notice " vvmt31w.dll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
if fileExists(JBpath$,"vvm31w.dll") = 0 then notice " vvm31w.dll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
if fileExists(JBpath$,"vtk3231w.dll") = 0 then notice " vtk3231w.dll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
if fileExists(JBpath$,"vtk1631w.dll") = 0 then notice " vtk1631w.dll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
if fileExists(JBpath$,"vthk31w.dll") = 0 then notice " vthk31w.dll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
if fileExists(JBpath$,"voflr31w.sll") = 0 then notice " voflr31w.sll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
if fileExists(JBpath$,"vgui31w.sll") = 0 then notice " vgui31w.sll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
if fileExists(JBpath$,"vbas31w.sll") = 0 then notice " vbas31w.sll Does not exist in ";JBpath$;" Closing BAS2EXE" : end
'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$(supportFileList$, i)
if w$="" then exit while
from$=JBpath$;"\";w$
to$=DestPath1$;"\";w$
if fileExists(DestPath1$,w$) then [noneed]
open from$ for input as #file
open to$ for output as #1
print #1, input$(#file, lof(#file));
close #file
close #1
[noneed]
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 )
if fileExists(DestPath1$,fnamenobas$;".exe") = 0 then notice "jbrun2.exe not copied or renamed - EXITING Program": end
'remove any existing exe from projectdir - of same name as bas file selected only if created on same date at same time
if fileExists(DestPath$;"\EXE",fnamenobas$;".exe") then kill DestPath$;"\EXE\";fnamenobas$;".exe"
if command = 1 and fileExists(exeDest$,fnamenobas$;".exe") then kill exeDest$;"\"; fnamenobas$;".exe"
'check for old tkn existence, delete it if it exists
if fileExists(DestPath1$,fnamenobas$;".tkn") then kill DestPath1$;"\";fnamenobas$;".tkn"
gosub [makeSED]
'verify sed file existence before proceeding
do
scan
loop until fileExists(DestPath$,fnamenobas$;".sed")
call writeAutoSave
'loop until autoSave$ File is verified
while fileExists(DefaultDir$, autoSave$) = 0 : scan : wend
'#######################################################################
'run the script to close the "save" dialog, and the follow up notice of creation automatically
run "wscript ";autoSave$
'#######################################################################
'Create the TKN file in Projects\current project folder.
run JBpath$;"\";JBexe$;" -T -A ";DestPath1$;"\";fname0$
'#######################################################################
'loop until TKN File is verified saved
do
countTime = countTime + 1
call pause 500
if countTime > 70 then exit do '- In case of unreported error - EXE file verification loop exit
scan
loop until fileExists(DestPath1$, fnamenobas$;".tkn")
call pause 1500
call fixtime : call fixdate ' append date/time to backup .bas and .tkn filename
'copy selected .bas file to BAS dir and date it
if bas = 1 then
open fname$ for input as #file
open DefaultDir$;"\BAS\";fnamenobas$;ve$;fixedDate$;fixedTime$;".bas" for output as #1
print #1, input$(#file, lof(#file));
close #file
close #1
end if
' copy TKN$ file to TKN dir, and append date\time to it's name
if tkn = 1 and fileExists(DestPath1$, fnamenobas$;".tkn") <> 0 then
open DestPath1$;"\";fnamenobas$;".tkn" for input as #file
open DefaultDir$;"\TKN\";fnamenobas$;ve$;fixedDate$;fixedTime$;".tkn") for output as #1
print #1, input$(#file, lof(#file));
close #file
close #1
end if
fixedDate$ = "" : fixedTime$ = ""
'First Run setup in User Home Dir for CommandLine use
if command = 1 and firstRun = 1 then
run "cmd.exe /c xcopy ";DestPath1$;" ";upath$;" /e /s /c /h /i /y", hide
call pause 1000
call wDS
run upath$;"\b2e.exe"
end if
if firstRun = 1 then close #pleasewait : end
'Check if iexpress.exe is installed (a built in Windows Install Maker = Self Extracting exe File)
[makeinst]
if fileExists("c:\windows\system32","iexpress.exe") 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)"
[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"
if fileExists(express64$,"iexpress.exe") then
run "iexpress /N /q ";sedfile$ : goto [verifyEXE]
else
noie = 1 : goto [quit.main]
end if
'makes 32 bit exe
[do32bit]
express32$ = "C:\Windows\SysWOW64"
if fileExists(express32$,"iexpress.exe") then
run "iexpress /N /q ";sedfile$
else
noie = 2 : goto [quit.main]
end if
'verify the exe file was created - loop until it exists
[verifyEXE]
if command = 1 then
do
countTime = countTime + 1
call pause 500
if countTime > 70 then exit do '- In case of unreported error - EXE file verification loop exit
scan
loop until fileExists(exeDest$, exe$)
end if
if command = 0 then
do
countTime = countTime + 1
call pause 500
if countTime > 70 then exit do '- In case of unreported error - EXE file verification loop exit
scan
loop until fileExists(DefaultDir$;"\EXE\", exe$)
end if
call pause 1500
if dt = 1 then call fixdate : call fixtime
' append version, date, time to filename if selected
if command = 1 then
if fileExists(exeDest$, fnamenobas$;".exe") then
exefilename$ = fnamenobas$;ve$;fixedDate$;fixedTime$;".exe"
name exeDest$;"\";fnamenobas$;".exe" as exeDest$;"\";exefilename$
end if
end if
if command <> 1 then
if fileExists(DefaultDir$;"\EXE", fnamenobas$;".exe") then
exefilename$ = fnamenobas$;ve$;fixedDate$;fixedTime$;".exe"
name DefaultDir$;"\EXE\";fnamenobas$;".exe" as DefaultDir$;"\EXE\";exefilename$
end if
end if
if runEXE = 1 and command = 1 and fileExists(exeDest$, exefilename$) then run exeDest$;"\";exefilename$
[main]
if pleaseOpen = 1 then close #pleasewait : pleaseOpen = 0
'create a window with options to view created files or run the new exe file.
WindowWidth = 400
WindowHeight = 320
UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
UpperLeftY=INT((DisplayHeight-WindowHeight)/2)
BackgroundColor$ = "darkgray"
ForegroundColor$ = "black"
button #main.default, "Make New Single EXE File (GUI Mode)", [rerun],UL 90, 200, 220, 40
button #main.run, "Run the Created EXE File", [progrun],UL 125, 150, 150, 40
button #main.browseT, "View TKN Files", [browseT],UL 125, 15, 150, 25
button #main.browseB "View BAS Files", [browseB],UL 125, 45, 150, 25
button #main.browseE, "View EXE Files", [browseE],UL 125, 75, 150, 25
button #main.browseP, "View Projects", [browseP],UL 125, 105, 150, 25
button #main.jbforums, "For more Information > Click Here to Visit the Just Basic Forums", [forumLink], UL 0, 270, 400, 20
open "View Files\ Run Created EXE \ Make New EXE" for window_nf as #main
#main, "trapclose [quit.main]"
mainOpen = 1
if show <> 1 then close #main : mainOpen = 0
if command = 0 and openDest = 1 then
run "cmd.exe /c explorer /select, ";q$;DefaultDir$;"\EXE\";exefilename$;q$, hide
openDest = 0
if mainOpen = 0 then [quit.main]
end if
if command = 1 and openDest = 1 then
run "cmd.exe /c start explorer.exe /select, ";q$;exeDest$;"\";exefilename$;q$, hide
openDest = 0
if mainOpen = 0 then [quit.main]
end if
cursor normal
wait
'Make another EXE file
[rerun]
if command = 1 then CommandLine$ = "" : exeDest$ = "" : fname$ = "" : command = 0
goto [TOP]
'open Windows explorer to the EXE Files
[browseE]
if command = 1 and exeDest$ <> "" then run "explorer.exe ";exeDest$
if command = 0 then run "explorer.exe ";DefaultDir$;"\EXE"
wait
'open Windows explorer to the backup TKN Files Files
[browseT]
run "explorer.exe ";DefaultDir$;"\TKN"
wait
'open Windows explorer to the backup BAS Files
[browseB]
run "explorer.exe ";DefaultDir$;"\BAS"
wait
'open Windows explorer to the Projects Dir
[browseP]
run "explorer.exe ";DefaultDir$;"\b2eProjects"
wait
'Run the new CommandLine created exe file chosen
[progrun]
if command = 1 then
run exeDest$;"\";exefilename$
end if
if command = 0 then
run DestPath$;"\EXE\";exefilename$
end if
wait
[quit.main]
if command = 0 and openDest = 1 then run "cmd.exe /c explorer /select, ";q$;DefaultDir$;"\EXE\";exefilename$;q$, hide
gosub [cleanUp]
if command = 1 and fileExists(exeDest$, exefilename$) = 0 then notice "No EXE Created"+chr$(13)+"EXE file was NOT created"+chr$(13)+"Check Selected File 'name' for Spaces"
if command = 0 and fileExists(DefaultDir$;"\EXE\", exefilename$) = 0 then notice chr$(13)+"EXE file was NOT created"+chr$(13)+"Check Selected File 'name' for Spaces"
end
[quit.pleasewait]
close #pleasewait
wait
[cancel]
close #pick
end
[abort]
cursor normal
notice "An error occured";chr$(13);"Error Code # ";Err;chr$(13);Err$;chr$(13);chr$(13);"BAS2EXE will Re-Start"
if pleaseOpen = 1 then close #pleasewait : pleaseOpen = 0
if mainOpen = 1 then close #main : mainOpen = 0
if pickOpen = 1 then close #pick : pickOpen = 0
if command = 0 then [TOP]
goto [quit.main]
[cleanUp]
if fileExists(DefaultDir$, fnameTemp$) then kill fnameTemp$
if fileExists(DefaultDir$,"temp.txt") then kill "temp.txt"
if fileExists(DefaultDir$, "FolderDialog.vbs") then kill "FolderDialog.vbs"
if fileExists(DefaultDir$, autoSave$) then kill autoSave$
if fileExists(DefaultDir$,desktopShortcut$) then kill desktopShortcut$
'if user chose to, - delete the current project dir and files (copied bas file, tkn file, sll,dll, jbrun2.exe(renamed file)
if project = 0 then
if fileExists(DestPath1$, "vbas31w.sll") then kill DestPath1$;"\";"vbas31w.sll"
if fileExists(DestPath1$, "vgui31w.sll") then kill DestPath1$;"\";"vgui31w.sll"
if fileExists(DestPath1$, "voflr31w.sll") then kill DestPath1$;"\";"voflr31w.sll"
if fileExists(DestPath1$, "vtk1631w.dll") then kill DestPath1$;"\";"vtk1631w.dll"
if fileExists(DestPath1$, "vthk31w.dll") then kill DestPath1$;"\";"vthk31w.dll"
if fileExists(DestPath1$, "vtk3231w.dll") then kill DestPath1$;"\";"vtk3231w.dll"
if fileExists(DestPath1$, "vvm31w.dll") then kill DestPath1$;"\";"vvm31w.dll"
if fileExists(DestPath1$, "vvmt31w.dll") then kill DestPath1$;"\";"vvmt31w.dll"
if fileExists(DestPath1$, exe$) then kill DestPath1$;"\";exe$
if fileExists(DestPath1$, fnamenobas$;".tkn") then kill DestPath1$;"\";fnamenobas$;".tkn"
if fileExists(DestPath1$, fnamenobas$;".bas") then kill DestPath1$;"\";fnamenobas$;".bas"
if pathExists(DestPath1$) then deldir = rmdir(DestPath1$)
end if
if fileExists(DefaultDir$, fnamenobas$;".sed") then kill DefaultDir$;"\";fnamenobas$;".sed"
if noie = 1 then notice "64Bit Version of IEXPRESS not installed"+chr$(13)+" No EXE File Created - BAS2EXE closing."
if noie = 2 then notice "32Bit Version of IEXPRESS not installed"+chr$(13)+" No EXE File Created - BAS2EXE closing."
if pleaseOpen = 1 then close #pleasewait : pleaseOpen = 0
run "cmd.exe /c del /y ";DefaultDir$;"\*.sed", HIDE
run "cmd.exe /c del /y ";DefaultDir$;"\EXE\*.RPT", HIDE
run "cmd.exe /c del /y ";DefaultDir$;"\EXE\*.CAB", HIDE
run "cmd.exe /c del /y ";DefaultDir$;"\*.DDF", HIDE
if mainOpen = 1 then close #main : mainOpen = 0
if pickOpen = 1 then close #pick : pickOpen = 0
return
'#######################################################################
'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
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"
if command = 1 and exeDest$ <> "" then
#sed "TargetName=";q$;exeDest$;"\";exe$;q$
else
#sed "TargetName=";q$;DefaultDir$;"\EXE\";exe$;q$
end if
#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
return
sub writeAutoSave
q$ = chr$(34)
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, "WshShell.SendKeys ";q$;"{ENTER}";q$
#1, "Do While Not WshShell.AppActivate(";q$;"Information";q$;")"
#1, "Loop"
#1, "WshShell.SendKeys ";q$;"{ENTER}";q$
#1, "Wscript.Sleep(100)"
#1, "WshShell.AppActivate(";q$;"pleasewait";q$;")"
close #1
end sub
sub fixdate
fixDate$ = Date$() 'set up the 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 the 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
[pleasewait]
WindowWidth = 450 : WindowHeight = 200
UpperLeftX=int((DisplayWidth-WindowWidth)/2)+50
UpperLeftY=int((DisplayHeight-WindowHeight)/2)+50
statictext #pleasewait.text1, " Please Wait While ", 50, 40, 325, 30
statictext #pleasewait.text3, "BAS2EXE gets everything ready ", 70, 90, 325, 30
statictext #pleasewait.text6, "This Can Take 10 - 20 Seconds ", 70, 140, 325, 30
Open "pleasewait" for window_popup as #pleasewait
#pleasewait "trapclose [quit.pleasewait]"
#pleasewait "font verdana"
pleaseOpen = 1
return
'write a vbs script to create a desktop shortcut to b2e.exe
sub wDS
desktopShortcut$ = "desktopShortcut.vbs"
open desktopShortcut$ for output as #1
#1 "Set Shell = CreateObject(";q$;"WScript.Shell";q$;")"
#1 "DesktopPath = Shell.SpecialFolders(";q$;"Desktop";q$;")"
#1 "Set link = Shell.CreateShortcut(DesktopPath & ";q$;"\BAS2EXE.lnk";q$;")"
#1 "link.Description = ";q$;"b2e shortcut";q$
#1 "link.HotKey = ";q$;"CTRL+ALT+E";q$
#1 "link.IconLocation = ";q$;upath$;"\b2e.exe,0";q$
#1 "link.TargetPath = ";q$;upath$;"\b2e.exe";q$
#1 "link.WindowStyle = 3"
#1 "link.WorkingDirectory = ";q$;upath$;q$
#1 "link.Save"
close #1
run "wscript ";desktopShortcut$
end sub
'get users homepath = aka %userprofile% = "c:\users\xxxxx" (5 characters long normally Win 10)
sub getUserPath
run "cmd.exe /c echo %userprofile% >UserHomePath.txt", HIDE
do
scan
loop until fileExists(DefaultDir$, "UserHomePath.txt")
open "UserHomePath.txt" for input as #1
upath$ = input$(#1, lof(#1))
close #1
if upath$ = "" then notice "Sorry, can't find user path " : end
kill DefaultDir$;"\UserHomePath.txt"
end sub
'sub to create delays
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
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, " (Single 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 8 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"
#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