makeNativePath()
Converts a file path into a operating system specific file format.
Synopsis
string makeNativePath(string path);
Parameters
Parameter | Description |
---|---|
path | The path that is converted as a string constant. You can also use the predefined string constants. See chapter Predefined symbolical constants. |
Return value
The converted path
Error
Missing or wrong arguments
Description
Converts a file path into a operating system specific file format (this means that slashes / in a file path are replaced via backslashes \.). The function is useful when file paths are passed to external modules that were not developed platform neutrally. The function does not check whether the path is valid. Note the naming convention for path specifications (see chapters Paths and Naming Convention/ Notation).
Example
The function checks if the file path created via the function tmpnam() is the project path.
main()
{
string sTestPath = PROJ_PATH + "data";
/*
Specifies the project path and the data directory
*/
bool bIsPath = isProjPath(sTestPath);
DebugN("Is this the proj Path", sTestPath, bIsPath);//e.g.
D:/WinCC_OA_Projects/WinCCOA_Project/data
sTestPath = WINCCOA_PATH + "data"; //The ínstallation path + the
data directory
bool bIsPath = isProjPath(sTestPath); //Passes the installation
path + data directory
DebugN("Is this the proj path", sTestPath, bIsPath);
/*
Checks if the path specified by the function tmpnam() is the
project path
*/
sTestPath = tmpnam(); //the function tmpnam creates a temporary
file name
bool bIsPath = isProjPath(sTestPath);
}
/*
The function checks if the path is the project path.
! The function does not check if the path exists
*/
bool isProjPath(string path)
{
string sNativeProjPath = makeNativePath(PROJ_PATH);
string sNativeTestPath = makeNativePath(path);
return ( strpos(sNativeTestPath, sNativeProjPath) == 0 );
/* The function strpos searches the string sNativeProjPath in
the string sNativeTestPath */
}
The function outputs:
WCCOAui2: ["Is this the proj Path"]["D:/WinCC_OA_Projects/WinCCOA_Project/data"][1]
WCCOAui2: ["Is this the proj Path"]["C:/Siemens/Automation/WinCC_OA/3.14/data"][0]
Assignment
Availability
UI, CTRL