خانه > def > object 
 en fr de es it nl pl pt pt_BR mk sq ca hu cs tr ar id vi ko ja ru zh zh_TW eo
قبلی  بعدی  ویرایش  تغییر نام  واگرد  بازآوردن  Search  سرپرستی  
مستندات
تاریخچه
 
اخطار! این صفحه ، روز آمد (up-to-date) نمی باشد.  مشاهده نسخه انگلیسی 
شی

Class

A class may be defined either in گامباس as e.g. the class "TextBox" or the programmer creates a new own class.

A class never has an address. A class cannot be displayed.

Object

To use a class at runtime, it must be instantiated. By this an object is created. This is either done by the framework at start, or by the program with the /lang/new2 command.

In both cases some memory holds all the variables of the class.

Objects have a runtime address. This address can be displayed in the watch window. As well members of the object can be displayed in the watch window.

Examples

In this example "TextBox" is a class. "TextBox1" is an object, which is created by the IDE. "xTextBox1" is a reference to an object of the type TextBox. Later in this example the reference to the IDE created "TextBox1" is copied to "xTextBox1". In the watch window of the IDE both references show the same hexadecimal address. As well members of the object can be displayed in the watch window.

Expression Value
TextBox ERROR: Unknown ...
TextBox1 (TextBox 0x81099c0)
xTextBox1 (TextBox 0x81099c0)
xTextBox1.Text "Set xTextBox1"

مثال

PUBLIC SUB Button1_Click()
DIM xTextBox1 AS TextBox            ' can hole the address of the object

xTextBox1 = TextBox1                ' gets the address of the already existing object
xTextBox1.Text = "Set xTextBox1"
xTextBox1.X = TextBox1.X + 80
xTextBox1.Y = TextBox1.Y + 120
END

In this example "TextBox" is a class. "xTextBox1" is an object of this class, which will be created new on the Form Form1. And then filled with a Text and moved to a place somewhere relative to the IDE created TextBox with the name TextBox1

PUBLIC SUB Button1_Click()
DIM xTextBox1 AS TextBox            ' can hold the address of the object

xTextBox1 = NEW TextBox(Form1)      ' Instatiate a TextBox, create the object
xTextBox1.Text = "Set xTextBox1"
xTextBox1.X = TextBox1.X + 80
xTextBox1.Y = TextBox1.Y + 120
END