Using projects

Top  Previous  Next

Projects are the heart of multi module programming and combine all of the source files and resource information into a centralized project module. Using projects you can create very complex programs by separating your source code over multiple files and libraries. Subroutines and variables in source files can be either local or shared globally between files for ease of data reuse.

Creating a new project

1.Select the File menu and choose New->Project. The new project options dialog will appear.
2.Select the project output type from the Project Type combo box. Choose Windows if your program will use any windows, dialogs, controls, etc. Console for a text only console program, DLL to create a DLL project, No Output for a compile-only project or Static Library to create a static library project
3.Select a path for the project file
4.Type in a name for the project. The Output File name will be added automatically based on the project type. Change the output file name if you don't want it to be the same name as the project.
5.Choose whether or not to create a debugging executable by checking the Debug Build checkbox
6.Finally click the OK button

At this point you will see the File View pane in the Project Workspace window of the IDE with the project name. This is where source files contained in the project will be listed. The default location of the Project Workspace window is the lower right of the IDE.

Opening an existing project

Select the File menu and chose Open Project. Browse to the location of the project file and select Open from the file dialog.  If the project directory was renamed, or copied from a different source, you will be prompted to update the project files. Selecting "Yes" to the prompt will adjust all of the internal paths in the project file to the new directory.  The resource file will also be scanned for any needed path updates.

 

Closing a project

Select the File menu and choose Close Project. You will be prompted to save any changes made to the project.

 

Adding source files

Once a project has been created you can begin to add source files to the project.

1.Open an existing EBASIC source file or create a new one by selecting the File menu and choosing New->Emergence Source File
2.Add the file to the project by right clicking in the source window and selecting Insert File into Project. Alternately you can select the Project menu in the IDE and choose Insert File into Project
3.Save the project when needed by selecting the File menu and choosing Save Project

It's common practice to keep all of the source files used in a project in the project directory. However, this is not necessary and your source files can be located anywhere on your drive.

Adding other external library/object files

A project may contain external object or library files.  These can be specified in the source code with the $USE statement or added to the project by following these steps

1.With a project open select the Project menu of the IDE and choose Insert Library/Object into Project.
2.Select one or more library or object files to insert from the file dialog and press "Open". The added files will be listed in the File View of the IDE after all of the source files.

For a static library project the external object files must be in the same directory as the project output. For other project types the external library/object can be located anywhere on the drive.

 

Adding resources

1.Chose the Resource menu and select Add
2.Enter the details of the resource into the Add Resource dialog
3.Click the Add button

Once one or more resources have been added they can be modified by selecting the Resource View tab in the Project Workspace window of the IDE. The default location of the Project Workspace window is the lower right of the IDE.

See Also: Using Resources

 

The $main directive

When using projects it is necessary to tell the compiler where to start execution of your program. This is accomplished by using the preprocessor keyword $main. Only one source file can contain the $main keyword and it does not matter where the keyword appears. Execution will begin at the first statement or command that is not in a function. DLL's and Compile-Only projects do not require the $main directive

See Also: Single file compiling

 

Modifying project options

You can modify your projects options at any time by selecting the Project menu and choosing Options. A dialog similar to the New Project dialog will open allowing modification of the project name, type, debug build, and output name. It is not possible to change the location of the project directory once its been created. If you need to move the project directory create a new project and add the existing source files.

 

Compiling the project

After adding source files and resources if any to the project you can build the executable or DLL by selecting the Build menu and selecting Rebuild All. You can also compile a single file for testing by selecting the Build menu and choosing Compile File. Any errors in the source files will appear in the Build pane of the Output Window. Double clicking on an error in a source file will display that file with the offending line highlighted.

After a successful build of the project you can test the resulting executable by selecting the Build menu and choosing Execute ... . Alternately the program can be executed by clicking the green 'Go' button on the tool bar.

 

Removing source/library files

If a source or library file is no longer needed by the project you can remove it by right-clicking on the file name in the File View of the Project Workspace window and choosing Remove from project. Removing a source file from a project does not delete the file, it just removes it from the list of source files in the project. You can safely re-add the file if necessary.