Please enable JavaScript to view this site.

In X/script source you can define your own data type, formally known as object.

A object can contain attributes (any type of variable, including user defined data) and methods (declared as functions inside the object itself).

Object prototype

Object cannot be prototyped as functions: they have to be declared before they can be used.

Object declaration

An object is declared using the object keyword.

OBJECT <objname>

...

[<attributes>]

...

[<methods>]

END[OBJECT]

Where:

<objname> is the object name, then used as user data type.

<attributes> attribute declarations.

<methods> methods declarations.

Note: attribute and methods must be declared before any inline method use it, otherwise the declaration order is not important.

Attribute declaration

Attribute declaration are variable declaration but having scope only in the object itself. The general syntax is:

[INTERNAL] <type> <variable> [, < variable> ...]

The special keyword internal means, when used, that the variable is readonly and cannot be written by anyone.

Methods declaration

Methods declaration is very similar to function declaration (with some syntax difference) and can be of two types: prototype and inline declaration.

When prototyping use the following syntax (see function prototype for more details):

CODE <name> ([<argument>, ... ]) [:<result>]

CODE ASSIGNABLE <name> ([<argument>, ...]): <type>

When declaring inline method use the following syntax (see function declaration for more details):

INLINE <name> ([<argument>, ... ]) [:<result>]

...

[RETURN <value>]

END[INLINE]

and when declaring inline assignable methods:

INLINE ASSIGNABLE <name> ([<argument>, ... ]) [:<type>]

...

END[INLINE]

Prototype implementation

Any prototyped method in a object, must be declared outside the object declaration, with following syntax:

CODE <objname>.<name> ([<argument>, ... ]) [:<result>]

...

[RETURN <value>]

END[CODE]

and with following syntax for assignable methods:

CODE ASSIGNABLE <objname>.<name> ([<argument>, ... ]) [:<type>]

...

END[CODE]

Note: inline methods have no implementation since is already done in object declaration.

Internal methods declaration

As internal function declaration, you can prototype internal methods, with the following syntax:

INTERNAL <id> <name> ([<argument>, ... ]) [:<result>]

INTERNAL <id> ASSIGNABLE <name> ([<argument>, ...]): <type>

WARNING: never define an internal method without knowing well what you are doing. You can cause serious damage and crashes to your system and loose important data or files.

 

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Contents: ALT+c
Search: ALT+s
Exit Menu/Up: ESC