8.1. About the eval() Function

You can use the JavaScript eval() function to run simple scripts on global objects such as finder, global, metamodel, and self. Self represents the object on which eval() is started (myRequirement in the example below).


Note:  The load() function does not work due to internal limitations.


Example

{ m:myRequirement.eval('self.asil') }

In addition to self, the eval() function can be called with up to five additional parameters. These are defined as p2 through p6. You can use the parameters with additional JavaScript methods to get more specific results.

Examples

For a string text, use charAt()get the character at position 3.

{ m:text.eval('self.charAt(p2)', 3) }

For a string text, use indexOf() to get the position of substring foo and beginning the search at position 5 in the string.

{ m:text.eval('self.indexOf(p2,p3)', 'foo', 5) }