PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Overview
  • Syntax
  • Declaring a dynamic object
  • Instantiating a dynamic object
  • Freeing a dynamic object
  • Remarks
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
An object can be dynamically associated with a class, we talk of dynamic instantiation of object.
The dynamic instantiation of an object allows you to create an object at a given time and to free this object when it is no longer used.
To instantiate an object, you must:
  1. Declare a dynamic object.
  2. Instantiate the object.
Remarks:
  • The object is automatically freed when it is no longer used. However, you can force the object destruction (to trigger the destructor execution for example).
  • The implementation of polymorphism requires the dynamic instantiation.
  • To retrieve the instance of the current object in the methods of the class, use the object keyword (or the this keyword).
MFile is Class
Name is string
Extension is string
Directory is string
END

SourceFile is object MFile dynamic
// ...
// Create the object
SourceFile = new MFile
// Process on the object...
// ...
// Free the object
delete
Syntax

Declaring a dynamic object

<ObjectName> is dynamic [object] <ClassName>
Details of syntax
<ObjectName>
Name that identifies the instance of the class.
<ClassName>
Name that identifies the class, defined when creating the class in the code editor.

Instantiating a dynamic object

<ObjectName> = new <ClassName> ([<Parameters>])
Details of syntax
<ObjectName>
Name that identifies the instance of the class.
<ClassName>
Name that identifies the class, defined when creating the class in the code editor.
<Parameters>
Optional parameters of constructor.

Freeing a dynamic object

Syntax 1:
delete <ObjectName>
Details of syntax
<ObjectName>
Name that identifies the instance of the class.

Syntax 2:
<ObjectName> = Null
Details of syntax
<ObjectName>
Name identifying the instance of the class.
Versions 16 and later
This parameter can correspond to a non-dynamic object.
New in version 16
This parameter can correspond to a non-dynamic object.
This parameter can correspond to a non-dynamic object.

Remarks

  • The object is automatically freed when it is no longer used. However, you can force the object destruction (to trigger the destructor execution for example).
  • To check whether a dynamic object is allocated and whether it was not freed yet, this object must be compared to NULL. For example:
    IF <Object Name> = NULL ...

    IF <Object Name> <> NULL...
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment