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.

TopicDescriptionExamples
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.

Some escaping examples:

ElementNameUsage With Escaping
Class attributestrange name having blanks and dots: ...
object.`strange name having blanks and dots: ...`;
Class attributea-b
object.`a-b`;
Operation::my strange operation name::
object.`::my strange operation name::`();
Parameteräparam
set `äparam` = "test";
Objecta//b
create `a//b`;
17_name
create `17_name`;

Case Sensitivity

All operations, statements, variable names, class names, and attribute names are case sensitive.

  • The variables myVar and myvar are two different variables.
  • The xUML Compiler will not recognize an assignment statement Set. you need to write set in lowercase instead.

Scripting StyleOperations can be scripted in an object-oriented or a procedural syntax style. The differences are shown in the example table on the right.
Object-Oriented StyleProcedural Style
myVariable.exists();
exists(myVariable);
myDataItem.myAttr.exists();
exists(myDataItem.myAttr);
s.substring(0, 5);
substring(s, 0, 5);
set aString = s.substring(0, 5).toUpper();
set aString = toUpper(substring(s, 0, 5));

Object Navigation

Use the following syntax to navigate to properties and operations within an object:

TargetSyntaxExample
PropertyobjectName.propertyName
product.category
OperationobjectName.operationName(parameters)
product.new()
Sub-property of a complex propertyobjectName.propertyName.subPropertyName
product.storage.area
Array propertyobjectName.arrayProperty
product.versions
Array property elementobjectName.arrayProperty[index]
product.versions[3]

Reserved Keywords

The following keywords, constants, operators etc. should not be used as variable names as they are reserved for action script execution:

  • and
  • append
  • apply
  • array
  • by
  • catch
  • create
  • distinct
  • each
  • else
  • errorCode
  • errorType
  • false
  • first
  • from
  • group
  • if
  • last
  • like
  • local
  • NULL
  • or
  • reduce
  • select
  • set
  • single
  • sort
  • then
  • to
  • true
  • unlike
  • use
  • using
  • where
  • No labels