Keeping Source & Run Directories Separate

Share your advanced PureBasic knowledge/code with the community.
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Keeping Source & Run Directories Separate

Post by yrreti »

This is a simple tip, but it may be useful to someone.
Have you ever worked on a project in which you wanted to keep your finished run program
with all its files, separate from your source code files? What I mean is that when you are debugging
your code from your source code directory, you are using the files in your Run directory. But all
your source files, image files, icons, and backups etc, that are needed for compiling, are kept out
of that run directory so when it comes time to prepare the program to sell to someone etc, it's already
prepared. No extra stuff needs to be removed from the run directory. And it's not all cluttered up with
all the source files etc.

This is what I do.
I create two directories:
name_of_your_program
name_of_your_program_stuff
Then I use the following code:

Code: Select all

;*****************  gets current program path  **********************
pp$=Space(#MAX_PATH)
GetCurrentDirectory_(#MAX_PATH,@pp$)

;I added this next part so I could keep the source code in a separate
;directory from the running directory so it wouldn't be copied to
;someone elses computer.  (I created a new directory with the same name with _Stuff
;added to the end of it to store source code etc.)
If FindString(UCase(pp$),"_STUFF",1)>0
  pp$=Left(pp$,Len(pp$)-6)  ;remove  _STUFF  
  ;Debug pp$
EndIf

pp$+"\"   ;now your using your code from your code directory, but your running from your Run directory
I then save the code file from the PB IDE in the \name_of_your_program_stuff directory,
with all its necessary stuff, and always run it from the PB IDE there.
I create the name_of_your_program.exe file from the PB IDE in the \name_of_your_program directory,
and place all of its needed file there.

Works great for me. Hope this is useful for someone else.