Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8301073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:48:39+00:00 2026-06-08T16:48:39+00:00

I want to process an array from java script. (i.e., from html page to

  • 0

I want to process an array from java script.
(i.e., from html page to plugin code. I want to get the values from html code to variables in plugin so that I can modify them within code and process for some other purpose.).

But I am facing a problem in this. I know that internally an array will be processed as NPObject. I am trying to retrieve the length of the array and the elements of the array from this NPObject but the array length returned is zero even thought the array is of non-zero length.

Any suggestions are Welcome….

I have a html page which has an array
The HTML page is as follows:

<html>
<script type="text/javascript">
var arrayData = [9,1,2,3,4,5,6,7,8,9];
function handleEvent(e) {
    if (e.keyCode == 55) {
        document.getElementById('arrayint_ele_disp').innerHTML = arrayData;
        process_intarray(arrayData);
    }
}
function  process_intarray(arrayData){
    obj = document.getElementById("Obj");
    if(obj){
        obj.process_array_intval(arrayData); 
    }
}
</script>

<body onload="init()" onkeydown="handleEvent(event)">
<div id ="arrayint_ele_disp" style="position:absolute;left:100px;top:250px"> 
ARRAY_INT VAL </div>
</body>

</html>

My plugin code for processing array elements is as folows:

bool ScriptableObject::process_intarray(const NPVariant* args, uint32_t 
     argCount, NPVariant* result)
{

    //Get the Length of the array
    //NPObject *inobject = args[0].value.objectValue;
    NPObject *inobject = args->value.objectValue;

    bool bRetval = false;
    NPVariant npvlength;
    //NPIdentifier id;

    bRetval = 
   NPN_GetProperty(m_npp,inobject,NPN_GetStringIdentifier("length"),&npvlength);
    printf("\n NPN_GetProperty length type %d value : %d\n"
  ,npvlength.type,npvlength.value.intValue);

    //Get the array elements
    int i = 0;
    for(i = 0; i < npvlength.value.intValue; i++)
    {
        NPVariant CurVal;
        NPN_GetProperty(m_npp,inobject,NPN_GetIntIdentifier(i),&CurVal);
        m_prop_array_intval[i] = CurVal.value.intValue;
    }
    return true;

}

Here in this function NPN_GetProperty(m_npp,inobject,NPN_GetStringIdentifier(“length”),&npvlength); is returning a true.

But on checking the length of npvlength its giving 0 and its type as NPVariantType_Double.
I am unable to understand why..

Any suggestions are welcome…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T16:48:41+00:00Added an answer on June 8, 2026 at 4:48 pm

    You shouldn’t rely on numbers being one of Int32 or Double. If the numbers type is double use value.doubleValue to get the length, otherwise you will get unexpected values (due to value being a union and hence doubleValue and intValue referencing the same memory).
    Ideally write yourself helper functions for the conversions so you don’t have to worry about the specific NPVariantType everywhere.

    Also you should cache the NPIdentifiers: In the worst case NPN_Get*Identifier() could result in a full interprocess-roundtrip from the plugin process into the browser process and back, in addition to the expense of string comparisons/hashing/…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of values that is passed to my function from a
I want to process every element of a for-loop. Taking this code, why is
I have the following XML and I want to process it so that I
I have a c++ process, I want that process should always remain on foreground,
I declare an NSArray in my code then building the array from another array.
I need to extract a value from a process array to myArray: File: MyClass.vb
I need to read a bi-dimensional array and convert the values into an HTML
I have a SQL database that contains a field. I can get all of
I want to itterate over a array of key,value pairs from post parameters: Parameters:
I have some inputs that I need to process from a form. The #

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.