StrRemoveLastSlash

InstallShield 2014 » InstallScript Language Reference

The StrRemoveLastSlash function removes the trailing backslash from a path specification. Because its purpose is to produce a valid path, StrRemoveLastSlash does not remove the backslash from a root directory specification, such as “A:\” or “C:\”.

Syntax

StrRemoveLastSlash ( svPath );

Parameters

StrRemoveLastSlash Parameters

Parameter

Description

svPath

Specifies a string whose value must be a path specification; returns the path without the trailing backslash. Note that if the path does not include a trailing backslash, it is returned unchanged.

Return Values

StrRemoveLastSlash Return Values

Return Value

Description

0

Indicates that the function successfully removed the trailing backslash or that the path does not contain a trailing backslash.

< 0

Indicates that the function was unable to remove the trailing backslash.

Additional Information

StrRemoveLastSlash provides a convenient way to remove the trailing backslash from a path returned by AskPath or ParsePath. Because its purpose is to produce a valid path, StrRemoveLastSlash does not remove the backslash from a root directory specification, such as “A:\” or “C:\”; doing so would turn a valid path into a drive specification. If you need to remove the trailing backslash from a path in all cases, use the following script segment as a guide.

    AskPath("", "", svPath);

 

    if (StrLength(svPath) = 3)

        && (svPath[1] = ":")

        && (svPath[2] = "\\") then

 

        svTempString = svPath;

        StrSub(svPath,svTempString,0,2);

    else

       StrRemoveLastSlash(svPath);

    endif;

See Also