NeoPlugins - Invalid Object Instance by ID in the npCiph plugin


Nelson Hernánez

Hello,

I'm getting a lot of 'Invalid Object Instance by ID "%"'

What is it that it means exactly? and also, the instance ID can that be a random number?

Regards.


decsoft

Hello Nelson,

Fortunatelly this kind of error is a plugin catched error, an "action argument error" to be exactly. If you try with the plugin samples, for example, you never get an error like that, or I need to fix that to work properly. But this is not an unexpected error, just an expected error when we do not provide the right argument to some plugin action.

Well. As you know, some NeoPlugins allow us to create various instances of a certain object, for example, we can create various "Ciphers" using the npCiphCreate action. Ok. Since we can create various objects, when we want to operate over such objects, we need some way in order to identify particular objects. And for that reason we have the "ID" argument in the right plugins actions.

The "ID" argument is not a random number, but it's the number returned in the result variable of the "create" actions. This mean the "npCiphCreate" action return in their result variable the "ID" of the object being created. Then, we can use another plugin actions like npCiphEncryptStr (to encrypt strings in this case) indicating the object "ID" that we want to use.

In few words this all stuff is useful because we can use more than one instance of an object. And this is useful for various reasons, for example, we can share "events" actions code between objects, because "events" actions provide the "ID" of the object that launch the "event" subroutine. You can maintain available all the objects until you need it, and, optionally, use the "destroy" actions (provide the "ID" of an object) in order to destroy it and free from the memory.

A good approach is to use the "create" actions providing a descriptive identifier for the "ID" variable. For example, take a look at the bellow code: we create a cipher object, use it to encrypt an string, and then destroy it. Note how we name the object "ID" variable with a descriptive name, which allow us to identify what this variable is and for what we can use.

Hope this explanation help you in some manner. What I suggest is to familiarize yourself with the plugin samples. If you have any other question don't hesitate to post it here Nelson.



Nelson Hernánez

This is exactly what I was looking for... Yeah, I understand now, I was unclear in the way Instances work when you are going to use more than one, so far I just used one at the time, for example while working with npTalk.

Great explanation, thanks for your time. And sorry about the title I never complete it but yeah it was supposed to be around the lines its right now. =)


decsoft

Hello,

You're welcome Nelson. ;)


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.