getannotations
getannotations |
Purpose
Get model annotations associated to a given symbol.
Synopsis
procedure getannotations(mo:Model, id:string, prefix:string, si:set of string, ann:array(string) of string)
procedure getannotations(mo:Model, id:string, prefix:string, lsa:list of string)
procedure getannotations(id:string, prefix:string, si:set of string, ann:array(string) of string)
procedure getannotations(id:string, prefix:string, lsa:list of string)
Arguments
mo
|
A model reference
|
id
|
Symbol for which annotations are requested (an empty string will report global declarations)
|
prefix
|
Prefix filter: only annotations with a name starting by the specified prefix will be returned
|
si
|
Set receiving the annotation names
|
ann
|
Array receiving the annotation values (indiced by names)
|
lsa
|
List receiving the annotation names and values
|
Example
The following code snippet implements a function to retrieve a specific annotation for the specified model entity (if several matching annotations are found the value of the first is returned):
public function getannotation(symb:string, aname:string):string declarations l:list of string end-declarations getannotations(symb,aname,l) if l.size>=2 and getfirst(l)=aname then cuthead(l,1) returned:=getfirst(l) end-if end-function writeln("Value of first annotation 'my.annot' for entity 'x': ", getannotation("x","my.annot")) writeln("Value of first global annotation 'my.annot': ", getannotation("","my.annot"))
Further information
1. With the version taking a list, each annotation is represented by 2 entries: the first one is the annotation name and the second one its value. Note that the version returning information via an array will only report partial information in the case of annotations defined several times.
2. When used without a model reference these procedures return information for the calling model.
3. These routines cannot be used with remote models.
Related topics
Module