Arrays in Eventhandling function

Hi
I just created one flex application using <mx:http>  tag with resultHandler event  function
<mx:HTTPService id="employees" url =" c:/sai/one.xml" result="resultHandler(event)"  fault="httpFaultHandler(event)"
resultFormat="e4x"
/>
private function resultHandler(event:ResultEvent):void
   var  custresultdata:XMLList=new XMLList();
   var labelsArray:Array /* of String */ = new Array(custresultdata.length);
          var index : int = 0;
          var i:int=0;
          custresultdata=event.result.customer; 
   for each (var labelText:String in custresultdata)
                         labelsArray[index++] = labelText;
                    aa=labelsArray;
i=aa.length;
Alert.show(p.toString());/       *here it  showing the length is 5 */
my problem is the function returning data to array named as aa,but  when i try to assigning the same array aa to another array hh out side of this function,the array hh is not contaning data
public function init():void
   employees.send();
   hh=aa;
   p=hh.length;
   Alert.show(p.toString());  /*here it  showing the length is 0 */
here i am posting the entire code of my application,
how can i slove this problem
thanks in advance
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
initialize="init()">
<mx:Script>
<![CDATA[
  import mx.collections.XMLListCollection;
  import mx.controls.dataGridClasses.DataGridColumn;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
[Bindable]
public var aa:Array = new Array();
public var hh:Array=new Array();
public var p:int=0;
   [Bindable]
  private var empdata:XMLListCollection=new XMLListCollection;
  public function init():void
   employees.send();
   hh=aa;
   p=hh.length;
   Alert.show(p.toString());
  private function resultHandler(event:ResultEvent):void
   var  custresultdata:XMLList=new XMLList();
   var labelsArray:Array /* of String */ = new Array(custresultdata.length);
          var index : int = 0;
          var i:int=0;
          custresultdata=event.result.customer; 
   for each (var labelText:String in custresultdata)
                         labelsArray[index++] = labelText;
                    aa=labelsArray;
   private function httpFaultHandler(event:FaultEvent):void
    Alert.show("there was a prolem");
    ]]>
</mx:Script>
<mx:HTTPService id="employees" url =" c:/sai/one.xml" result="resultHandler(event)"  fault="httpFaultHandler(event)"
resultFormat="e4x"
/>
</mx:WindowedApplication>

Try this, way of intializing hh value. Because Flex follow asynchronous process of execution.
public function init():void
   employees.send(); 
private function resultHandler(event:ResultEvent):void
   var  custresultdata:XMLList=new XMLList();
   var labelsArray:Array /* of String */ = new Array(custresultdata.length);
          var index : int = 0;
          var i:int=0;
          custresultdata=event.result.customer; 
   for each (var labelText:String in custresultdata)
                         labelsArray[index++] = labelText;
                    aa=labelsArray;
hh=aa;
p=hh.length;
Alert.show(p.toString());

Similar Messages

  • How to pass an array to a function from a SELECT statement

    Hi all. I have a problem with passing an array to a function directly from a SELECT statement.
    Here is what I want. If I have a function
    function AAA(arrayVar <ArrayType>) return number;
    I want to be able to call this function this way
    select AAA((2,3,4))
    from dual
    or this way
    select AAA((10,12))
    from dual
    In other words I want to be able to pass an arbitrary number of numbers to the function. And I want this to work in a SELECT statement.
    Does anyone have any ideas how to implement this? What <ArrayType> should I use?(I've read about VARRAY, nested tables in the Oracle documentation but as far as I've understood these array types are meant to be used within PL/SQL blocks).
    I found only this http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:208012348074 through Google but it didn't help me.
    Thank you in advance.

    > What <ArrayType> should I use?
    SQL data types - as 3360 showed above. You cannot use PL/SQL structures and user types in the SQL Engine.
    You can however use all SQL structures and types in PL/SQL.
    Arrays in SQL is created as collection type - basic o-o. The collection type (or class) serve as a container for instantiated objects or scalar type.
    This is covered in detail in [url http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14260/toc.htm]
    Oracle® Database Application Developer's Guide - Object-Relational Features

  • Logic of array and plotting functions?

    Hi,
    I started to build versatile acquisition programn with labview (with NI cards it seemed to be the best option) and it took quite an effort to adjust the way of thinking while shifting from other programming environments. I start to see the logic behind the labview but I have serious difficulties on figuring out how the labview's array and plotting functions work. Here's a simple example for replacing array subset and plotting it, which just doesn't work as i'd expect. I thought this would first initialize 10 rows, 1000 cols matrix of which the certain row would be replaced (zero padding when new row is longer than the original). The resulting matrix would then be displayed each row having its own windows in the stacked plot. It seems to do something totally different...
    Attachments:
    koe4.vi ‏303 KB

    As you noticed, "Replace Array Subset" can only replace array elements that exist. If it's not there, there's nothing to replace.
    What you'll need to do is make the array larger by using the "Insert into Array" function. Use this function cautiously though. It requires LabVIEW to dynamically reallocate memory while the program is running, and takes time. If you only do the 'Insert' when needed, you should be OK.
    Use the "Array Size" function to get the size of the array to be inserted, then you can choose between the ‘Insert’ or ‘Replace’ functions.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

  • Control array of callback functions?

    Apologies for my basic question.
    I am experimenting with control arrays and so far am able to collect data in string controls that are inside control arrays.  Works well.  Naturally, none of these controls need callback functions.
    Now I have need of some momentary command buttons in a control array as well.  So my question is, should I use a single callback function for all of the button controls in that single array?  And if so, how do I go about identifying which element in the control array called the function?  From reading on the forums, it seems as if use of the callback data parameter might get me there.
    Just wanted to ask before I get off track.  Thanks!
    Solved!
    Go to Solution.

    Yes, callbackData can be of help in such a situation, but if you can limit to switch on array index to discriminate what to do your button callback could be something on this line:
    int CVICALLBACK BtnAttayCallback (int panel, int control, int event,
    void *callbackData, int eventData1, int eventData2)
    int handle, index;
    switch (event) {
    case EVENT_COMMIT:
    handle = GetCtrlArrayFromResourceID (panel, control);
    GetCtrlArrayIndex (handle, panel, control, &index);
    switch (index) {
    // Your code here
    return 0;
     (No CVI install here so I cannot test it: double check the code but it should reasonably work)
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Insert values in an array (within a function)

    Hello,
    I can't seem to get values insert in an array. I know it
    works outsite the function but
    when using variables in a function and trying to insert this
    in an array it does not work.
    The values are empty.
    But if you uncomment the line someArray.push(a0,a1,a2) and
    uncommend the for loop it works.
    In actionscript 2.0 i could use eval ..but in actionscript
    3.0 you have to use this to convert a string to a value.
    Does anyone see, what i am doing wrong?
    function doSomething() {
    var a0:String = "hello";
    var a1:String = "why doesn't it";
    var a2:String = "work!";
    var someArray:Array = new Array();
    //someArray.push(a0,a1,a2);
    for (var i:uint =0; i<=3; i++) {
    someArray.push(this["a"+i]);
    trace(someArray);
    doSomething();

    In this case, the problem arises from a scope issue. The vars
    are defined within the function so they are visible only within the
    function. When you use "this" you are referencing the object that
    contains the function, which cannot see those vars (they do not
    exist for "this", only for the function). It works if you go this
    way...
    var a0:String = "hello";
    var a1:String = "why doesn't it";
    var a2:String = "work!";
    function doSomething() {
    var someArray:Array = new Array();
    for (var i:uint=0; i<3; i++) {
    someArray.push(this["a"+i]);
    trace(someArray);
    doSomething();
    The other line: someArray.push(a0,a1,a2);
    does work because it is within the function and can see the
    vars.

  • Array argument in function call from 3DAnnots to host

    Hi,
    with Acrobat I am trying this: host.my_func(Array) from within an Annots3D script.
    my_func is a pdf document function.
    This is what I get in my_func:
    1) console.println (Array): Arr_Element_1,Arr_Element2
    2) for..in, console.println (Array[i]):
    [object ScriptProxy]
    [object ScriptProxy]
    Array[i] is undefined
    (actually I am passing a 2-element array).
    So, the only way to work on Array in document my_func is to stringify Array (Array.toString()) and recreate an array. This may be a feasible way with litteral arrays but not as praticable with objects as you can image.
    Have you got any workarounds?
    Thanks

    Global access to objects is indeed part of the sandboxing restriction. What you're trying to do is not transfer an object reference between scripts as you would when web pages interact with one another, but between interpreters. Allowing that would be a huge problem, as you could inject methods as well as properties.

  • Using an array with a function

    Hi all,
    I'm working on an order form where users choose a course they want to order from a drop-down list, then enter the number of licences they require. I'm trying to build in a 'volume-based' discount model the form, and would like to ask for some help in using arrays and how to use them in functions. I'm very new to this, and would appreciate any help you can provide!
    Basically, we have 3 products that can be ordered on the same form, and all have different discount models (i.e you get a different % discount for different numbers of licences ordered, depending on the course chosen). I'm storing the discount models in 3 separate two-dimensional arrays, then want to create a function that takes two parameters - the name of the array and the volume that the customer orders - to calculate the appropriate discount. I would then call the function on the change events of either the drop down list or the licence qty field.
    Below is my attempt so far (only one array here, but the others are the same syntax). This is held in a script object called DiscountCalculator in the form. The idea of the function is to loop through the array until it finds the correct course, then loop through the value field until it finds the correct discount:
    //code holds the discount model for each course in a 2 dimensional array. A new array is needed for each course.
    //Course 1
    var
    Course1Array = new Array(3);
    Course1Array[0]
    = new Array(2);Course1Array[0][0]
    = "49";  //'breakpoint' at which discount is appliedCourse1Array[0][1]
    = "0";   //discount % given for this no of licences
    Course1Array[1]
    = new Array(2);Course1Array[1][0]
    = "99";Course1Array[1][1]
    = "20";
    Course1Array[2]
    = new Array(2);Course1Array[2][0]
    = "199";Course1Array[2][1]
    = "25";
    function
    CalculateDiscount(CourseArray, value){
    for
    (var i = 0; i <= CourseArray.length; i++){
    if
    (value <= CourseArray[i][0]){
    return CourseArray[i][1]}
    I can use a MessageBox to return a specified value from the array on the click event, so that seems to be set up correctly. But when I try to tcall the function in the change event of the drop-down list on the form:
    DiscountCalculator.CalculateDiscount(fldCourse.rawvalue, fldqty.rawvalue)
    It doesn't work, usually complaining that "Course1Array is not defined". I think it must be some kind of syntax error, but I have trawled the internet looking for some examples and can't find any.
    I'd be grateful for any assistance.
    Thanks
    Matt

    It might be easy to solve these issues if you post your form.
    Post your form if it doesn't contain any confidential information.
    Nith

  • Calling the next number in an array through a function?

    ow do I request the next number in an array?
    For example - currently being used for a loop:
    for (i=0; i = levelSettings[0]; i++)
    But when the function (named - NextLevel() ) is called I would like that loop to call the next number in that array.
    Example:
    (i=0; i = levelSettings[1]; i++) //Not the change in the levelSettings[x]
    I would like this to work for all subsequent numbers in that particular array - so it can continue through to levelSettings[10] and so on.
    Cheers!

    in the outter for-loop, k is varying from 0 to the last index in levelSettings.
    in the inner for-loop i varies from 0 to levelSettings[k].
    ie,
    0 to levelSettings[0]
    0 to levelSettings[1]
    0 to levelSettings[last_index]

  • Access Java Array in Javascript function

    Hi, could someone please help me, I have an array that gets populated in java code and I need to see it in a javascript function.
    Here's what I have so far:
    //In java class for AvgCostChart.jsp
    private String[] month;
    public String[] getMonth()
    {//code to populate
    return month;}
    Then in my javascript onLoad function I try to access it. I know how to access the values one at a time like this.
    var month1='#{AvgCostChart.month[0]}';
    But how do I pass this to a function.
    I tried assigning to to another array to loop through the values like this:
    var myArr = new Array();
    myArr'#{AvgCostChart.month}';
    alert (myArr[0]);
    But that does not work, any one done this before.
    I've also tried saving it in the session and then accessing it but can't get that to work either.
    Any help will be greatly appreciated.

    Hi,
    Please go through the following thread:
    http://swforum.sun.com/jive/thread.jspa?forumID=123&threadID=60147
    Hope this helps
    Cheers
    Girish

  • Passing a Variant array to ArrayToImage Function

    Hi,
    I need help passing a Variant array to the ArrayToImage function in the NI Vision library.
    I have no problems using the ImageToArray function - but when going back to the CWIMAQImage type the application throws an exception.
    Are there any code samples for doing this?
    Thanks!

    Hello,
    Thank you for posting to the NI forums! Try calling the ImageToArray function then immediately passing the resultant array back to ArrayToImage. That will determine whether the ArrayToImage function is causing the error, or the array that is passed into it. Can you post a small sample of how you call the ArrayToImage function and the errors that are thrown?
    Thanks,
    Maclean G.
    Applications Engineering
    National Instruments

  • Pass string array to Oracle function from Web page

    Hi. I need to pass a two-dimensional array of string values to an Oracle function from an ASP.NET page. Is there an efficient way to accomplish this? I'm thinking I'll have to create a long string with special delimiters,
    |12345^4.000|67890^3.670|.....
    I'd parse the string on Oracle and break it into its component parts. In this example, each "record" is separated by the bar "|" and each field is separated by the up arrow "^". So each record has two fields.
    Is this a good approach? Your input is much appreciated. Thanks.

    In PL/SQL, it is easy enough to define a record type with two attributes and declare a store procedure that takes in an array of those parameters. I know that from Java it is possible to create and pass in such an array. I would suspect that the same is possible from .Net but I am not a competent .Net developer.
    Justin

  • Array types in functions

    Hi,
    I have defined a type like
    CREATE TYPE TYPE1 AS OBJECT (
    NAME VARCHAR2(100),
    AGE NUMBER
    and i have created anothe arratype which is array of type TYPE1
    Now i need to write a function whcih takes this array as input and in this function i need to loop through the TYPE1 elements and get the name and age.
    Please give me the looping syntax.
    thanks,
    Kishore.

    SQL> CREATE TYPE TYPE1 AS OBJECT (
      2  NAME VARCHAR2(100),
      3  AGE NUMBER
      4  );
      5  /
    Type created.
    SQL> create or replace type type1_arr as varray(10) of type1;
      2  /
    Type created.
    SQL> create or replace procedure proc1 (p1 type1_arr) as
      2  begin
      3   for i in 1..p1.count loop
      4    dbms_output.put_line(p1(i).name||':'||to_char(p1(i).age));
      5   end loop;
      6  end;
      7  /
    Procedure created.
    SQL> set serverout on
    SQL> declare
      2   arr type1_arr := type1_arr(type1('a',1),type1('b',2));
      3  begin
      4   proc1(arr);
      5  end;
      6  /
    a:1
    b:2
    PL/SQL procedure successfully completed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Passing multidim array to c function

    Hi all,
    I am very new to JNI, so please excuse if asking something stupid. I want to pass amultidimensional array (double[][]) to a c++ function. The array holds a large matrix for a linear equation system, the c++ function is a solver.
    I can run "Hello World" using JNI, and I can pass a 1-dim double[] Array to a c++ function.
    If changing the native method argument from double[] to double[][], javah produces a c++ header file with jobjectArray as argument type. I don't understand, how to access the array within the c++ code.
    Can anyone give me a tip, how to do it? Most helpfull would be a c++ code line, that fetches an array...
    Thanks a lot,
    Clemente
    The generated header file:
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class Solver */
    #ifndef IncludedSolver
    #define IncludedSolver
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: Solver
    * Method: solve
    * Signature: ([[DI)[D
    JNIEXPORT jdoubleArray JNICALL Java_Solver_solve
    (JNIEnv *, jobject, jobjectArray, jint);
    #ifdef __cplusplus
    #endif
    #endif
    Edited by: Clemente on Oct 15, 2007 2:15 AM
    Edited by: Clemente on Oct 15, 2007 3:37 AM
    Edited by: Clemente on Oct 15, 2007 3:42 AM
    Edited by: Clemente on Oct 15, 2007 3:43 AM

    Finally, I figured to access all dimensions. For the archive and anyone with similar problems:
    Assumed, that the provided jobjectArray is called "array", means the method looks something like:
    JNIEXPORT jdoubleArray JNICALL Java_de_vonmusil_vs_wqn_solver_Solver_solve(JNIEnv *env, jobject ob, jstring path, jobjectArray array) { [...] }
    following snippet lists the first two rows of the array of doubles:
         int j;
         jdoubleArray darray = (jdoubleArray) env->GetObjectArrayElement(array, 0);
         jdouble* first_element = env->GetDoubleArrayElements(darray, NULL);
         for (j=0; j<env->GetArrayLength(darray); j++)
              std::cout << "->" << first_element[j] << std::endl;
         darray = (jdoubleArray) env->GetObjectArrayElement(array, 1);
         first_element = env->GetDoubleArrayElements(darray, NULL);
         for (j=0; j<env->GetArrayLength(darray); j++)
              std::cout << "->" << first_element[j] << std::endl;
    Besides all the casting things, it works this way: A double[][] array is an array (a) of arrays (b). One can get a b-array with env->GetObjectArrayEalement(array, 0);.
    env->GetDoubleArrayElements(darray, NULL); fetches a pointer to the first double value and using the pointerarithmetic pointer[], one can iterate over the whole array.
    Thank you for all your help,
    Clemente
    Edited by: Clemente on Oct 15, 2007 1:26 PM

  • How to pass jsp array to javascript function()

    function delete(var arr[][])
    out.print(arr[1][2]);
    <%String [][] arra=new String[1][2];
    %>
    <select name="" onClick="delete(<%=arra%>)">
    <option>fvfvfdfdfddffdd</option>
    </select>

    Thanks again for constant support .Now , here comes my real problem .
    I'm having a listbox . I need to find out how to get the values selected in a JSP variable .
    Like I'm having names of cities in listbox .When , I click on save button , i need the names of selected cities in JSP variable or an array .
    <html>
    <head>
    <script language="JavaScript">
         function show(acl)
              for(var i=0;i<4;i++)
                   if(acl.aclnames.options.selected)
                        // i don't know what to put here
              alert("in show");
    </script>
    </head>
    <body>
    <form name="acl" method="post">
    <select name="aclnames" multiple="true" size="3">
    <option>Ahmedabad</option>
    <option>Baroda</option>
    <option>Surat</option>
    <option>Rajkot</option>
    </select>
    <input type="button" name="save" value="Save" onClick="show(acl)">
    </form>
    </body>
    </html>

  • Passing array variables into functions (and why I'm hopeless at arrays)

    OK, I have spent a day on this now and have done some fairly
    extensive searching online. The problem is - I am hopeless with
    arrays (and probably just actionscript generally for that matter)
    I want to create an array of buttons, so I set up an array of
    actions, step through each item and then try to pass that array
    action into an onclick button for an attached button
    The problem I have is that the onclick function ALWAYS
    returns the last item in the array.
    Help!
    Code below:
    ----------------------------------------------------------------

    the reason for this, is that once the for loop executes, the
    'last' value is the only one remaining. what one needs to do here
    is 'store' the string in a newly created property on each button,
    like this:

Maybe you are looking for

  • When I mirror my late 2012 mac mini to my apple tv. I only see a black screen.  I have no problems if I use my mid 2012 MBPr

    When I try to mirror my late 2012 macmini to my apple tv. I only see a black screen.  I have no problems if I use my mid 2012 MBPr. The mac mini is still on mavericks at present any advice welcome please.  (There is no other monitor attached to the m

  • Vendor balaces

    hi all when i was seeing vendor balaces (s_alr_87012085) its not appearing the vendor name and vedor code where can i found out plz give suggstion urgent. Regards nasa

  • Robohelp X5 and structured authoring

    My office does not currently use structured authoring, but we are moving to it. Currently when I create webhelp using RoboHelp, I take advantage of the Create Drop-down Hotspot and Text to enter step-by- step procedures for screens that have multiple

  • [SOLVED] - Multi-App Dependencies

    I'm in an environment where we use Autonomy (or HP now) iManage. The clients all have FileSite, Email Management Module and another third-party application called NRL Translator. All three applications have dependencies FileSite requires Office Email

  • Fiel open dialog -properties

    Hi, i implemented a file open dialog using cl_gui_frontend_services (->file_open_dialog) and it works so far ok. But now i'd like to change the size of the file open dialog (with programm code) and change the layout to the detailview (with filesize,