
Creating a project
You would want to actually create a project (File | New… , Choose Project, then click New file button) for your project and it will actually make your life easier.
If you didn't create a project when you first started, you can add a project later. Also, your project file does not require to be the same place where your programs are. However, it is a good idea to put them together.
When you created a new project, you will get a blank Project. In Project Manager, Click at Code tab, and then click Add… to add your existing programs as shown in the screenshot below. If you want to create a new program/module, it is as easy as clicking New… button.
If you look at the screenshot above, you should notice that my main program is in bold. This means that it is the default module that will execute first. You will have to set your main module, so it knows which program to run first. To do that, right click on the program you want to set main and then click Set main.
Because your programs are listed in one place, making it easier to add, modify, or delete programs in your project. Don’t get too excited yet. You will also have to add tables as well. To do that, click Data tab and click Add…. Again, if you want to add a new table, you can easier add one by clicking New... button. To modify the table structure is as easy as double clicking at the table you want to change.

Extended: Creating an executable (.EXE file)
Previous section must be completed prior to this section
After all, we all have so much fun programming in FoxPro and in the end you want to distribute it for others to use your program by making it executable. Believe it or not, you can do that with FoxPro. We will show you how.
First you may want to add descriptions and info. about your project. To do that, Right click and choose Project Info…, Click Projects tab, and you should see what shown below.
In this dialog, you will have an ability to change your program icon, by clicking Icon… button, and make sure that Attached icon checkbox is checked.
In many cases, you will want to keep your sourcecode confidential so others will not able to look at it. To do that, check the Encrypted checkbox.
Now, you are ready to build an executable. To do that, Click Build… button. You will see the first dialog as shown below. Select Build Executable to make .EXE file. You may want to check Recompile All files to make sure that all modules of your programs are all up to date.
You can change the information to be on the executable file as well as the version of your program by clicking at Version… button

In Version… dialog, you can set Version number, in my case is 1.1 and again you will be able to set your descriptions in an executable file here.
When you have done configuring an executable file, click OK to create the executable. You will see it in the project's folder.
Now, test your executable file by running it.
What? What happened to my project? It never looks like that when I run in FoxPro! Calm down. You are not the only person if you got the same problem like me as shown below. Some of you may not get it, if you all use customized font, as mentioned in Print of show output on the screen section of this summary.

OK. You probably do not want to set font to everything you say in the project. That would be a lot of work, especially to the one who already programmed much. And hey, I even use ‘?’ command which does not support to change font! Can this be fixed?
Yes, you can solve this problem. In fact, the solution is already mentioned in this summary! There are commands that let you set default fonts to the whole Project. See ‘Print or show output on the screen’, ‘Extended: Applying it to all!' section.
For your information, the default recomemnded font is ‘Tahoma’, font size:10.
OK. Look like I heard complains somewhere saying that the window is not maximized, and I want to change the title, instead of Microsoft Visual FoxPro to I love Jutiphan’s FoxPro Summary. The good news is that you can do it!
_Screen.WindowState = 2 This will maximize the window.
_Screen.Caption = "I love Jutiphan’s FoxPro Summary” This will set the Program Title.
Thank you. Thank you everybody.
You have successfully created EXE file of your project. Hooray!
[Someone murmuring…] What? You want to create Setup like what I did? Come on! It is out of scoop of this section, but hey, look at what upcoming section got for you. You are now ready to move on to the next one. Let’s go!
Extended: Setup Setup Setup!
Previous sections must be completed prior to this section
Note: Guidelines provided for creating Setup is no longer applicable to FoxPro 7 and above. FoxPro 9 comes with InstallShied Express specially for creating a more modern Setup. However, the information on this section may still be useful for preparing your program for publication.
Want your program to look professional by having its cool Setup thing? Yes, you can do that without help of external programs. Have you noticed that you can only execute EXE file on the computer with FoxPro installed? Yes, You can overcome that problem with Setup. Wait… What am I doing? I think I tell you too much secrets already. I better shut my mouth. OK, I am only joking.
[In this exercise you will very likely have to do it twice. Be prepared. Don’t cheat, because I have to do so many many times to get this thing right.]
First, You will have to create a new folder named Application in your project folder. Put the files You want you want to distribute (to be installed on the computer.) Here are some guidelines for you:
- Put an executable file of your program. Do not include any programs/modules files.
- Put your clean database .dbf files pre-configured for first use.
I also recommended that you keep a copy of those files.Now, with your Project Manager selected, click Tools | Wizards, then choose Setup…
You will get a new dialog box. It will ask you to locate the folder you just created named Application. When you are done, click next button.
It will let you choose the components required to run your project. In most cases, you only need to tick the first one, Visual FoxPro runtime. With this component, the computer to run your program on will not need to install Visual FoxPro in order to run your program. Click next when you are done.
The next step is to choose the location where you want your setup file you be saved. I recommended you create a new folder named Setup and put it there.
After that you will be able to choose the type of setup. There are 2 main types to consider which are Diskette and web setup. Diskette option will divide setup files to fit in a diskette for you. Normally it would need 3 diskettes. For web setup option, it will simply create a single setup file for you to upload onto the website, share it on LAN or burn it to the CD. Click next when you done.
Enter information on the first 2 textboxes. Do not worry about the last one, leave it blank. Click next when you done.
The next step, Enter the default directory where you want the program to be installed, Take note at my example below.
Program group is the name that will appear in the StartMenu under Programs.
Users can modify allows you to specify what users can configure during the installation. If Directory only, They can only modify where to be installed. If both, They can modify the program group name.
6th Step. Don’t worry about the table. In this step, It let you choose which item you want to add into the Start menu. Make sure you checked your executable file in PM Item column, not the Active X one.

When you make checked it, It will give you a new dialog box as shown above. Do not worry about the icon, since we already added the icon to EXE file. (See Creating an executable section.)
%s stands for the installation path. Remember, User can change an installation path they want, and that's the reason not to hard coded where to locate the files. Click OK when you are done, then click Next to move on.
Now comes to the last step, You don’t have to tick anything. Leave those unticked. Just click Finish and it will generate the Setup for you.
If you chose 1.44 Diskette, You will have to put each Setup file into the each separate diskette in order to test it. If you choose Websetup option, you can test it right away. Don't get tired yet, it's not over.
Go ahead and test the setup, then try to start your program from the Start menu. Make sure that you done all that before you read on!
Depends on how good your program can handle the error. Good program will give a friendly error message like mine: (Come on! Give me a chance to show off my program!) No, This is not a error-handling section, so forget it if you are going to ask about that.

I assume that many of you probably have Set default to command to your Drive P. As I mentioned earlier, hard coded the directory path is a bad idea. A quick and dirty solution you may think is to change the set default to into ‘C:\Program files\BMO’. But you have to remember that users can choose and may prefered to install on other locations instead.
Let me warn you before I go on. I see many examples that hardcoded the location when opening tables and so forth. This is why I have recommended you to use Set default to command all along. So if you are the one who keep telling the path everywhere and not taking advantage of set default to, then you are struck, and I recommended you to clean up your code before you continue.
Let forget about those people, and let them spend their time fixing those problems. Let get on how to fix this problem.
Fortunately FoxPro provides commands to get Current Drive and current directlory. Here are the one you want to use:
Sys(5) Default drive or volume
Sys(2003) Current Directory
See Helpfile for the full lists of SYS() function.
This is the example how you can take advantages of those functions:
set default to sys(5) + sys(2003)
This will work when you run from an executable, but may give you an error when you run from MS FoxPro. If you are running from MS FoxPro. Just make sure when you chagned it, you change back to use those functions before you create an executable.
Now you will have to recreate the executable file, and create the setup again. Hey! It’s not my fault that I didn’t tell you this thing first. You should be happy that I tell you the solution at the end. Think of it as an exercise. The more you do, the better you get. I have to go through all this myself many times before I get it right!
Please note: I did this because some of you requested me and now you got it. Please make sure that you read it carefully. I may make mistakes due to that I done it quickly and yet it still take me quite a long time to do it. I assume that you have a good understanding of FoxPro programming and such for extended sections in this page. If you do not understand or cannot follow what I said, please read it carefully and make sure that you already have understand about FoxPro programming. In the case that I worded it so badly that you cannot understand even trying to understand it several times, please email me, or best tell me on MSN Messenger. Thank you.
- There is NO NEED to make the most complicated program in the world. Keep it SIMPLE, FAST AND EASY TO USE. If you look at the mark scheme, there isn't many marks here compared to documentation.
- Well Structured designed modules and Table.
- Give clear & meaningful variable names & Field names.
- Think before you write. Revise worksheets or look at this summary to see and judge things you would like to get done. Don’t design something like Check E-mail features, buttons or pictures. Remember: FoxPro is a simple Database programming language and you are going to do about Database programming, not becoming a graphics designer!
- Don’t design something too complicated or have too much features, remember you will have to do all those programming by yourself. It's better to start small and expand as time allows. When you become a programming genius in the future, you can all the features you ever dreamed off and MAKE BIG BUCKS!
- Write good detailed algorithms. This makes life easier when you write codes and have less problems!
Simply put:
Good progarms have a clean consistent and easy to use interface and error-handling.
Good programmers write codes neatly, organized in modular ways, easy to read, easy to understand, and well commented.
Are you there yet?