Post by xxgeek on Jan 28, 2021 2:38:00 GMT
Here's something I've been working. I was advised to post it before completion.
Can't say it's finished yet, it's not. I have a few more ideas for future.
Things to know.....
1. It assumes JB was installed to the default dir..(for now)
2. Windows can't keep up with file creations so you MAY see an error once in a while telling you that a file doesn't exist when in fact it does exist, windows is just to slow creating it before it's checked. This is intermittent, doesn't always happen. (I've been working like a madman trying to solve this, and have added calls to pause so windows can catch up) these pauses seem to work but may need to be increased as the users Projects increase in size, I don't know that yet, just a guess.
3. The button "Make project works, the checkboxes are for future plans.
4. tsh73 posted in justbasiccom.proboards.com/thread/223/creating-jb-exe-programmatically
Most of the code was borrowed and editted from that post, thanks tsh73.
If you don't like it, tell me so. Also include why.
Whether you like it or not, let me know your thoughts (be brutal)
If you have ideas for future versions let me know
peace out.
Code updated to latest version March 3 2021
Can't say it's finished yet, it's not. I have a few more ideas for future.
Things to know.....
1. It assumes JB was installed to the default dir..(for now)
2. Windows can't keep up with file creations so you MAY see an error once in a while telling you that a file doesn't exist when in fact it does exist, windows is just to slow creating it before it's checked. This is intermittent, doesn't always happen. (I've been working like a madman trying to solve this, and have added calls to pause so windows can catch up) these pauses seem to work but may need to be increased as the users Projects increase in size, I don't know that yet, just a guess.
3. The button "Make project works, the checkboxes are for future plans.
4. tsh73 posted in justbasiccom.proboards.com/thread/223/creating-jb-exe-programmatically
Most of the code was borrowed and editted from that post, thanks tsh73.
If you don't like it, tell me so. Also include why.
Whether you like it or not, let me know your thoughts (be brutal)
If you have ideas for future versions let me know
peace out.
Code updated to latest version March 3 2021
'#####################################################################
' Visit the forums @ https://justbasiccom.proboards.com/ for more
' information on Just Basic or this program and many more, and learn
' more about programming with the 'easy to learn' Just Basic language.
'#####################################################################
' Title$ = "Project Organizer v.004 for Just Basic v2.0"
' PP$ = "Purpose = To manage the projects created with Just Basic v2.0"
' and add features to help with whatever a user may want to do with:
' the projects they create.
' Currently = It creates a directory named Just Basic Projects in a directory of
' the users choice to store each project. Then it creates a directory in the
' Projects dir each time it is RUN using the name of the BAS file
' selected (minus the .bas). It then gathers the necessary .DLL and .SLL, files and the
' jbrun2.exe runtime file, copies them to the new dir and renames
' jbrun2.exe to the name of the .BAS file (minus the .bas)
' It also creates the TKN file in the new project folder.
' Allows user to add Folders to each project (bmp, media, apps),
' and a users choice of a folder name to add any files they wish.
' Allows user to add files to each of these Folders.
' Allows user to add files to the root of the New project Folder.
' Allows user to remove the Source Code (.bas) from the Project Dir
' Allows user to Run the new project
' Thank you to all the members of the Just Basic Forums for
' your generosity and insightful helpful posts that made this possible.
' Special Mentions go to...
' [tsh73] for getting me started with making the TKN , [B+], [Rod],
' [cundo], [bluatigro],[Enzo],[xcoder],[honky],[ntech] and some I may have
' forgotten (sorry, I'm losing my mind) :D for their solicited and unsolicited
' posts on the forums that helped with learning the JB code syntax and
' structure, and of course Carl Gundel for giving away free of charge such a
' great program as Just Basic v2.0. Thank You Carl.
' Dream Plans = a whole slew of tools, abilities like downloading
' files (freeware etc). Using Windows to provide apps at our finger tips,
' like MSpaint, Notepad, Run, 3D Builder etc etc etc. Using Windows
' Registry to do things like change Windows settings on the fly, create
' shortcuts, change screen resolution etc etc etc), Also, I have seen
' code on these forums like a Sprite Maker, a Search Engine for the
' help files, a Code generator etc, etc that could be added.
'#########################################################
titlebar "Project Organizer v.004 for Just Basic v2.0"
'res=pathExists(JBpath$)
' if res then a = a + 1 else notice " JBpath Does not exist on the given path - > ";JBpath$;" J.B.P.O. will now close":end
'res=fileExists(JBpath$,JBexe$)
[start]
JBpath$ = "c:\Program Files (x86)\Just Basic v2.0"
res=pathExists(JBpath$)
if res then [go] else notice " Just Basic v2.0 was not installed to the default install folder"
prompt "Please provide the path to the Just Basic v2.0 install Directory"; JBpath$
[go]
res=pathExists(JBpath$)
if res then a = a + 1 else notice " Just Basic v2.0 was not was not found in ";JBpath$;" Restart JB Project Organizer - Try Again":end
JBexe$ = "jbasic.exe"
JBruntime$ = "jbrun2.exe"
DllList$="vbas31w.sll vgui31w.sll voflr31w.sll vthk31w.dll vtk1631w.dll vtk3231w.dll vvm31w.dll vvmt31w.dll"
qq$=chr$(34) '(") - used later to wrap quotes around file paths.
a = 0
'Checking all paths and file locations for existence
res=pathExists(JBpath$)
if res then a = a + 1 else notice " JBpath Does not exist on the given path - > ";JBpath$;" J.B.P.O. will now close":end
res=fileExists(JBpath$,JBexe$)
if res then a = a + 1 else notice " jbasic.exe Does not exist on the given path -> ";JBpath$;" J.B.P.O. will now close":end
res=fileExists(JBpath$,JBruntime$)
if res then a = a + 1 else notice " jbrun2.exe Does not exist on the given path -> ";JBpath$;" J.B.P.O. will now close":end
res=fileExists(JBpath$,"vbas31w.sll")
if res then a = a + 1 else notice " vbas31w.sll Does not exist on the given path -> ";JBpath$;" J.B.P.O. will now close":end
res=fileExists(JBpath$,"vgui31w.sll")
if res then a = a + 1 else notice " vgui31w.sll Does not exist on the given path -> ";JBpath$;" J.B.P.O. will now close":end
res=fileExists(JBpath$,"voflr31w.sll")
if res then a = a + 1 else notice " voflr31w.sll Does not exist on the given path -> ";JBpath$;" J.B.P.O. will now close":end
res=fileExists(JBpath$,"vthk31w.dll")
if res then a = a + 1 else notice " vthk31w.dll Does not exist on the given path -> ";JBpath$;" J.B.P.O. will now close":end
res=fileExists(JBpath$,"vtk1631w.dll")
if res then a = a + 1 else notice " vtk1631w.dll Does not exist on the given path -> ";JBpath$;" J.B.P.O. will now close":end
res=fileExists(JBpath$,"vtk3231w.dll")
if res then a = a + 1 else notice " vtk3231w.dll Does not exist on the given path -> ";JBpath$;" J.B.P.O. will now close":end
res=fileExists(JBpath$,"vvm31w.dll")
if res then a = a + 1 else notice " vvm31w.dll Does not exist on the given path -> ";JBpath$;" J.B.P.O. will now close":end
res=fileExists(JBpath$,"vvmt31w.dll")
if res then a = a + 1 else notice " vvmt31w.dll Does not exist on the given path -> ";JBpath$;" J.B.P.O. will now close":end
' setup a window
nomainwin
WindowWidth = 600
WindowHeight = 320
UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
UpperLeftY=INT((DisplayHeight-WindowHeight)/2)
BackgroundColor$ = "black"
ForegroundColor$ = "white"
statictext #main.header, "Project Organizer v.004 for Just Basic v2.0", 40, 20, 590, 35
statictext #main.1, "(1) Select a .bas file from your Just Basic v2.0 source collection", 15, 50, 590, 25
statictext #main.2, "(2) Provide a Path to a Folder or Drive to put your Projects Folder", 15, 70, 590, 25
statictext #main.3, " JBPO copies DLL's \ SLL's \ jbrun2.exe to the New Project Folder", 15, 90, 590, 25
statictext #main.4, " JBPO renames the jbrun2.exe to the name of the .bas file you select", 15, 110, 590, 25
statictext #main.5, " JBPO makes the TKN file in the New Project folder ", 15, 130, 590, 25
statictext #main.info, "Pick a working JB Source Code File (.bas)", 15, 167, 590, 45
statictext #main.jbforums, "Visit the Just Basic Forums @ https://justbasiccom.proboards.com/", 35, 265, 590, 20
button #main.cancel, "Cancel", [cancelClick],UL 360, 210, 135, 42
button #main.default, "Select File", [defaultClick],UL 220, 210, 135, 42
open "Project Organizer v.004 for Just Basic v2.0" for dialog_nf as #main
#main, "trapclose [quit.main]"
#main, "font Arial 10 bold"
#main.header, "!font Arial 12 bold"
#main.1, "!font Arial 8 bold"
#main.2, "!font Arial 8 bold"
#main.3, "!font Arial 8 bold"
#main.4, "!font Arial 8 bold"
#main.5, "!font Arial 8 bold"
#main.info, "!font Arial 12 bold"
#main.jbforums "!font Arial 8 bold"
#main.default, "!font Arial 10 bold"
#main.cancel, "!font Arial 10 bold"
wait
'select a source file
[defaultClick]
filedialog "Open \ Select JB Source File", UserData$ ; "*.*", fname$
if fname$ = "" then notice "No file selected, P.O. will now close" : close #main : 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)
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)
#main.header, "The Folder you choose MUST already exist."
#main.default, "!hide"
#main.1, "Type the Path to an EXISTING Folder"
#main.2, "!hide"
#main.3, "No quotes and don't use a backslash to end the Path"
#main.4, "!hide"
#main.5, "See the examples below"
#main.info, "e: , c: , c:\My JB Stuff , e:\Just Basic\Source"
'DestPath$ = UserData$
prompt "Path to Projects folder? " + chr$(13) +"Path to Dir where Projects Dir will be created";DestPath$
if DestPath$ = "" then notice "No Folder Path given, closing JB Program Organizer": goto [quit.main]
res=pathExists(DestPath$)
goto [begin]
wait
[cancelClick]
'notice "Project Organizer will now close"
close #main
end
wait
[begin]
#main.header, "Creating Dirs, Copying Files to Project Dir"
#main.default, "!hide"
#main.1, "!hide"
#main.3, "!hide"
#main.5, "!hide"
' redefine DestPath$
projects$ = "Just Basic Projects"
DestPath$ = DestPath$;"\";projects$
#main.info, "!font Arial 10 bold"
do
z = z + 1
#main.info, "Creating Projects Folder .... . .. "
call pause 100
loop until z = 15
z=0
'redefine Destpath1$
DestPath1$=DestPath$;"\";fnamenobas$
'Make dir's for Projects and ProjectName
run "cmd.exe /c mkdir ";qq$;DestPath$;qq$
run "cmd.exe /c mkdir ";qq$;DestPath1$;qq$
run "cmd.exe /c copy ";qq$;fnames$;qq$;" ";qq$;DestPath1$;qq$;"\";qq$;fname0$;qq$
do
z = z + 1
#main.info, "Waiting for Windows to make the Folders .. . "
call pause 100
loop until z = 15
z=0
'copy the project .bas file to new dir
open fname$ for input as #fname
open DestPath1$;"\";fname0$ for output as #1
print #1, input$(#fname, lof(#fname));
close #fname
close #1
do
z = z + 1
#main.info, "copying BAS file to New Project Dir . ... .. "
call pause 100
loop until z = 15
z=0
'check if the 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$;" J.B.P.O. will now close":close #main:end
'################################################################################
'Create the TKN file. A good time to cross your fingers :D
'Getting to this pont cost me a new wig & 2 bottles of Rogain :D
RUN JBpath$;"\";JBexe$;" -T -A ";DestPath1$;"\";fname0$
notice "AFTER the TKN file is Saved it is OK to Press [OK] "
'################################################################################
do
z = z + 1
#main.info, "Copying jbrun2.exe to New Project Dir + rename . .. . .."
call pause 100
loop until z = 15
z = 0
'copy the jbrun2.exe file to the new project dir
from$=JBpath$;"\";JBruntime$
to$=DestPath1$;"\";fnamenobas$;".exe"
run "cmd.exe /c copy ";qq$;from$;qq$;" ";qq$;to$;qq$
do
z = z + 1
#main.info, "Copying DLL and SLL Files to New Project Dir .. . .. .. "
call pause 100
loop until z = 20
z = 0
'Copy the needed DLL and SLL files from Just Basic dir to New Project Dir
w$ = ""
i = 0
while 1
i = i + 1
w$=word$(DllList$,i)
if w$="" then exit while
from$=JBpath$;"\";w$
to$=DestPath1$;"\";w$
run "cmd.exe /c copy ";qq$;from$;qq$;" ";qq$;to$;qq$
wend
do
z = z + 1
#main.info, "Almost done . ... . . . .."
call pause 100
loop until z = 20
z = 0
'check dll's were copied to new dir
if res then a = a + 1 else notice " jbrun2.exe Does not exist on the given path -> ";JBpath$;"\";JBruntime$;" J.B.P.O. will now close":end
res=fileExists(DestPath1$,"vbas31w.sll")
if res then a = a + 1 else notice " vbas31w.sll Was not created in --> ";DestPath1$;" J.B.P.O. will now close":end
res=fileExists(DestPath1$,"vgui31w.sll")
if res then a = a + 1 else notice " vgui31w.sll Was not created in --> ";DestPath1$;" J.B.P.O. will now close":end
res=fileExists(DestPath1$,"voflr31w.sll")
if res then a = a + 1 else notice " voflr31w.sll Was not created in --> ";DestPath1$;" J.B.P.O. will now close":end
res=fileExists(DestPath1$,"vthk31w.dll")
if res then a = a + 1 else notice " vthk31w.dll Was not created in --> ";DestPath1$;" J.B.P.O. will now close":end
res=fileExists(DestPath1$,"vtk1631w.dll")
if res then a = a + 1 else notice " vtk1631w.dll Was not created in --> ";DestPath1$;" J.B.P.O. will now close":end
res=fileExists(DestPath1$,"vtk3231w.dll")
if res then a = a + 1 else notice " vtk3231w.dll Was not created in --> ";DestPath1$;" J.B.P.O. will now close":end
res=fileExists(DestPath1$,"vvm31w.dll")
if res then a = a + 1 else notice " vvm31w.dll Was not created in --> ";DestPath1$;" J.B.P.O. will now close":end
res=fileExists(DestPath1$,"vvmt31w.dll")
if res then a = a + 1 else notice " vvmt31w.dll Was not created in --> ";DestPath1$;" J.B.P.O. will now close":end
'check new project exe and tkn files for existence
res=fileExists(DestPath1$,fnamenobas$;".exe")
if res then a=a+1 else notice "The EXE file was not created ": close #main : goto [start]
'check for new tkn existence
tkn$ = fnamenobas$;".tkn"
res=fileExists(DestPath1$,tkn$)
if res then a=a+1 else notice "The TKN File was not created" : close #main : goto [start]
do
z=z+1
#main.info, "Your Project was created successfully.....please wait."
call pause 100
loop until z = 30
z=0
'##################################################################
[include]
close #main
WindowWidth = 800
WindowHeight = 600
UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
UpperLeftY=INT((DisplayHeight-WindowHeight)/2)
BackgroundColor$ = "black"
ForegroundColor$ = "white"
statictext #include.header, "Include Some Files or Folders with this Project", 225, 20, 590, 35
statictext #include.1, "(1) Add a BMP Folder to this New Project Dir", 140, 85, 570, 25
statictext #include.2, "(2) Add BMP Files (.bmp) to this New BMP Dir", 140, 120, 570, 25
statictext #include.3, "(3) Add a Media Folder to this New Project Dir", 140, 155, 570, 25
statictext #include.4, "(4) Add Media Files (.wav) to this New Media Dir", 140, 190, 570, 25
statictext #include.5, "(5) Add an Apps Folder to this New Project Dir", 140, 225, 570, 25
statictext #include.6, "(6) Add Apps Files (.exe) to this New Apps Dir", 140, 260, 570, 25
statictext #include.7, "(7) Create a New Folder in this New Projects Dir", 140 , 295, 570, 25
statictext #include.8, "(8) Add any Files to the Folder you created in (7)", 140, 330, 570, 25
statictext #include.9, "(9) Add Files to the Root of this New Projects Dir", 140, 365, 570, 25
statictext #include.10, "(10) Remove .bas File from this New Project Dir", 140, 400, 570, 25
statictext #include.info, "Add Folder First then any # of Files to Folder", 135, 450, 350, 40
statictext #include.jbforums, "https://justbasiccom.proboards.com/ https://justbasic.com", 10, 545, 500, 15
button #include.bmpd, "Add bmp Dir", [bmpd],UL 560, 80, 145, 25
button #include.bmpf, "Add bmp Files", [bmpf],UL 560, 115, 145, 25
button #include.medd, "Add media Dir", [medd],UL 560, 150, 145, 25
button #include.medf, "Add media Files", [medf],UL 560, 185, 145, 25
button #include.appd, "Add apps Dir", [appd],UL 560, 220, 145, 25
button #include.appf, "Add Files to apps", [appf],UL 560, 255, 145, 25
button #include.userd, "Create Dir", [userd],UL 560, 290, 145, 25
button #include.userf, "Add Files", [userf],UL 560, 325, 145, 25
button #include.rootf, "Add File to Root", [rootf],UL 560, 360, 145, 25
button #include.remsource, "Remove Source", [remsource],UL 560, 395, 145, 25
button #include.back, "Back", [back],UL 590, 525, 90, 25
button #include.done, "Done", [done],UL 525, 440, 90, 25
button #include.cancel2, "Cancel", [cancel2],UL 645, 440, 90, 25
button #include.makeexe, "Make Exe", [makeexe],UL 645, 480, 90, 25
button #include.run, "Run it", [run],UL 525, 480, 90, 25
open "Include Folders and Files" for dialog_nf as #include
#include, "trapclose [quit.include]"
#include, "font Arial 10 bold"
#include.header, "!font Arial 12 bold"
#include.bmpd, "!font Arial 8 bold"
#include.bmpf, "!font Arial 8 bold"
#include.medd, "!font Arial 8 bold"
#include.medf, "!font Arial 8 bold"
#include.appd, "!font Arial 8 bold"
#include.appf, "!font Arial 8 bold"
#include.userd, "!font Arial 8 bold"
#include.userf, "!font Arial 8 bold"
#include.rootf, "!font Arial 8 bold"
#include.remsource, "!font Arial 8 bold"
#include.back, "!font Arial 10 bold"
#include.info, "!font Arial 12 bold"
#include.done, "!font Arial 10 bold"
#include.cancel2, "!font Arial 10 bold"
#include.makeexe, "!font Arial 10 bold"
wait
[cancel2]
close #include
goto [start]
wait
[bmpd]
bmp$ = "bmp"
run "cmd.exe /c mkdir ";qq$;DestPath1$;qq$;"\";qq$;bmp$;qq$
call pause 300
res=pathExists(DestPath1$;"\";bmp$)
if res then notice "bmp directory was added to ";DestPath1$ else notice bmp$;" Was not created in ";DestPath1$
wait
[bmpf]
filedialog "Open a bmp File - (.bmp)", "c:\*.bmp", bmpFile$
run "cmd.exe /c copy ";qq$;bmpFile$;qq$;" ";qq$;DestPath1$;qq$;"\";qq$;bmp$;qq$
call pause 300
res=fileExists(DestPath1$;"\";bmp$,bmpFile$)
if res then notice bmpFile$;" Was created in ";DestPath1$;"\";bmp$ else notice bmpFile$;" Was not created"
wait
[medd]
media$ = "media"
run "cmd.exe /c mkdir ";qq$;DestPath1$;qq$;"\";qq$;media$;qq$
call pause 300
res=pathExists(DestPath1$;"\";media$)
if res then a = a + 1 else notice media$;" Was not created in ";DestPath1$
notice media$;" folder created in ";DestPath1$
wait
[medf]
filedialog "Open a Media File - (.wav)", "c:\*.wav", mediaFile$
if mediaFile$ = "" then notice "No Media File Chosen"
run "cmd.exe /c copy ";qq$;mediaFile$;qq$;" ";qq$;DestPath1$;qq$;"\";qq$;media$;qq$
call pause 300
res=fileExists(DestPath1$;"\";media$,mediaFile$)
if res then notice mediaFile$;" copied to ";DestPath1$;"\";media$ else notice mediaFile$;" Was not created in ";DestPath1$
wait
[appd]
apps$ = "apps"
run "cmd.exe /c mkdir ";qq$;DestPath1$;qq$;"\";qq$;apps$;qq$
call pause 300
res=pathExists(DestPath1$;"\";apps$)
if res then notice apps$;" folder created in ";DestPath1$;"\";apps$ else notice apps$;" Was not created in ";DestPath1$
wait
[appf]
filedialog "Open \ Choose a File to add to the New Apps Dir - (.exe)", "c:\*.exe*", appFile$
run "cmd.exe /c copy ";qq$;appFile$;qq$;" ";qq$;DestPath1$;qq$;"\";qq$;apps$;qq$
call pause 300
res=fileExists(DestPath1$,appFile$)
if res then notice appFile$;" was added to ";DestPath1$;"\";apps$ else notice appFile$;" Was not created in ";DestPath1$
wait
[userd]
prompt "Give the new folder a name" + chr$(13) + "Type any Name for your New Folder";userDir$
run "cmd.exe /c mkdir ";qq$;DestPath1$;qq$;"\";qq$;userDir$;qq$
call pause 300
res=pathExists(DestPath1$;"\";userDir$)
if res then notice userDir$;" was added to ";DestPath1$ else notice userDir$;" Was not created in ";DestPath1$
wait
[userf]
filedialog "Add Files to Folder Created in (7)", "c:\*.*", userFile$
run "cmd.exe /c copy ";qq$;userFile$;qq$;" ";qq$;DestPath1$;qq$;"\";qq$;userDir$;qq$
call pause 300
res=fileExists(DestPath1$,userFile$)
if res then notice userFile$;" was added to ";DestPath1$;"\";userDir$ else notice userFile$;" Was not added to ";DestPath1$;"\";userDir$
wait
[rootf]
filedialog "Add Files to root of New Project Dir", "c:\*.*", rootFile$
rootFile$ = lower$(rootFile$)
run "cmd.exe /c copy ";qq$;rootFile$;qq$;" ";qq$;DestPath1$;qq$
call pause 300
res=fileExists(DestPath1$,rootFile$)
if res then notice rootFile$;" Was added to ";DestPath1$ else notice rootFile$;" Was not added to ";DestPath1$
wait
[remsource]
delFile$ = "yes"
prompt "Are you sure you want to delete this source code file?";delFile$
if left$(delFile$, 1) <> "y" then notice "No File will be deleted"
kill DestPath1$;"\";fname0$
call pause 350
res=fileExists(DestPath1$,fname0$)
if res then notice fname0$;" Has not been removed from ";DestPath1$ else notice fname0$;" Has been removed from ";DestPath1$
wait
[back]
close #include
goto [start]
wait
[makeexe]
prompt "runs iexpress.exe" + chr$(13) + "iexpress.exe creates a self extracting exe file." + chr$(13) + "Want to continue? y or n";iexpress$
if iexpress$ = "" then notice "No answer given" : close #include : end
if left$(iexpress$, 1) = "n" then notice "Project Organizer will now close" :close #include : end
run "iexpress"
wait
[done]
close #include : goto [start]
wait
[run]
run DestPath1$;"\";fnamenobas$
wait
[quit.include]
close #include
goto [start]
[quit.main]
close #main
end
sub pause mil
t=time$("ms")+mil
while time$("ms")<t
scan
wend
end sub
function fileExists(path$, filename$)
dim info$(0, 0)
files path$, filename$, info$()
fileExists = val(info$(0, 0)) 'non zero is true
end function
function pathExists(path$)
pathExists = (mkdir(path$)=183)
end function