PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Syntax
  • Declaring a dynamic object
  • Instantiating a dynamic object
  • Freeing a dynamic object
  • Notes
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.
Notes:
  • 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 current object in the class methods, use the object keyword (this keyword corresponds to this in other programming languages).
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
Versions 17 and later
AndroidUniversal Windows 10 App This feature is now available for the Android and Windows Phone applications.
iPhone/iPad This feature is now available for the iPhone/iPad applications.
New in version 17
AndroidUniversal Windows 10 App This feature is now available for the Android and Windows Phone applications.
iPhone/iPad This feature is now available for the iPhone/iPad applications.
AndroidUniversal Windows 10 App This feature is now available for the Android and Windows Phone applications.
iPhone/iPad This feature is now available for the iPhone/iPad applications.
Versions 21 and later
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
New in version 21
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
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.

Notes

  • 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 has not been freed, this object must be compared to NULL. For example:
    IF <Object Name> = NULL ...

    IF <Object Name> <> NULL...
AndroidJava Special case in Java/Android
The concept of destructor does not exist in Java/Android. Therefore, the code found in the destructor of a class will never be run.

An object is freed by the garbage collector when it is no longer referenced in the application. There is no way to foresee the moment when this operation occurs.

To force an object to be freed, you have the ability to assign it to NULL or to use the Free statement.
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment