Contact | Privacy | Datenschutzerklärung | Impressum

Objects

An object is a sequence of fields with an associated value and name. Each object belongs to a class. Each object field has an index (starting from 0) giving the position in the sequence. It has a value which can be of any heitml data type. Fields can have a name, a case insensitive string. The number of fields, their names and types can change dynamically.

An object can be used as a structure or record by accessing fields using the name. It can also be used as an array by indexing fields and as an associative array by using dynamic field names.

Creation

An object is created by using the emptytuple magic variable, the array() functions, or a constructor. Emptytuple creates a new object without fields that belongs to the class Object. Array creates an Object with n unnamed fields containing the null value also belonging to the Object class.

Operators

The operator . selects a field of an object.
Syntax:
Expr::= Expr . Fieldname .
FieldName::= Identifier .
The right operand of . must be an identifier and the left operand an object. The result is the field of the object designated by the identifier. The . operator can be used on the left hand side or the right hand side of an assignment statement. If used on the right hand side, the named field must be existent. If used on the left hand side a new field is added to the object, if necessary.

The operator [ ] can be used to index an object.
Syntax:
Expr::= Expr [ Expr ] .
The index must be of type integer or string. If t is an object and i an integer, t[i] denotes the i-th field of the object, where counting starts with 0. If s is a string t[s] denotes the field of t with name s.

Example:

input:resulting output:
<let tup=emptytuple; ? tup>()
<let tup=emptytuple; tup.field1='Hallo'; tup.test=5; ? tup>(field1="Hallo", test=5)
<let tup=array(3); tup[0]='Hallo'; tup[1]=5; ? tup>([0]="Hallo", [1]=5, [2]=null)
<let tup=emptytuple; tup["x+67"]='Hallo'; tup["x"+67]="Test"; ? tup>(x+67="Hallo", x67="Test")
<let tup=emptytuple; tup.field1='Hallo'; tup[0]=5; ? tup>(field1=5)
<let tup=emptytuple; tup.field1='Hallo'; tup["FiELd1"]=5; ? tup>(field1=5)
<let tup=array(2); tup[0]='Hallo'; tup.ito=5; ? tup>([0]="Hallo", [1]=null, ito=5)

Note that field names can be arbitrary strings, but the t.id syntax requires the field name to be an identifier. Using t["str"] instead arbitrary names can be used. Field names are always case insensitive.

Reference Semantics

Tuples have reference (also called pointer) semantics, as usual in object oriented languages. Assigning an object in fact assigns a reference to this object.

The copy() function can be used to actually copy an object (deep copy). The TuAssign() can be used to copy all fields of an object (shallow copy).

Example:

input:resulting output:
<let tup=emptytuple; ass=tup; tup.field1='content'; ? ass>(field1="content")
<let tup=emptytuple; ass=copy(tup); tup.field1='Hallo'; ? ass>()

Field Handling Functions

Using the isdecl(), isnull(), isempty(), and default() functions the presents of a field can be checked.

The function fname() returns the name of a specified field and findex() the index of the field. TuName() changes the name of a field and TuAssField() sets value and name.

TuAppField() appends a field after a given field and TuInsField() before it. TuDelField() removes a field from an object.

Object Field Functions

TuAssign() assigns all fields of a given object to another object, TuMerge() merges two objects, TuProject() and TuSlice() get a group of fields from an object.

ArAppend() and ArConcat() can be used to append fields or complete objects to a given object. These functions clear field names and so are useful for array operations. resize() can be used to change the size of an array. ArSearch() searches for a certain field content and TuFieldSort() sorts the fields of an object.


This page was dynamically generated by the web application development tool RADpage of H.E.I.

Selected blog articles : 3D Objects on HTML pages, CSS Transition Visibility, and CSS Transition Display.


© 1996-2024 H.E.I. All Rights Reserved.



Homepage
Intro/Features
Component Guide
Programming
  Language Guide
  Language Ref.
    General Design
    Lexical Structure
    Expressions
    Objects
    Methods
    Classes
    heitml Tags
    heitml Functions
    Advanced Functions
    Database Access
    Global Variables
    Form Fields
    Server Variables
    Sessions
    heitml Syntax
  Component Ref.
  Class Library
  User Components
  Tutorial
  New Features
  heitml 1
User Guide
Services
Privacy
Datenschutz
 
Contact / Impressum