GetServerTagPrefix
Description TagPrefix
In order for a WinCC client in a distributed system to access tags of the associated server, the tag names must be expanded to include the server prefix.
A pointer of type “char” to server prefix, tag prefix, and window prefix is returned in each case.
The user is not permitted to change the memory (including no strcat) or release it.
Can only be used in C scripting.

Syntax
void GetServerTagPrefix (char** ppszServerPrefix, char** ppszTagPrefix, char** ppszWindowPrefix);
Return value
ppszServerPrefix
Pointer to a pointer that references the server prefix
ppszTagPrefix
Pointer to a pointer that references the tag prefix
ppszWindowPrefix
Pointer to a pointer that references the window prefix
Example
The following program code retrieves the server prefix, tag prefix and window prefix checks their validity. If an error occurs, a text is output and the function is exited. If the check is successful a tag name is created and returned. Processing is executed as follows:
- Declaration of pointer pszServerPrefix, pszTagPrefix and pszWindowPrefix for the three prefixes
- Initialization of the nServerPrefixLen, nTagPrefixLen and nTagLen tagsThey serve as a buffer for the string length of the prefixes to be read out.
- Initialization of the myTagName tag
- Reading out of server prefix, tag prefix and window prefix
- Case distinction: Server prefix
- – No server prefix returned: a text is output and the function is exited.
- – Server prefix returned: Its length is determined and saved in the nServerPrefixLen tag.
- If a tag prefix is returned, its length is determined and saved in the nTagPrefixLen tag.
- Determines the length of the tag name and saves it in the nTagLen tag.
- Case distinction: Permissible length for tag name
- – Permissible length exceeded: a text is output and the function is exited.
- – Permissible length not exceeded: The tag name required for a client environment is compiled.
| { char* pszServerPrefix; char* pszTagPrefix; char* pszWindowPrefix; int nServerPrefixLen = 0; int nTagPrefixLen = 0; int nTagLen = 0; char myTagName[MAX_DM_VAR_NAME+1]; //Initialize the return valuememset(myTagName,0,MAX_DM_VAR_NAME + 1); //Get the serverprefix the tagprefix and the windowprefixGetServerTagPrefix(&pszServerPrefix, &pszTagPrefix, &pszWindowPrefix); //If a serverprefix exists if (pszServerPrefix) { //Get the length of the string nServerPrefixLen = strlen(pszServerPrefix);} Else{ printf(“No server prefix was returned.”); return;} //If a tagprefix existsif (pszTagPrefix) { //Get the length of the string nTagPrefixLen = strlen(pszTagPrefix);} //Get the length of the tagnTagLen = strlen(“TagName”); //Check if the lenght of the //ServerPrefix+TagPrefix+VarName + the double points < MAX_DM_VAR_NAME) if (nServerPrefixLen + nTagPrefixLen + nTagLen+2 < MAX_DM_VAR_NAME) { sprintf(myTagName,”%s::%s%s”,pszServerPrefix,pszTagPrefix,”TagName”); //User defined code where the //user can do something with the returnvalue …} Else{ printf(“The resulting string is too long.”); return;}} |






