INTRODUCTION
The SRC_PATH is a list of paths which GAUSS uses to search for files. For example, if you enter:
run myfile.gss;
at the GAUSS command prompt, or you have a file which contains the line:
#include myprocs.src;
GAUSS will first look in your current working directory for myfile.gss or myprocs.src. If they are not found, GAUSS will then search the folders in the SRC_PATH.
HOW CAN I FIND MY CURRENT SRC_PATH?
VIEW IN LIBRARY TOOL
You can see which folders are in your SRC_PATH in the Library Tool by following these steps.
- Open the Library Tool (View > Library Tool).
- Expand the Paths node and the Sources node.
The last two folders from the full path are shown. Hover your mouse over one of the paths to see all folders in the path.
PRINT SRC_PATH
Alternatively, you can use the sysstate
command to print out a semi-colon separated list of paths.
// Print the SRC_PATH folders print sysstate(22,0);
The above command will return something similar to one of the following.
C:\gauss\src;C:\gauss\examples /Users/YourUserName/gauss/src;/Users/YourUserName/gauss/examples /home/user/gauss/src;/home/user/gauss/examples
HOW CAN I MODIFY MY SRC_PATH
ADD THE LOCATION OF YOUR FILE
The #includedir
command will add the folder containing your program file to your source path. Consider, for example, the file named my_main_program.gss
stored in the folder C:\Users\MyName\Research
. If you add this line at the top:
#includedir
The path C:\Users\MyName\Research
will be added to the front of your SRC_PATH
. You can also add a sub-folder by adding a relative path. For example, if we modified our file to start with this:
© 2024 Aptech Systems, Inc. All rights reserved.
#includedir src
Then GAUSS would instead add the C:\Users\MyName\Research\src
directory to your source path.
Recommended option
The portability of #includedir
makes it easier for you to share code with others.
What makes this even better is that if you share this file with a colleague, it will still work without any changes regardless of the name of their main folder.
CHANGE THE SRC_PATH WITH THE SYSSTATE COMMAND
You can also use the sysstate command to modify your SRC_PATH. Instead of passing in a zero for the second argument, pass in the new SRC_PATH.
// Get the current SRC_PATH old_src_path = sysstate(22, 0); // Add a new path to the front of the SRC_PATH new_src_path = "C:\\gauss\\myproject\\src;" $+ old_src_path; // Set the new SRC_PATH call sysstate(22, new_src_path); // Print the SRC_PATH to confirm the change print sysstate(22,0);
Since the SRC_PATH folders are searched in order, adding a new path to the front of the list means that it will be searched first (after the current working directory). This new SRC_PATH will be in effect until it is reset or until GAUSS is restarted.
CHANGE THE SRC_PATH IN GAUSS.CFG
When GAUSS starts up, the SRC_PATH is initially set from the contents of the gauss.cfg file. The gauss.cfg file is located in the GAUSSHOME directory. The line which controls the SRC_PATH will look something like this.
# multiple paths for program files src_path = $(GAUSSDIR)/src;$(GAUSSDIR)/examples;$(GAUSSDIR)/gaussplot/src;$(GAUSSDIR)/gaussplot/examples;$ (PACKAGEDIR)/*/src;$(PACKAGEDIR)/*/examples
In the line above, $(GAUSSDIR) means your GAUSSHOME directory. In the code below, we add the same path from our earlier sysstate example to the front of the SRC_PATH.
# multiple paths for program files src_path = C:\gauss\myproject\src;$(GAUSSDIR)/src;$(GAUSSDIR)/examples;$(GAUSSDIR)/gaussplot/src;$(GAUSSDIR)/gaussplot/examples;$(PACKAGEDIR)/*/src;$(PACKAGEDIR)/*/examples
Since this file is read every time that GAUSS starts, this is a more permanent solution.
CONCLUSIONS
We have seen that:
- The SRC_PATH is a list of file paths that GAUSS searches when looking for files to run or open.
- The current SRC_PATH can be found by looking in the Library Tool, or using the sysstatecommand.
- The SRC_PATH can be modified with the sysstate command or by editing the gauss.cfg file.