Examples using special modifiers

The assumed path and filename (filename base for the modifiers) used for the examples Listing 5.2 through Listing 5.13 is displayed in the following listing.

Listing: Example filename and path used for the following examples

C:\Freescale\my demo\TheWholeThing.myExt

Using the %p modifier as the following listing displays the path with a file separator but without the filename.

Listing: %p gives the path only with the final file separator

C:\Freescale\my demo\

Using the %N modifier only displays the filename in 8.3 format but without the file extension, as the following listing displays.

Listing: %N results in the filename in 8.3 format (only the first 8 characters)

TheWhole

The %n modifier returns the entire filename but with no file extension, as the following listing displays.

Listing: %n returns just the filename without the file extension

TheWholeThing

Using %E as a modifier returns the first three characters in the file extension, as the following listing displays.

Listing: %E gives the file extension in 8.3 format (only the first 3 characters)

myE

If you want the entire file extension, use the %e modifier, as the following listing displays.

Listing: %e is used for returning the whole extension

myExt

The %f modifier returns the path and the filename without the file extension, as the following listing displays.

Listing: %f gives the path plus the filename (no file extension)

C:\Freescale\my demo\TheWholeThing

The path in the listing, Example filename and path used for the following examples listed above contains a space, therefore using %" or %' is recommended, as the following listings displays.

Listing: Use %"%f%" in case there is a space in its path, filename, or extension

"C:\Freescale\my demo\TheWholeThing"
Listing: Use %'%f%' where there is a space in its path, filename, or extension

`C:\Freescale\my demo\TheWholeThing'

Using %(envVariable) an environment variable may be used. A file separator following %(envVariable) is ignored if the environment variable is empty or does not exist. If TEXTPATH is set as in following listing, then $(TEXTPATH)\myfile.txt is expressed as in next listing.

Listing: Example for setting TEXTPATH

TEXTPATH=C:\Freescale\txt
Listing: $(TEXTPATH)\myfile.txt where TEXTPATH is defined

C:\Freescale\txt\myfile.txt

However, if TEXTPATH does not exist or is empty, then $(TEXTPATH)\myfile.txt is expressed as in the following listing.

Listing: $(TEXTPATH)\myfile.txt where TEXTPATH does not exist

myfile.txt

It is also possible to display the percent sign by using %%. %e%% allows the expression of a percent sign after the extension as in the following listing.

Listing: %% allows a percent sign to be expressed

myExt%