Function AttributeToString(IdentifierName, AttributeName)

AttributeToString

The function AttributeToString converts a specified attribute for a given identifier to a string.

AttributeToString(
     IdentifierName,       ! (input) scalar element parameter
     AttributeName         ! (input) scalar element parameter
     )

Arguments

IdentifierName

An element expression in the predefined set AllIdentifiers specifying the identifier for which an attribute should be converted to a string.

AttributeName

An element expression in the predefined set AllAttributeNames specifying the attribute that should be converted to string format.

Return Value

This function returns a string representation of the attribute on success or the empty string otherwise and the predeclared identifier CurrentErrorMessage contains an appropriate error message.

Note

In order to protect the intellectual property of the model developer, the string Encrypted is returned and the predeclared identifier CurrentErrorMessage contains an appropriate error message, when the identifier is in an encrypted section of the model. There is one exception; if the procedure making the call AttributeToString(id,attr) is in the same component as the identifier id, the attribute attr is still returned as string. Here component is the main model or one of the libraries.

Example

Given the declaration:

Parameter p {
    Comment: "Hello""}

inside the nested module chapterModel::sectionModelQuery::funcAttributeToString, the code that queries the comment attribute of identifier p is:

1_ep_p := StringToElement(AllIdentifiers,
2    "chapterModel::sectionModelQuery::funcAttributeToString::p",
3    create: 0);
4_sp_cmt := AttributeToString(_ep_p, 'comment');
5block where single_column_display := 1, listing_number_precision := 6 ;
6    display { _ep_p, _sp_cmt };
7endblock ;

Remark:

  • Lines 1-3: Note that the name of the identifier contains all prefixes of the modules it is in.

The results in the listing file:

_ep_p   := 'chapterModel::sectionModelQuery::funcAttributeToString::p' ;
_sp_cmt :=                                                   "Hello\n" ;

References