getPath()

This function determines the absolute paths for panels, scripts etc.

Synopsis

string getPath(string keyword[, string filename[,intlangId = activeLang[,intlevel = 1]]]);

s tring getPath(string keyword[, string filename[, string|OaLanguagelang[,intlevel = 1]]]);

Parameters

Parameter Description
keyword Directory from the project structure, see below
filename The file name whose absolute path is to be determined (an entry does not have to be present)
langId

Language (with a language-dependent subdirectory (help, msg), the default is the active language

The index of the active language is -1. In case of index errors the function returns an exception. The function returns an empty string when the index is correct but the filename is not.

n = number of the project languages:

If ( langId < -1 ) || ( langId >= n ), an exception is thrown.

langId == -1 is interpreted as the index of the active language.

If ( langId >= -1 ) && ( langId < n ), and there is no file called filename, "an empty string " is returned.

lang string or OaLanguageEnum that defines the language (for language-dependent sub-directories)
level Numbering of all the directories of the search path from 1-SEARCH_PATH_LEN, where 1 is the <proj_dir> and SEARCH_PATH_LEN the <wincc_oa_dir> (the search is only carried out in the directory with the specified level). SEARCH_PATH_LEN is a defined constant that determines the maximum possible number of levels.

List of valid keywords:

Keyword directory
BIN_REL_PATH bin/
SOURCE_REL_PATH source/
HELP_REL_PATH help/ (CAUTION! The current project language, e.g. de_AT.io88591, is automatically added to the path. If no files are available for this language an empty string is returned!)
MSG_REL_PATH msg/
CONFIG_REL_PATH config/
PICTURES_REL_PATH pictures/
COLORDB_REL_PATH colorDB/
PANELS_REL_PATH panels/
IMAGES_REL_PATH images/
SCRIPTS_REL_PATH scripts/
LIBS_REL_PATH lib/
DATA_REL_PATH data/
DB_REL_PATH db/wincc_oa
LTA_REL_PATH lta/
LOG_REL_PATH log/
DPLIST_REL_PATH dplist/
NLS_REL_PATH nls/
PIXMAPS_REL_PATH pictures/
ICONS_REL_PATH pictures/
GIF_REL_PATH pictures/

Return value

The return value is the absolute path of the supplied parameters (for example, of a particular file) or an empty string.

Description

This function determines the absolute paths for panels, scripts and other WinCC OA elements based on the current path list and language.

The following calls are possible:

  • getPath(<keyword>)

returns <proj_path>/<directory for keyword>

  • getPath(<keyword>, <filename>)

Searches for the specified file <filename> in all Directories <keyword> of the search path and returns the file with the complete path if the file is located in one of the directories of the search path or "" if the file was not found.

  • getPath(<keyword>, <filename>, <langId | lang>)

If the file is located in a language-dependent subdirectory, the active language will be used by default. Otherwise the specified language (Parameters: langId or lang) will be used.

  • getPath(<keyword>, <filename>, <langId | lang>, <level>)

If a <level> (1..n) is specified, a search is only performed in the directory with the given level. The level is a numbering of all directories of the search path from 1-n where 1 is the <proj_path> and n the <wincc_oa_path>. To have easier access to the <wincc_oa_path>, getPath() should interpret level 0 as <wincc_oa_path>.

  • getPath(<keyword>, "", <langId | lang>, <level>)

Does not search for a file but returns the path with the required level

<searchpath(level)>/<directory for keyword>/.

The function getPath(HELP_REL_PATH, fileName) returns help/lang/fileName if the file exists in the lang directory. If the file exists only in the help/ directory, the function returns an empty string.

If accessing other files using File functions consider that they maybe have not yet been imported to the cache directory on the client. Thus, always use file functions together with the getPath() function. getPath() sends an HTTP request to the web server to download the current version of the file. See also getFileNamesRemote()

Example

For 1 parameter:

main()
{
  string path;
  path = getPath(MSG_REL_PATH); // path =
  <proj_path>/msg/
}

For 2 parameters:

main()
{
  string path;
  path = getPath(NLS_REL_PATH, "lang.dir");
  // path = <proj_path>/nls/lang.dir
}

For 3 parameters:

main()
{
  string path;
  path = getPath(HELP_REL_PATH, "lang.dir", 1);
  // path = <proj_path>/help/de_AT.iso88591
}

For 4 parameters:

main()
{
  string path;
  path = getPath(PANELS_REL_PATH, "", 1, 2);
  // path = <proj_dir_2>/panels/
}

Assignment

File functions

Administration of managers

Availability

CTRL