Basics of the Action Script Language
The Action Script language comes with a syntax scheme as explained below. Also, the reserved keywords of the Action Script language cannot be used as variable names.
When writing action scripts, you should respect the following explanations regarding
Syntax Scheme
The following syntax scheme applies to the action script language.
Names
All object and attribute names in Action Scripts must follow the syntax below:
[a-zA-Z]([a-zA-Z0-9])*
However, UML names are not restricted and may contain any character. To use these names in Action Scripts apply backticks as follows:
If the name of an element contains other characters, it must be escaped by backticks as follows:
`invalid name`
Consequently, the only characters not allowed in element names that are to be used in action scripts are backticks (`
).
If the invalid attribute name is given by an external representation, e.g. it has to be serialized into an XML document, flat file, IDocs or such, you can also use the attribute externalName on attributes to hold the external name.
This way, you can use a valid name internally. Once the data is serialized, the external name will be used.
Examples
Some escaping examples:
Element | Name | Usage With Escaping |
---|---|---|
Class attribute | strange name having blanks and dots: ... |
|
Class attribute | a-b |
|
Operation | ::my strange operation name:: |
|
Parameter | äparam |
|
Object | a//b |
|
17_name |
|
Case Sensitivity
All operations, statements, variable names, class names, and attribute names are case sensitive.
Examples
The variables myVar and myvar are two different variables.
The xUML Compiler will not recognize an assignment statement
Set
. You need to writeset
in lowercase instead.
Scripting Style
Operations can be scripted in an object-oriented or a procedural syntax style. The differences are shown in the example table on the right.
Examples
Object-oriented Style | Procedural Style |
---|---|
|
|
|
|
|
|
|
|
Object Navigation
Use the following syntax to navigate to properties and operations within an object:
Target | Syntax | Example |
---|---|---|
Property |
|
|
Operation |
|
|
Sub-property of a complex property |
|
|
Array property |
|
|
Array property element |
|
|
Reserved Keywords
The following keywords, constants, operators etc. should not be used as variable names as they are reserved for action script execution:
|
|
|