Ptr Dataype cannot get Address Of Class Method?

This is what i was trying to do , to get the address of a class Method called myClassMethod

The class name is HulaHooClass

But i got this error , that the method doesn’t exist in class.

I also tried to return the address of the class as an integer value Return myPtr.Integer

With addressOf you need to assign to a delegate type variable.

well if you see my above picture there are two methods i created on the left panel named"Another Method" and “Test Method”,

If i replace myPtr = AddressOf hulaObj.myClassMethod

with

myPtr = AddressOf AnotherMethod

It works absolutely fine also in the documentation it says AddressOf can be assigned to Ptr datatype

The code you refer to is not doing what you are doing…

  • You can’t get the address of an instance method until you create an instance of the class

  • You need to assign it to a delegate if you wish to invoke it

1 Like

Ok Sir. Thank you . I understood :slight_smile:

I have one more question

As you can see there are several properties inside the Ptr Dataype , as from what i can guess ,… most of those properties will generate the address of location of a method in the memory or the address of location of memoryblock

My question is that is there any use to convert these address to say Single , Integer , Double ?? I mean what is the practical purpose of those properties

No. An address for a method is just some pointer and if you’d read the bytes there, you read whatever machine code is there.

1 Like

No. They read the memory at the address pointed to by the Ptr and return its value in the given format. None of that is appropriate for the address of a method.

1 Like

Yes :slight_smile: . It returns the address pointed by the pointer.

But i just wanna know what is the use of that address being converted in Single , Double , Integer even Boolean . As what pointer properties can do ,

I know the address is some machine code , but just wanna know why convert it to Single , Double ,Integer

Yes Sir you are right. I wanna just know what can i do with that machine code afterwards? Like about all those properties that are available. What are their uses?

These methods will be useful if you are using declares. Sometimes depending on the call, you will get a memory pointer instead of a return value and you are expected to get the value yourself.

1 Like

Yes i have to read about declares now, Thanks for clarifying things up a little bit :slight_smile:

I was being stupid the error was that i wrote the class method name wrong as

myClassMethod

instead of

myClassFunction

Hence the error :man_facepalming:

Also i learnt that pointer variables properties can be used when we are using Declares

Again, those functions do not return the address. The Ptr is the address; those functions return the data stored at that address. Not useful for functions, but quite useful for declares and accessing data in a MemoryBlock.

1 Like