User Tools

Site Tools


redirection_file.htm
Navigation:  Development Environment (IDE) >Redirection System Previous pageReturn to chapter overviewNext page

The Clarion IDE sets the active working directory to the folder in which the current application or project file resides. Clarion uses the redirection file (%ClarionRoot%\BIN\Clarion80.RED) both to locate files and to output new files.

The project system first looks for a local redirection (.RED) file in the current directory (e.g., the directory where the project is). If it does not find one there, it uses the default RED file (%ClarionRoot%\BIN\Clarion8.RED).

The RED file controls where files are found as well as where they are creaed and saved. When the project system needs to find a file, it looks through the RED file, checking if the file being looked for matches the file extension at the beginning of each line of the red file. If the extension matches, the project system then searches each directory in the list on that line starting at the left most directory. Once the file is found in one of the search directories, that file is used.

When a file needs to be created by the project system the same system. Once a file extension pattern is found to match the file being created, then the first directory of that pattern is used.

The red file is not used at all when a program runs. However, the redirection file is used to find DLLs when the Copy referenced DLLs to output directory check box in the Project Options is selected.

NoteBox.jpg

Backup files are always created in the directory where the original file is located.

To edit the default redirection file, choose Tools C6H0013.jpg Edit Base Redirection File. The text editor opens the appropriate redirection file for editing.

Adding a pipe character “|” to the end of a path causes the redirection system to stop searching. This is very useful if you want to have separate template registries for different development projects.

Redirection File Syntax

Each line of the redirection file is in the format:

filemask = directory1 [;directory2]… [;directoryn]

The filemask is a file name or a file mask using the standard OS wild card characters: * and ?.

The directory is a pathname identifying the directory or folder to search for the filemask files. The first directory is where any new filemask files are created. This is only true for files created and saved by the development environment, such as .OBJ, .DBD, .LIB, .EXE, and .CLW. The additional directory entries name additional search paths for existing filemask files.

NoteBox.jpg

The redirection system also supports transforming '.' and '..' syntax into directory names based on the location where the redirection file was opened (not based on the current directory). The redirection file needs to know what '.' means because you can have one red file in use in a project that is compiling on one thread while you have a different red file in use on a different thread for an app that is in a different directory.

It is also recommended that any paths with spaces should be quoted as follows:

*.* = %ROOT%\Accessory\libsrc\win; “%ROOT%\Accessory\my images”

Redirection Macros

The redirection file directory can contain macros. Redirection macros are labels surrounded by the percent sign (%). When a redirection macro is detected, the Clarion environment substitutes the macro's substitution value. You can define redirection macros and their substitution values in the Redirection File tab located in the Tools > Options > Clarion > (product name) > Versions section of the IDE:

Redirection.jpg

For example to define a TEMP macro:

Redirection2.jpg

To use the TEMP macro, add the following to CLARION70.RED:

*.dbd = %TEMP%\obj

The Clarion environment expands the redirection line to:

*.dbd = c:TEMP\obj

The ROOT Macro

The redirection file directory can contain the predefined %ROOT% macro. By default, the %ROOT% macro expands to the drive and path one level above that from which the environment program is executing. For example, if the environment program is in C:\Clarion\BIN, the environment substitutes C:\Clarion for %ROOT%. The default redirection file uses the %ROOT% macro to work with Clarion's default directory structure, regardless of where you install Clarion.

You may override the %ROOT% macro's default substitution value by explicitly changing a value in the Redirection File options. For example:

Name:   ROOT

Value:   D:\Clarion

The LibPath Macro

The redirection system supports the %libpath% macro in the [Copy] section of a redirection file.  This macro evaluates to the folder where the .lib file is located when copying the matching .dll to the destination folder.

The default redirection file includes the folder %libpath%\bin\%configuration% in the Copy section.  This matches the structure implemented by Clarion.NET when you create a lib file for a .NET assembly, thus making it very easy to add .NET assembly projects to your win32 solution

Additional Macros:

REDNAME

Converts to the redirection file name based on the version of Clarion you are building with.

REDDIR

Expands to the directory where the default redirection file can be found for the version of Clarion you are building with.

WinUserApplicationData

Expands to the directory where the user application data is stored.

Under Windows 7 and later, this is C:\Users\{user name}\AppData\Roaming

Under Windows XP this will be the C:\Documents and Settings\{user name}\Application Data

WinCommonApplicationData

Expands to the directory where the common application data is stored.

Under Windows XP this is C:\Documents and Settings\All Users\Application Data folder by default.

THISDIR

Expands to the directory where the redirection file is located. This makes it easier to put your .DCT in a root folder or a folder of the root.

The Redirection {INCLUDE}

You can now include other redirection files in a target redirection by adding the following line:

{include <;redirection file name>}

This acts like the contents of the included redirection file is contained at the place where the {include} directive is placed.

The RED file uses a priority system. The earlier a line is read the higher the priority.

For example, if you have:

{include C:\myred.red}

{include C:\otherred.red}

And myred.red has the following line:

*.ico = C:\myicons

And myotherred.red has the following line:

*.ico = C:\othericons

If cancel.ico exists in both locations, then the one in the myicons folder would be used. However, if you reversed the include lines so you had'

{include C:\otherred.red}

{include C:\myred.red}

'then the cancel.ico in the othericons folder would be used.

In addition, any {include} within a section is only active when that section is active.

Relative paths in the {include} directive are now calculated based on the directory of the redirection file rather than the directory of the project file. This allows you to spread applications/redirection files over more than one level of folders. For example you could have multiple products that share common company sources and templates but may have product specific location for the output.

Redirection File Sections

The redirection file can be separated into sections that are conditionally ignored or used depending on Project System settings. The sections are of the form [Section Name] where Section Name is one of the following:

Section Name Project System Switch
DEBUG Debug Mode
RELEASE Release Mode
COMMON none - COMMON is always used
COPY none - COPY is always used

Redirection lines within a section are only used if the section's corresponding Project System switches are true (COMMON is always true). Redirection lines without a section are always used. For example:

[DEBUG]

*.obj = c:\test

[RELEASE]

*.obj = c:\release

[COMMON]

*.* = work

In this example if the Build Configuration is set to Release, then .obj files are created in c:\release.

If the Build Configuration is set to Debug, then .obj files are created in c:\test.

The Default Redirection File

*Note: The IDE checks for the existence of the RED file, and if it does not exist, the IDE creates a new default RED file.

[Copy]

– Directories only used when copying dlls

*.dll = %BIN%;%BIN%\AddIns\BackendBindings\ClarionBinding\Common;%ROOT%\Accessory\bin;%libpath%\bin\%configuration%

[Debug]

– Directories only used when building with Debug configuration

*.obj = obj\debug

*.res = obj\debug

*.rsc = obj\debug

*.lib = obj\debug

*.FileList.xml = obj\debug

*.map = map\debug

[Release]

– Directories only used when building with Release configuration

*.obj = obj\release

*.res = obj\release

*.rsc = obj\release

*.lib = obj\release

*.FileList.xml = obj\release

*.map = map\release

[Common]

*.chm = %BIN%;%ROOT%\Accessory\bin

*.tp? = %ROOT%\template\win

*.trf = %ROOT%\template\win

*.txs = %ROOT%\template\win

*.stt = %ROOT%\template\win

*.*   = .; %ROOT%\libsrc\win; %ROOT%\images; %ROOT%\template\win

*.lib = %ROOT%\lib

*.obj = %ROOT%\lib

*.res = %ROOT%\lib

*.hlp = %BIN%;%ROOT%\Accessory\bin

*.dll = %BIN%;%ROOT%\Accessory\bin

*.exe = %BIN%;%ROOT%\Accessory\bin

*.tp? = %ROOT%\Accessory\template\win

*.txs = %ROOT%\Accessory\template\win

*.stt = %ROOT%\Accessory\template\win

*.lib = %ROOT%\Accessory\lib

*.obj = %ROOT%\Accessory\lib

*.res = %ROOT%\Accessory\lib

*.dll = %ROOT%\Accessory\bin

*.*   = %ROOT%\Accessory\images; %ROOT%\Accessory\resources; %ROOT%\Accessory\libsrc\win; %ROOT%\Accessory\template\win

Additional Notes:

1.The default redirection file is designed to work with Clarion's default directory structure. If you change the directory structure, you should make corresponding changes to the redirection file.

2.You can specify extra directories that are searched for DLL files (used by the “Copy Referenced Dlls” option) by adding to the [Copy] section of the redirection file.

redirection_file.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1