[Rename] Object-oriented programming simulation for a virtual object manager

Just starting out? Need help? Post your questions and find answers here.
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: A virtual object manager code

Post by Mijikai »

Whats the actual goal here (i am confused)?
Realizing objects with vtables and interfaces is nothing new.
ShadowStorm
Enthusiast
Enthusiast
Posts: 303
Joined: Tue Feb 14, 2017 12:07 pm

Re: A virtual object manager code

Post by ShadowStorm »

Mijikai wrote: Thu Feb 20, 2025 10:26 pm Whats the actual goal here (i am confused)?
Realizing objects with vtables and interfaces is nothing new.
I’m exploring different approaches!
Yes, I’m trying to find the method that suits me best.
I’ve done a lot of experimenting because, at first, I couldn’t achieve what I wanted—a simpler syntax, as I had imagined.
After testing and seeking help from the AI, we finally came up with a solution that works.
I don’t understand the prototypes introduced by the AI, but it works, so I’m sticking with it for now!
And I’m not using those damn interfaces!
Honestly, I never really understood how interfaces work, and besides, they didn’t fully meet my needs. For example, I couldn’t access object properties directly—only call methods.

Code: Select all

; Code créer par Dieppedalle David avec l'aide de l'IA, le 21/02/2025.
; Code created by Dieppedalle David with the help of AI, on 02/21/2025.

; ======================================================
; Structure des propriétés de l'Objet.
; Structure of the Object's properties.
; ======================================================
Structure ObjectProperties
  ID.i    ; L'ID de l'Objet              |   The ID of the Object.
  Name.s  ; Le nom de l'Objet.           |   The Name of the Object.
  X.i     ; La coordonnée ou valeur X.   |   The X coordinate or value.
  Y.i     ; La coordonnée ou valeur Y.   |   The Y coordinate or value.
EndStructure

; ======================================================
; Prototypes pour les méthodes.
; Prototypes for methods.
; ======================================================
Prototype.i ProtoIntFunc()                             ; Méthode sans paramètre qui retourne un entier.                      |   Method without parameters that returns an integer.
Prototype.s ProtoStrFunc()                             ; Méthode sans paramètre qui retourne une chaîne.                     |   Method without parameters that returns a string.
Prototype.s ProtoStrFuncWithParams(Title.s, Message.s) ; Méthode avec paramètres (Title, Message) qui retourne une chaîne.   |   Method with parameters (Title, Message) that returns a string.

; ======================================================
; Une structure où chaque champ contient l'adresse 
; de la procédure qui porte le nom du champ.
;
; A structure where each field contains the address 
; of the procedure with the same name as the field.
; ======================================================
Structure ObjectMethods
  *Abc123.ProtoIntFunc           ; *Abc123 est un Pointeur de Type ProtoIntFunc qui est un Prototype.             |   *Abc123 is a Pointer of Type ProtoIntFunc which is a Prototype.
  *Abc246.ProtoIntFunc           ; *Abc246 est un Pointeur de Type ProtoIntFunc qui est un Prototype.             |   *Abc246 is a Pointer of Type ProtoIntFunc which is a Prototype.
  *AbcXY.ProtoIntFunc            ; *AbcXY est un Pointeur de Type ProtoIntFunc qui est un Prototype.              |   *AbcXY is a Pointer of Type ProtoIntFunc which is a Prototype.
  *AbcStr.ProtoStrFunc           ; *AbcStr est un Pointeur de Type ProtoStrFunc qui est un Prototype.             |   *AbcStr is a Pointer of Type ProtoStrFunc which is a Prototype.
  *AbcBox.ProtoStrFuncWithParams ; *AbcBox est un Pointeur de Type ProtoStrFuncWithParams qui est un Prototype.   |   *AbcBox is a Pointer of Type ProtoStrFuncWithParams which is a Prototype.
EndStructure

; ======================================================
; Structure principale de l'Objet.
; Main Object structure.
; ======================================================
Structure StructureObject
  *Properties.ObjectProperties  ; Pointeur (*Properties) de type ObjectProperties qui pointe vers les propriétés (état).   |   Pointer (*Properties) of type ObjectProperties that points to properties (state).
  *Methods.ObjectMethods        ; Pointeur (*Methods) de type ObjectMethods qui pointe vers les méthodes (comportement).   |   Pointer (*Methods) of type ObjectMethods that points to methods (behavior).
EndStructure

Global NextObjectID.i = 1
Global *CurrentObject.StructureObject  ; Variable globale pour stocker l'Objet courant.   |   Global variable to store the current Object.

; ======================================================
; Des procédures quelconque.
; Any procedures.
; ======================================================
Procedure.i Abc123()
  ProcedureReturn 123  ; Retourne la valeur entière 123.   |   Returns the integer value 123.
EndProcedure

Procedure.i Abc246()
  ProcedureReturn 246  ; Retourne la valeur entière 246.   |   Returns the integer value 246.
EndProcedure

Procedure.i AbcXY()
  ; Utilise le contexte global pour accéder aux propriétés de l'Objet courant. 
  ; Uses the global context to access the properties of the current Object.
  If *CurrentObject And *CurrentObject\Properties
    ProcedureReturn *CurrentObject\Properties\X + *CurrentObject\Properties\Y
  Else
    Debug "Error: Object Or properties Not initialized."
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure.s AbcStr()
  ; Utilise le contexte global pour accéder aux propriétés de l'Objet courant et retourne une chaîne formatée. 
  ; Uses the global context to access the properties of the current Object and returns a formatted string.
  If *CurrentObject And *CurrentObject\Properties
    ProcedureReturn "X + Y = " + Str(*CurrentObject\Properties\X + *CurrentObject\Properties\Y)
  Else
    Debug "Error: Object Or properties Not initialized."
    ProcedureReturn ""
  EndIf
EndProcedure

Procedure.s AbcBox(Title.s, Message.s)
  ; Affiche une boîte de message avec un titre et un message, puis retourne une chaîne de confirmation.
  ; Displays a message box with a title and message, then returns a confirmation string.
  MessageRequester(Title, Message)
  ProcedureReturn "Message displayed !"
EndProcedure

; ======================================================
; Création d'un nouvel Objet.
; Creating a new Object.
; ======================================================
Procedure.i NewObject()
  
  ; Déclare un Pointeur (*Object) protégé de type StructureObject, qui prend comme valeur l'adresse de la structure "StructureObject".
  ; Ensuite, alloue un nouvel Objet de type Structure dynamique.
  ; 
  ; Declares a protected Pointer (*Object) of type StructureObject, which takes as a value the address of the "StructureObject" structure.
  ; Then, allocates a new Object of dynamic Structure type.
  Protected *Object.StructureObject = AllocateStructure(StructureObject)
  
  ; Si l'Objet *Object est bien initialisé.
  ; If the Object *Object is properly initialized.
  If *Object.StructureObject
    
    ; Alloue un nouvel Objet "Properties" de type Structure dynamique qui prend comme valeur l'adresse de la structure "ObjectProperties".
    ; Allocates a new "Properties" Object of dynamic Structure type which takes as a value the address of the "ObjectProperties" structure.
    *Object\Properties = AllocateStructure(ObjectProperties)
    
    ; Si l'Objet "Properties" n'est pas initialisé.
    ; If the "Properties" Object is not initialized.
    If Not *Object\Properties
      Debug "Error: Unable To allocate Object properties."
      FreeStructure(*Object) ; Supprime l'Objet car il a pu être créé.   |   Remove the Object as it has been created.
      ProcedureReturn 0
    EndIf
    
    ; Alloue un nouvel Objet "Methods" de type Structure dynamique qui prend comme valeur l'adresse de la structure "ObjectMethods".
    ; Allocates a new "Methods" Object of dynamic Structure type which takes as a value the address of the "ObjectMethods" structure.
    *Object\Methods = AllocateStructure(ObjectMethods)
    
    ; Si l'Objet "Methods" n'est pas initialisé.
    ; If the "Methods" Object is not initialized.
    If Not *Object\Methods
      Debug "Error: Unable To allocate Object methods."
      FreeStructure(*Object\Properties) ; Supprime les propriétés de l'Objet car elles ont pu être créées.   |   Remove the properties of the Object as they have been created.
      FreeStructure(*Object)            ; Supprime l'Objet car il a pu être créé.   |   Remove the Object as it has been created.
      ProcedureReturn 0
    EndIf
    
    ; Affecte un Numéro d'identification à l'Objets en fonction de la variable NextObjectID.i.
    ; Assigns an identification number to the object according to the NextObjectID.i variable.
    *Object\Properties\ID = NextObjectID.i
    NextObjectID.i + 1
    
    ; Associe les méthodes aux champs correspondants, chaque champ contient l'adresse mémoire de la procédure qui porte le nom du champ.
    ; Associates methods with the corresponding fields, each field contains the memory address of the procedure that has the same name as the field.
    *Object\Methods\Abc123 = @Abc123()
    *Object\Methods\Abc246 = @Abc246()
    *Object\Methods\AbcXY = @AbcXY()
    *Object\Methods\AbcStr = @AbcStr()
    *Object\Methods\AbcBox = @AbcBox()
    
    ; Retourne un pointeur qui est l'adresse mémoire de la structure "StructureObject".
    ; Returns a pointer which is the memory address of the "StructureObject" structure.
    ProcedureReturn *Object
    
  Else
    ProcedureReturn 0
    
  EndIf

EndProcedure

; ======================================================
; Détruit un objet et libère toute sa mémoire allouée.
; Destroys an Object and releases all its allocated memory.
; ======================================================
Procedure.b DestroyObject(*Object.StructureObject)
  
  ; Vérifie si l'objet est valide (non-nul)   |   Checks if Object is valid (non-null).
  If *Object
    
    If *Object\Properties 
      FreeStructure(*Object\Properties) ; Libère les propriétés   |   Frees properties.
    EndIf
    
    If *Object\Methods 
      FreeStructure(*Object\Methods) ; Libère les méthodes   |   Frees methods.
    EndIf
    
    FreeStructure(*Object) ; Libère l'objet principal   |   Frees main Object.
    
    ProcedureReturn 1
    
  Else
    Debug "Error: Object Not initialized: " + Str(*Object)
    ProcedureReturn 0
    
  EndIf
    
EndProcedure




; --------------------------------

; Exemple d'utilisation:
; Example of use:

; ======================================================
; Création d'instance.
; Instance creation.
; ======================================================
*MyObject.StructureObject = NewObject() ; Crée un nouvel Objet.   |   Creates a new Object.

; Si l'Objet existe.   |   If the Object exists.
If *MyObject
  
; *CurrentObject est un Pointeur globale définie plus haut dans le code qui sert à savoir l'Objet courant actuel.
; *CurrentObject is a Global Pointer defined earlier in the code, used to identify the current Object.
*CurrentObject = *MyObject ; Enregistre l'Objet courant (*MyObject) dans le pointeur *CurrentObject, sert à ne pas passer l'Objet *MyObject en paramètre des méthodes.
                           ; Saves the current Object (*MyObject) in the *CurrentObject pointer, so as not to pass the *MyObject as a methods parameter.

Debug "Adress Object: " + Str(*MyObject)                       ; Affiche l'adresse mémoire de l'instance de l'Objet.         |   Displays the memory address of the Object instance.
Debug "Adress Object Properties: " + Str(*MyObject\Properties) ; Affiche l'adresse mémoire de la structure des propriétés.   |   Displays the memory address of the properties structure.
Debug "Adress Object Methods: " + Str(*MyObject\Methods)       ; Affiche l'adresse mémoire de la structure des méthodes.     |   Displays the memory address of the methods structure.
Debug "-----------------------------------"

; ======================================================
; Modification des propriétés.
; Modification of properties.
; ======================================================
*MyObject\Properties\Name = "Object #1"    ; Définit la propriété Name à "Object #1".    |   Sets Name property to "Object #1".
*MyObject\Properties\X = 15                ; Définit la propriété X à la valeur de 15.   |   Sets X property to 15.
*MyObject\Properties\Y = 25                ; Définit la propriété Y à la valeur de 25.   |   Sets Y property to 25.

Debug "Object ID: " + Str(*MyObject\Properties\ID)  ; Affiche la valeur de la propriété ID.                          |   Displays ID property value.
Debug "Object X: " + Str(*MyObject\Properties\X)    ; Affiche la valeur de la propriété X.                           |   Displays X property value.
Debug "Object Y: " + Str(*MyObject\Properties\Y)    ; Affiche la valeur de la propriété Y.                           |   Displays Y property value.
Debug "Object Name: " + *MyObject\Properties\Name   ; Affiche la valeur de la propriété Name sous forme de chaîne.   |   Displays Name property value as a string.
Debug "-----------------------------------"

; ======================================================
; Appel des fonctions sans passer explicitement les propriétés dans les paramètres. 
; Calling functions without explicitly passing properties in parameters. 
; ======================================================
Debug "Adress Object Methode Abc123:" + Str(*MyObject\Methods\Abc123)    ; Affiche l'adresse mémoire de la méthode Abc123().   |    Displays memory address of Abc123 method().
Debug "Adress Object Methode Abc246:" + Str(*MyObject\Methods\Abc246)    ; Affiche l'adresse mémoire de la méthode Abc246().   |    Displays memory address of Abc246 method().
Debug "Adress Object Methode AbcXY:" + Str(*MyObject\Methods\AbcXY)      ; Affiche l'adresse mémoire de la méthode AbcXY().    |    Displays memory address of AbcXY method().
Debug "Adress Object Methode AbcStr:" + Str(*MyObject\Methods\AbcStr)    ; Affiche l'adresse mémoire de la méthode AbcStr().   |    Displays memory address of AbcStr method().
Debug "Adress Object Methode AbcBox:" + Str(*MyObject\Methods\AbcBox)    ; Affiche l'adresse mémoire de la méthode AbcBox().   |    Displays memory address of AbcBox method().
Debug "-----------------------------------"

Debug "Object Fonction Abc123: " + Str(*MyObject\Methods\Abc123())       ; Appelle et affiche le résultat de la méthode Abc123().   |    Calls and displays result from Abc123 method().
Debug "Object Fonction Abc246: " + Str(*MyObject\Methods\Abc246())       ; Appelle et affiche le résultat de la méthode Abc246().   |    Calls and displays result from Abc246 method().
Debug "Object Fonction AbcXY: " + Str(*MyObject\Methods\AbcXY())         ; Appelle et affiche le résultat de la méthode AbcXY().    |    Calls and displays result from AbcXY method().
Debug "Object Fonction AbcStr: " + *MyObject\Methods\AbcStr()            ; Appelle et affiche le résultat de la méthode AbcStr().   |    Calls and displays result from AbcStr method().

; Appel de la méthode avec paramètres:   -   Calling a method with parameters:
Debug "Result of AbcBox: " + *MyObject\Methods\AbcBox("Information", "Hello, world!")

Else
  Debug "Erreur: Objet non initialisés: " + Str(*MyObject)
  
EndIf

In my code, here is an allegory of what it does (Text created by AI, slightly modified by me):

*1. MyObject: The "invisible" master!

Role: It coordinates its two employees (Properties and Methods) without ever directly interacting with the outside world.
Power: It hires and fires its employees using (NewObject() and FreeStructure()).
Limitation: It only sees its employees (Properties and Methods), not the subcontractors (X, Y, Name, AbcXY...).

**2. The employees: Properties and Methods

*Properties (Data Department)
Role: Manages the subcontractors: X, Y, Name.
Actions: Transmits and collects data on their behalf.
Secret: The subcontractors are completely unaware of the existence of *MyObject, and vice versa.

*Methods (Operations Department)
Role: Hires external experts (AbcXY, AbcStr...) to perform tasks.
Actions: Gives orders.
Secret: The experts do not know they are working for *MyObject, and vice versa.

3. The subcontractors: X, Y, Name, AbcXY...
Status: Independent, interchangeable, specialized.

Relationship:

X/Y/Name: Only know *Properties.
AbcXY/AbcStr: Only know *Methods.

Mutual ignorance: None of the subcontractors know that *MyObject exists.

4. Hierarchical control: The genius of the architecture
Level 1: *MyObject (CEO)
Level 2: *Properties (Data Director) and *Methods (Operations Director)
Level 3: X/Y/Name (Data) and AbcXY/AbcStr (Operations)

Advantages:

Encapsulation: No information leakage between levels.
Flexibility: Changing *Properties or *Methods does not affect *MyObject.
Scalability: Easy addition of new subcontractors (e.g., Z, AbcLog...).

5. Philosophical limitation: The isolation of the master
*MyObject is an omniscient but isolated manipulator:

It controls everything through its employees, who act as mere messengers, but it never communicates directly
with the subcontractors for fear of getting its hands dirty or facing issues with justice or karma.

The subcontractors act blindly, unaware of who is mandating them—they are merely pawns.
This is the price of abstraction: *MyObject sacrifices its "visibility" to gain organizational power.
Last edited by ShadowStorm on Sat Feb 22, 2025 5:22 pm, edited 2 times in total.
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 456
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: A virtual object manager code

Post by Mindphazer »

Maybe you should start learning the basics of coding by trying to program something simple, like Tetris for example, before touching on concepts you don't understand.
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: A virtual object manager code

Post by Mijikai »

ShadowStorm wrote: Fri Feb 21, 2025 12:43 am For example, I couldn’t access object properties directly—only call methods.
Object (struct + vtable) & Interface share the same address, values within the object can be accessed.

Example:

Code: Select all

EnableExplicit

;Template: Object + Dynamic VTable
;Project: Objects and Interfaces
;Author: Mijikai

;----------------------------------------- OBJECT STRUCT

Structure OBJECT
  *vtable
  Array *methods(0);<- if methods should be dynamic (otherwise use for ex. datasection or a buffer...)
EndStructure

;----------------------------------------- BALL OBJECT STRUCT

Interface METHODS_BALL
  Add.i(Value.i)
  Sub.i(Value.i)
  Rename.i(Name.s)
  Release.i();<- could be in a seperate interface (usually objects also allocate stuff so this is more practical)
EndInterface

Structure OBJECT_BALL Extends OBJECT
  *method.METHODS_BALL
  name.s
  x.i
  y.i
EndStructure

;----------------------------------------- BALL FUNCTIONS/METHODS

Procedure.i ballAdd(*Object.OBJECT_BALL,Value.i)
  With *Object
    \x + Value
    \y + Value
    ProcedureReturn #Null
  EndWith
EndProcedure

Procedure.i ballSub(*Object.OBJECT_BALL,Value.i)
  With *Object
    \x - Value
    \y - Value
    ProcedureReturn #Null
  EndWith
EndProcedure

Procedure.i ballRename(*Object.OBJECT_BALL,Name.s)
  With *Object
    \name = Name
    ProcedureReturn #Null
  EndWith
EndProcedure

Procedure.i ballRelease(*Object.OBJECT_BALL)
  ProcedureReturn FreeStructure(*Object)
EndProcedure

Procedure.i ballObject();<- create the object
  Protected.OBJECT_BALL *object
  Protected.i count
  With *object
    *object = AllocateStructure(OBJECT_BALL)
    If *object
      count = 3;<- we have 4 (0 - 3) methods (more methods could be added/removed later at any time)
      ReDim \methods(count)
      If ArraySize(\methods(),1) = count
        \methods(0) = @ballAdd()
        \methods(1) = @ballSub()
        \methods(2) = @ballRename()
        \methods(3) = @ballRelease()
        \vtable = \methods()
        \method = *object
        ProcedureReturn *object
      EndIf
      FreeStructure(*object)
    EndIf
    ProcedureReturn #Null
  EndWith
EndProcedure

;----------------------------------------- EXAMPLE

Procedure.i Main()
  Protected.OBJECT_BALL *ball
  *ball = ballObject()
  Debug *ball
  *ball\method\Add(100)
  Debug *ball\x
  Debug *ball\y
  *ball\method\Sub(50)
  Debug *ball\x
  Debug *ball\y
  *ball\method\Rename("Hello World!")
  Debug *ball\name
  *ball\method\Release()
  ProcedureReturn #Null
EndProcedure

End Main()
Anyway this is just one example there are many different ways to do this.
I hope this helps.
ShadowStorm
Enthusiast
Enthusiast
Posts: 303
Joined: Tue Feb 14, 2017 12:07 pm

Re: A virtual object manager code

Post by ShadowStorm »

Hi Mijikai,

Thank you so much for sharing this code with me—I truly appreciate it, and it will definitely serve as a helpful example. :)
That said, I much prefer my approach because *MyObject is structured in a way that only lists two main things: Methods and Properties .

Methods contains all the functions,
Properties contains all the values, such as X, Y, Name, etc.
I really value this structure. While my code might not be the most optimized or technically perfect,
it’s the one that lets me achieve exactly what I wanted, with the syntax and functionality I was aiming for.
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
ShadowStorm
Enthusiast
Enthusiast
Posts: 303
Joined: Tue Feb 14, 2017 12:07 pm

Re: A virtual object manager code

Post by ShadowStorm »

Mindphazer wrote: Fri Feb 21, 2025 11:43 am Maybe you should start learning the basics of coding by trying to program something simple, like Tetris for example, before touching on concepts you don't understand.
If the monkeys that we are (speaking figuratively) had never tried to do something we didn't understand, we would still be in the age of caves and would have never discovered fire! Trying is learning, whether it's positive (success) or negative (failure) ! :wink:
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
SMaag
Enthusiast
Enthusiast
Posts: 302
Joined: Sat Jan 14, 2023 6:55 pm
Location: Bavaria/Germany

Re: A virtual object manager code

Post by SMaag »

Honestly, I never really understood how interfaces work
I try to bring light to the dark

An Interface is like the name says: an Interface to the Pcrocedures of an Object

Interface IfcMyObj
Move()
Draw()

End Interfache

First this is abstract or virtual. Just Names without any function.

Later you have to bind this Interface Procedures to a real procedure.

(!Pseudocode - not working!)

Code: Select all


Structure ObjThis
 *vTable
 ; Object Variables
EndStructure

Procedure New()
 Protected *obj
 *obj = AllocateStructure(ObjThis)
 ProcedureReturn *obj
EndProcedure

Procedure MoveObj(*This.ObjThis, dX, dY)
EndProcedure

Procedure DrawObj(*This.ObjThis)
EndProcedure

; Now you can call the Methodes directly with the Procedurename

define *ObjBall.ObjThis
*ObjBall = New()
MoveObj(*ObjBall, 10, 10)
Draw(*ObjBall)


; the other way is to call functions over the Interface
; for this youe have to create a pointer of the Inteface, not directly the ObjThis Structure

Define *ObjBall.IfcMyObj
*ObjBall = New()
*ObjBall\Move(10,20)
*ObjBall\Draw()

; A call over the Interface do not need the Pointer *This.
The compiler adds the *This as first parameter automatically!
For this the Pointer to the virtual Address Table must be the first variable in the This-Structure

The Interface Function name can be different from the real Procedure Name.

If you want to change the real Draw() Procedure later (maybe during runtime), you can overwrite the Procedure-Pointer in the vTable
with an other Procedure. Maybe Procedure Draw2(*This.ObjThis).

ShadowStorm
Enthusiast
Enthusiast
Posts: 303
Joined: Tue Feb 14, 2017 12:07 pm

Re: A virtual object manager code

Post by ShadowStorm »

Thank you SMaag,

What do you think of my code? Is it correct? I need to know.
Did you understand what I wanted to do? I need help, thank you.

Yes ok thanks for the code, it helps me to understand more how it works, but the problem with the interface is that I can't do for example:

*MyObject\X = 45
ObjectX.i = *MyObject\X

In fact, I can only use this kind of thing:

*MyObject\SetX(45)
ObjectX.i = *MyObjectGet(X)
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
ShadowStorm
Enthusiast
Enthusiast
Posts: 303
Joined: Tue Feb 14, 2017 12:07 pm

Re: A virtual object manager code

Post by ShadowStorm »

Okay, I’m not far from the goal. I tried to modify it myself using an interface, and it seemed
to work until I added a procedure: DeleteObject()

Which:

1- Isn’t even referenced in the object’s methods, and I don’t get why, by the way!
2- There’s a problem with the DeleteObject() procedure—it’s failing!

There also seems to be a problem in the NewObject() procedure.
Here: *Object\Methods = *Object ; Error Here!

I’m trying as hard as I can, but it’s tough.

Code: Select all


; Code créer par Dieppedalle David avec l'aide de l'IA, le 22/02/2025.
; Code created by Dieppedalle David with the help of AI, on 22/02/2025.

; ======================================================
; Structure des propriétés de l'Objet.
; Structure of the Object's properties.
; ======================================================
Structure ObjectProperties
  ID.i    ; L'ID de l'Objet              |   The ID of the Object.
  Name.s  ; Le nom de l'Objet.           |   The Name of the Object.
  X.i     ; La coordonnée ou valeur X.   |   The X coordinate or value.
  Y.i     ; La coordonnée ou valeur Y.   |   The Y coordinate or value.
EndStructure

; ======================================================
; Interface pour les méthodes de l'Objet.
; Interface for Object methods.
; ======================================================
Interface ObjectMethods ; Les Noms des procédures doivent être identiques à ceux du code, avec les mêmes types et les mêmes paramètres.
                        ; The names of the procedures must be identical to those in the code, with the same types and the same parameters.
  Abc123.i()
  Abc246.i()
  AbcXY.i()
  AbcStr.s()
  AbcBox.s(Title.s, Message.s)
  DeleteObject.b()
  
EndInterface

; ======================================================
; Structure principale de l'Objet.
; Main Object structure.
; ======================================================
Structure StructureObject
  *VirtualTableObject           ; Pointeur (*VirtualTableObject) sans type, qui pointe vers l'adresse des procedures.      |   Pointer (*VirtualTableObject) without type, which points to the address of the procedures.
  *Properties.ObjectProperties  ; Pointeur (*Properties) de type ObjectProperties qui pointe vers les propriétés (état).   |   Pointer (*Properties) of type ObjectProperties that points to properties (state).
  *Methods.ObjectMethods        ; Pointeur (*Methods) de type ObjectMethods qui pointe vers les méthodes (comportement).   |   Pointer (*Methods) of type ObjectMethods that points to methods (behavior).
EndStructure

Global NextObjectID.i = 1

; ======================================================
; Des procédures quelconque.
; Any procedures.
; ======================================================
Procedure.i Abc123(*Object.StructureObject)
  ProcedureReturn 123  ; Retourne la valeur entière 123.   |   Returns the integer value 123.
EndProcedure

Procedure.i Abc246(*Object.StructureObject)
  ProcedureReturn 246  ; Retourne la valeur entière 246.   |   Returns the integer value 246.
EndProcedure

Procedure.i AbcXY(*Object.StructureObject)
  ; Si l'Objet est valide.   |    If the Object is valid.
  If *Object
    ProcedureReturn *Object\Properties\X + *Object\Properties\Y
  Else
    Debug "Error: Object Or properties Not initialized."
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure.s AbcStr(*Object.StructureObject)
  ; Si l'Objet est valide.   |    If the Object is valid.
  If *Object
    ProcedureReturn "X + Y = " + Str(*Object\Properties\X + *Object\Properties\Y)
  Else
    Debug "Error: Object Or properties Not initialized."
    ProcedureReturn ""
  EndIf
EndProcedure

Procedure.s AbcBox(*Object.StructureObject, Title.s, Message.s)
  ; Affiche une boîte de message avec un titre et un message, puis retourne une chaîne de confirmation.
  ; Displays a message box with a title and message, then returns a confirmation string.
  MessageRequester(Title, Message)
  ProcedureReturn "Message displayed !"
EndProcedure

; ======================================================
; Détruit un objet et libère toute sa mémoire allouée.
; Destroys an Object and releases all its allocated memory.
; ======================================================
Procedure.b DeleteObject(*Object.StructureObject)
  
  ; Vérifie si l'objet est valide (non-nul)   |   Checks if Object is valid (non-null).
  If *Object
    
    If *Object\Properties 
      FreeStructure(*Object\Properties) ; Libère les propriétés   |   Frees properties.
    EndIf
    
    If *Object\Methods 
      FreeStructure(*Object\Methods) ; Libère les méthodes   |   Frees methods.
    EndIf
    
    FreeStructure(*Object) ; Libère l'objet principal   |   Frees main Object.
    
    ProcedureReturn 1
    
  Else
    Debug "Error: Object Not initialized: " + Str(*Object)
    ProcedureReturn 0
    
  EndIf
    
EndProcedure

; Création de la table virtuel, elle sert à stocker les adresses des procédures (Médhodes).
; Create virtual table, It is used to store procedure addresses (Medhodes).
DataSection
  VirtualTableObject:
  Data.i @Abc123()
  Data.i @Abc246()
  Data.i @AbcXY()
  Data.i @AbcStr()
  Data.i @AbcBox()
  Data.i @DeleteObject()
EndDataSection

; ======================================================
; Création d'un nouvel Objet.
; Creating a new Object.
; ======================================================
Procedure.i NewObject()
  
  ; Déclare un Pointeur (*Object) protégé de type StructureObject, qui prend comme valeur l'adresse de la structure "StructureObject".
  ; Ensuite, alloue un nouvel Objet de type Structure dynamique.
  ; 
  ; Declares a protected Pointer (*Object) of type StructureObject, which takes as a value the address of the "StructureObject" structure.
  ; Then, allocates a new Object of dynamic Structure type.
  Protected *Object.StructureObject = AllocateStructure(StructureObject)
  
  ; Si l'Objet *Object est bien initialisé.
  ; If the Object *Object is properly initialized.
  If *Object.StructureObject
    
    *Object\VirtualTableObject = ?VirtualTableObject
    
    ; Alloue un nouvel Objet "Properties" de type Structure dynamique qui prend comme valeur l'adresse de la structure "ObjectProperties".
    ; Allocates a new "Properties" Object of dynamic Structure type which takes as a value the address of the "ObjectProperties" structure.
    *Object\Properties = AllocateStructure(ObjectProperties)
    
    ; Si l'Objet "Properties" n'est pas initialisé.
    ; If the "Properties" Object is not initialized.
    If Not *Object\Properties
      Debug "Error: Unable To allocate Object properties."
      FreeStructure(*Object) ; Supprime l'Objet car il a pu être créé.   |   Remove the Object as it has been created.
      ProcedureReturn 0
    EndIf
    
    ; Affecte un Numéro d'identification à l'Objets en fonction de la variable NextObjectID.i.
    ; Assigns an identification number to the object according to the NextObjectID.i variable.
    *Object\Properties\ID = NextObjectID.i
    NextObjectID.i + 1
    
    ; Alloue un nouvel Objet "Methods" de type Structure dynamique qui prend comme valeur l'adresse de la structure "ObjectMethods".
    ; Allocates a new "Methods" Object of dynamic Structure type which takes as a value the address of the "ObjectMethods" structure.
    *Object\Methods = AllocateStructure(ObjectMethods)
    
    ; Si l'Objet "Methods" n'est pas initialisé.
    ; If the "Methods" Object is not initialized.
    If Not *Object\Methods
      Debug "Error: Unable To allocate Object methods."
      FreeStructure(*Object\Properties) ; Supprime les propriétés de l'Objet car elles ont pu être créées.   |   Remove the properties of the Object as they have been created.
      FreeStructure(*Object)            ; Supprime l'Objet car il a pu être créé.   |   Remove the Object as it has been created.
      ProcedureReturn 0
    EndIf
    
    ; Methods reçois la structure de l'Objet ou la Table Virtuel est stocké pour réfférencer les Procédures.
    ; Methods receives the structure of the Object where the Virtual Table is stored to refferentiate the Procedures.
    *Object\Methods = *Object ; Error Here !
    
    ; Retourne un pointeur qui est l'adresse mémoire de la structure "StructureObject".
    ; Returns a pointer which is the memory address of the "StructureObject" structure.
    ProcedureReturn *Object
    
  Else
    ProcedureReturn 0
    
  EndIf

EndProcedure


; --------------------------------

; Exemple d'utilisation:
; Example of use:

; ======================================================
; Création d'instance.
; Instance creation.
; ======================================================
*MyObject.StructureObject = NewObject() ; Crée un nouvel Objet.   |   Creates a new Object.

; Si l'Objet existe.   |   If the Object exists.
If *MyObject
  
Debug "Adress Object: " + Str(*MyObject)                       ; Affiche l'adresse mémoire de l'instance de l'Objet.         |   Displays the memory address of the Object instance.
Debug "Adress Object Properties: " + Str(*MyObject\Properties) ; Affiche l'adresse mémoire de la structure des propriétés.   |   Displays the memory address of the properties structure.
Debug "Adress Object Methods: " + Str(*MyObject\Methods)       ; Affiche l'adresse mémoire de la structure des méthodes.     |   Displays the memory address of the methods structure.
Debug "-----------------------------------"

; ======================================================
; Modification des propriétés.
; Modification of properties.
; ======================================================
*MyObject\Properties\Name = "Object #1"    ; Définit la propriété Name à "Object #1".    |   Sets Name property to "Object #1".
*MyObject\Properties\X = 15                ; Définit la propriété X à la valeur de 15.   |   Sets X property to 15.
*MyObject\Properties\Y = 25                ; Définit la propriété Y à la valeur de 25.   |   Sets Y property to 25.

Debug "Object ID: " + Str(*MyObject\Properties\ID)  ; Affiche la valeur de la propriété ID.                          |   Displays ID property value.
Debug "Object X: " + Str(*MyObject\Properties\X)    ; Affiche la valeur de la propriété X.                           |   Displays X property value.
Debug "Object Y: " + Str(*MyObject\Properties\Y)    ; Affiche la valeur de la propriété Y.                           |   Displays Y property value.
Debug "Object Name: " + *MyObject\Properties\Name   ; Affiche la valeur de la propriété Name sous forme de chaîne.   |   Displays Name property value as a string.
Debug "-----------------------------------"

Debug "Object Fonction Abc123: " + Str(*MyObject\Methods\Abc123())       ; Appelle et affiche le résultat de la méthode Abc123().   |    Calls and displays result from Abc123 method().
Debug "Object Fonction Abc246: " + Str(*MyObject\Methods\Abc246())       ; Appelle et affiche le résultat de la méthode Abc246().   |    Calls and displays result from Abc246 method().
Debug "Object Fonction AbcXY: " + Str(*MyObject\Methods\AbcXY())         ; Appelle et affiche le résultat de la méthode AbcXY().    |    Calls and displays result from AbcXY method().
Debug "Object Fonction AbcStr: " + *MyObject\Methods\AbcStr()            ; Appelle et affiche le résultat de la méthode AbcStr().   |    Calls and displays result from AbcStr method().

; Appel de la méthode avec paramètres:   -   Calling a method with parameters:
Debug "Result of AbcBox: " + *MyObject\Methods\AbcBox("Information", "Hello, world!")

*MyObject\Methods\DeleteObject() ; Non référencer mais est accepté ! - ; Not referenced but is accepted!

Else
  Debug "Erreur: Objet non initialisés: " + Str(*MyObject)
  
EndIf
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: A virtual object manager code

Post by Mijikai »

ShadowStorm wrote: Sat Feb 22, 2025 10:52 pm ...but the problem with the interface is that I can't do for example:

*MyObject\X = 45
ObjectX.i = *MyObject\X

In fact, I can only use this kind of thing:

*MyObject\SetX(45)
ObjectX.i = *MyObjectGet(X)
Why are you still saying this?
It is wrong, i even posted an example.
\method = *object

Ist all just memory!
ShadowStorm
Enthusiast
Enthusiast
Posts: 303
Joined: Tue Feb 14, 2017 12:07 pm

Re: A virtual object manager code

Post by ShadowStorm »

Mijikai wrote: Sun Feb 23, 2025 9:52 am
ShadowStorm wrote: Sat Feb 22, 2025 10:52 pm ...but the problem with the interface is that I can't do for example:

*MyObject\X = 45
ObjectX.i = *MyObject\X

In fact, I can only use this kind of thing:

*MyObject\SetX(45)
ObjectX.i = *MyObjectGet(X)
Why are you still saying this?
It is wrong, i even posted an example.
\method = *object

Ist all just memory!
Yes, with your way we can do it ok.
However, as I told you, it doesn't really suit me.
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: A virtual object manager code

Post by Mijikai »

ShadowStorm wrote: Sun Feb 23, 2025 1:25 am 2- There’s a problem with the DeleteObject() procedure—it’s failing!
You free *Object twice in DeleteObject() hence the error (hint: *Object\Methods = *Object).
ShadowStorm
Enthusiast
Enthusiast
Posts: 303
Joined: Tue Feb 14, 2017 12:07 pm

Re: A virtual object manager code

Post by ShadowStorm »

Oh yes, of course, I'm stupid since in NewObject() I do: *Object\Methods = *Object
Thank you Mijikai :wink:

But then, although everything works now, why when I delete the object at the end with: *MyObject\Methods\DeleteObject()
Do I still have memory spaces?

This shows the same memory addresses as if it wasn't deleted, why does it do that?

Code: Select all

Debug *MyObject
Debug *MyObject\Properties
Debug *MyObject\Methods
However, if I put things back in the object, for example:

Code: Select all

*MyObject\Properties\Name = "Object #1" ; Sets Name property to "Object #1".
*MyObject\Properties\X = 15 ; Sets X property to 15.
*MyObject\Properties\Y = 25 ; Sets Y property to 25.
The debug window closes unexpectedly, a crash.
So what? The addresses are still there but the house is empty, is that basically it?

It's really a mess to use all this!

Well, basically with this kind of thing: *MyObject\Properties\X = 15
Nothing is secure, it's way too prone to incomprehensible errors, it's driving me crazy! :evil:
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: A virtual object manager code

Post by mk-soft »

It is your task to stop using the object once you have deleted it (DeleteObject).
The memory area is then used for other tasks.

Mijikai has shown you how to use properties and methods with a pointer.
@Mijikai: Really great job ;)

So be more careful what you do ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
ShadowStorm
Enthusiast
Enthusiast
Posts: 303
Joined: Tue Feb 14, 2017 12:07 pm

Re: A virtual object manager code

Post by ShadowStorm »

So, what do you think of this approach ?

Code: Select all

; Code créer par Dieppedalle David avec l'aide de l'IA, le 22/02/2025.
; Code created by Dieppedalle David with the help of AI, on 22/02/2025.

; ======================================================
; Structure des propriétés de l'Objet.
; Structure of the Object's properties.
; ======================================================
Structure ObjectProperties
  ID.i    ; L'ID de l'Objet              |   The ID of the Object.
  Name.s  ; Le nom de l'Objet.           |   The Name of the Object.
  X.i     ; La coordonnée ou valeur X.   |   The X coordinate or value.
  Y.i     ; La coordonnée ou valeur Y.   |   The Y coordinate or value.
EndStructure

; ======================================================
; Interface pour les méthodes de l'Objet.
; Interface for Object methods.
; ======================================================
Interface ObjectMethods ; Les Noms des procédures doivent être identiques à ceux du code, avec les mêmes types et les mêmes paramètres.
                        ; The names of the procedures must be identical to those in the code, with the same types and the same parameters.
  Abc123.i()
  Abc246.i()
  AbcXY.i()
  AbcStr.s()
  AbcBox.s(Title.s, Message.s)
  
EndInterface

; ======================================================
; Structure principale de l'Objet.
; Main Object structure.
; ======================================================
Structure StructureObject
  *VirtualTableObject           ; Pointeur (*VirtualTableObject) sans type, qui pointe vers l'adresse des procedures.      |   Pointer (*VirtualTableObject) without type, which points to the address of the procedures.
  *Properties.ObjectProperties  ; Pointeur (*Properties) de type ObjectProperties qui pointe vers les propriétés (état).   |   Pointer (*Properties) of type ObjectProperties that points to properties (state).
  *Methods.ObjectMethods        ; Pointeur (*Methods) de type ObjectMethods qui pointe vers les méthodes (comportement).   |   Pointer (*Methods) of type ObjectMethods that points to methods (behavior).
EndStructure

Global NextObjectID.i = 1

; ======================================================
; Des procédures quelconque.
; Any procedures.
; ======================================================
Procedure.i Abc123(*Object.StructureObject)
  ProcedureReturn 123  ; Retourne la valeur entière 123.   |   Returns the integer value 123.
EndProcedure

Procedure.i Abc246(*Object.StructureObject)
  ProcedureReturn 246  ; Retourne la valeur entière 246.   |   Returns the integer value 246.
EndProcedure

Procedure.i AbcXY(*Object.StructureObject)
  ; Si l'Objet est valide.   |    If the Object is valid.
  If *Object
    ProcedureReturn *Object\Properties\X + *Object\Properties\Y
  Else
    Debug "Error: Object Or properties Not initialized."
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure.s AbcStr(*Object.StructureObject)
  ; Si l'Objet est valide.   |    If the Object is valid.
  If *Object
    ProcedureReturn "X + Y = " + Str(*Object\Properties\X + *Object\Properties\Y)
  Else
    Debug "Error: Object Or properties Not initialized."
    ProcedureReturn ""
  EndIf
EndProcedure

Procedure.s AbcBox(*Object.StructureObject, Title.s, Message.s)
  ; Affiche une boîte de message avec un titre et un message, puis retourne une chaîne de confirmation.
  ; Displays a message box with a title and message, then returns a confirmation string.
  MessageRequester(Title, Message)
  ProcedureReturn "Message displayed !"
EndProcedure

; Création de la table virtuel, elle sert à stocker les adresses des procédures (Médhodes).
; Create virtual table, It is used to store procedure addresses (Medhodes).
DataSection
  VirtualTableObject:
  Data.i @Abc123()
  Data.i @Abc246()
  Data.i @AbcXY()
  Data.i @AbcStr()
  Data.i @AbcBox()
EndDataSection

; ======================================================
; Création d'un nouvel Objet.
; Creating a new Object.
; ======================================================
Procedure.i NewObject()
  
  ; Déclare un Pointeur (*Object) protégé de type StructureObject, qui prend comme valeur l'adresse de la structure "StructureObject".
  ; Ensuite, alloue un nouvel Objet de type Structure dynamique.
  ; 
  ; Declares a protected Pointer (*Object) of type StructureObject, which takes as a value the address of the "StructureObject" structure.
  ; Then, allocates a new Object of dynamic Structure type.
  Protected *Object.StructureObject = AllocateStructure(StructureObject)
  
  ; Si l'Objet *Object est bien initialisé.
  ; If the Object *Object is properly initialized.
  If *Object.StructureObject
    
    *Object\VirtualTableObject = ?VirtualTableObject
    
    ; Alloue un nouvel Objet "Properties" de type Structure dynamique qui prend comme valeur l'adresse de la structure "ObjectProperties".
    ; Allocates a new "Properties" Object of dynamic Structure type which takes as a value the address of the "ObjectProperties" structure.
    *Object\Properties = AllocateStructure(ObjectProperties)
    
    ; Si l'Objet "Properties" n'est pas initialisé.
    ; If the "Properties" Object is not initialized.
    If Not *Object\Properties
      Debug "Error: Unable To allocate Object properties."
      FreeStructure(*Object) ; Supprime l'Objet car il a pu être créé.   |   Remove the Object as it has been created.
      ProcedureReturn 0
    EndIf
    
    ; Affecte un Numéro d'identification à l'Objets en fonction de la variable NextObjectID.i.
    ; Assigns an identification number to the object according to the NextObjectID.i variable.
    *Object\Properties\ID = NextObjectID.i
    NextObjectID.i + 1
    
    ; Alloue un nouvel Objet "Methods" de type Structure dynamique qui prend comme valeur l'adresse de la structure "ObjectMethods".
    ; Allocates a new "Methods" Object of dynamic Structure type which takes as a value the address of the "ObjectMethods" structure.
    *Object\Methods = AllocateStructure(ObjectMethods)
    
    ; Si l'Objet "Methods" n'est pas initialisé.
    ; If the "Methods" Object is not initialized.
    If Not *Object\Methods
      Debug "Error: Unable To allocate Object methods."
      FreeStructure(*Object\Properties) ; Supprime les propriétés de l'Objet car elles ont pu être créées.   |   Remove the properties of the Object as they have been created.
      FreeStructure(*Object)            ; Supprime l'Objet car il a pu être créé.   |   Remove the Object as it has been created.
      ProcedureReturn 0
    EndIf
    
    ; Methods reçois la structure de l'Objet ou la Table Virtuel est stocké pour réfférencer les Procédures.
    ; Methods receives the structure of the Object where the Virtual Table is stored to refferentiate the Procedures.
    *Object\Methods = *Object 
    
    ; Retourne un pointeur qui est l'adresse mémoire de la structure "StructureObject".
    ; Returns a pointer which is the memory address of the "StructureObject" structure.
    ProcedureReturn *Object
    
  Else
    ProcedureReturn 0
    
  EndIf
  
EndProcedure


; ======================================================
; Détruit un objet et libère toute sa mémoire allouée.
; Destroys an Object and releases all its allocated memory.
; ======================================================
Procedure.b DeleteObject(*Object.StructureObject)
  
  ; Vérifie si l'objet est valide (non-nul)   |   Checks if Object is valid (non-null).
  If *Object.StructureObject
    
    If *Object\Properties 
      
      FreeStructure(*Object\Properties) ; Libère les propriétés   |   Frees properties.
      *Object\Properties = 0
      
      If *Object\Methods 
        
        FreeStructure(*Object\Methods) ; Libère les méthodes   |   Frees methods.
        *Object\Methods = 0
        
        *Object.StructureObject = 0
        ProcedureReturn 1
        
      EndIf
      
    EndIf
    
    ProcedureReturn 0
    
  Else
    Debug "Error: Object Not initialized: " + Str(*Object)
    ProcedureReturn 0
    
  EndIf
  
EndProcedure

; --------------------------------

; Exemple d'utilisation:
; Example of use:

; ======================================================
; Création d'instance.
; Instance creation.
; ======================================================
*MyObject.StructureObject = NewObject() ; Crée un nouvel Objet.   |   Creates a new Object.

; Si l'Objet existe.   |   If the Object exists.
If *MyObject
  
  Debug "Adress Object: " + Str(*MyObject)                       ; Affiche l'adresse mémoire de l'instance de l'Objet.         |   Displays the memory address of the Object instance.
  Debug "Adress Object Properties: " + Str(*MyObject\Properties) ; Affiche l'adresse mémoire de la structure des propriétés.   |   Displays the memory address of the properties structure.
  Debug "Adress Object Methods: " + Str(*MyObject\Methods)       ; Affiche l'adresse mémoire de la structure des méthodes.     |   Displays the memory address of the methods structure.
  Debug "-----------------------------------"
  
  ; ======================================================
  ; Modification des propriétés.
  ; Modification of properties.
  ; ======================================================
  *MyObject\Properties\Name = "Object #1"    ; Définit la propriété Name à "Object #1".    |   Sets Name property to "Object #1".
  *MyObject\Properties\X = 15                ; Définit la propriété X à la valeur de 15.   |   Sets X property to 15.
  *MyObject\Properties\Y = 25                ; Définit la propriété Y à la valeur de 25.   |   Sets Y property to 25.
  
  Debug "Object ID: " + Str(*MyObject\Properties\ID)  ; Affiche la valeur de la propriété ID.                          |   Displays ID property value.
  Debug "Object X: " + Str(*MyObject\Properties\X)    ; Affiche la valeur de la propriété X.                           |   Displays X property value.
  Debug "Object Y: " + Str(*MyObject\Properties\Y)    ; Affiche la valeur de la propriété Y.                           |   Displays Y property value.
  Debug "Object Name: " + *MyObject\Properties\Name   ; Affiche la valeur de la propriété Name sous forme de chaîne.   |   Displays Name property value as a string.
  Debug "-----------------------------------"
  
  Debug "Object Fonction Abc123: " + Str(*MyObject\Methods\Abc123())       ; Appelle et affiche le résultat de la méthode Abc123().   |    Calls and displays result from Abc123 method().
  Debug "Object Fonction Abc246: " + Str(*MyObject\Methods\Abc246())       ; Appelle et affiche le résultat de la méthode Abc246().   |    Calls and displays result from Abc246 method().
  Debug "Object Fonction AbcXY: " + Str(*MyObject\Methods\AbcXY())         ; Appelle et affiche le résultat de la méthode AbcXY().    |    Calls and displays result from AbcXY method().
  Debug "Object Fonction AbcStr: " + *MyObject\Methods\AbcStr()            ; Appelle et affiche le résultat de la méthode AbcStr().   |    Calls and displays result from AbcStr method().
  
  ; Appel de la méthode avec paramètres:   -   Calling a method with parameters:
  Debug "Result of AbcBox: " + *MyObject\Methods\AbcBox("Information", "Hello, world!")
  
  ; Pour supprimer un objet, suivez scrupuleusement cette méthode !
  ; To delete an object, follow this method carefully !
  If DeleteObject(*MyObject)
    *MyObject = #NUL
    Debug "Object deleted !" 
  EndIf
  
Else
  Debug "Error: Uninitialized objects: " + Str(*MyObject)
  
EndIf
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
Post Reply