#1 2015-04-22 21:33:23

Nelson
Member
Registered: 2015-04-21
Posts: 21

NeoPlugins - Invalid Object Instance by ID in the npCiph plugin

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.

Offline

#2 2015-04-22 22:30:09

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: NeoPlugins - Invalid Object Instance by ID in the npCiph plugin

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.

.Create our Cipher object (note the ID is stored in the "[CipherID]" variable)

npCiphCreate "[CipherID]"

.Use it to encrypt some string (note the use of "[CipherID]" as the ID of our object)

npCiphEncryptStr "[CipherID]" "[SelectedAlgorithm]" "[SourceString]" "[Password]" "[EncryptedText]"

.Destroy the object, if anymore is needed (using the "ID" variable as well)

npCiphDestroy "[CipherID]" "[Result]"

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.

Offline

#3 2015-04-23 13:20:32

Nelson
Member
Registered: 2015-04-21
Posts: 21

Re: NeoPlugins - Invalid Object Instance by ID in the npCiph plugin

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. smile

Offline

#4 2015-04-23 14:40:58

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: NeoPlugins - Invalid Object Instance by ID in the npCiph plugin

Hello,

You're welcome Nelson. wink

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.