CopyJsonStringFromSymbolProperties

CopyJsonStringFromSymbolProperties 1:

This method generates a corresponding JSON representation of PLC attributes on a symbol. In contrast to the AddJsonKeyPropertiesFromSymbol method, the result is not written to an instance of the function block FB_JsonSaxWriter, but to a string variable. The method receives as its input parameters the data type name of the symbol and a string variable that represents a list of the PLC attributes to be extracted, separated by a cross bar.

The method copies this JSON representation into a variable of the data type STRING, which can be of any length. The method returns the length of the string (including null termination). If the destination buffer is too small, it is emptied by a null termination and returned as length 0.

Syntax

METHOD CopyJsonStringFromSymbolProperties : UDINT
VAR_INPUT
  nDoc        : UDINT;
END_VAR
VAR_IN_OUT CONSTANT
  pDoc        : STRING;
  sDatatype   : STRING;
  sProperties : STRING;
END_VAR
VAR_OUTPUT
  hrErrorCode : HRESULT;
END_VAR

CopyJsonStringFromSymbolProperties 2: Return value

Name

Type

CopyJsonStringFromSymbolProperties

UDINT

CopyJsonStringFromSymbolProperties 3: Inputs

Name

Type

nDoc

UDINT

CopyJsonStringFromSymbolProperties 4:/CopyJsonStringFromSymbolProperties 5: Inputs/Outputs

Name

Type

pDoc

STRING

sDatatype

STRING

sProperties

STRING

CopyJsonStringFromSymbolProperties 6: Outputs

Name

Type

hrErrorCode

HRESULT

Sample call:

nLen := fbJsonDataType.CopyJsonStringFromSymbolProperties('ST_Test','Unit|DisplayName',sString,SIZEOF(sString));