Announcement

Collapse
No announcement yet.

Passing Array names as parameters

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Passing Array names as parameters

    This is a question for some a good Java/EFS person.

    Here is the situation: I have a number of arrays to which I apply similar calculations and/or functions.

    Java 1.3 and higher allows passing an object name as "undefined" parameter to a Java Method and works fine.

    For example, the following constructs are valid and work fine.

    var Array1, Array2, Array3, Array4;

    Then, in main, I can do this:

    var SrcArray = Array3;
    var zzz = SrcArra[1]+SrcArray[2]+SrcArray[3];

    This works even the array components are function names [case when must provide the appropriate parameters as well].

    Furthermore, I can have a function that does the calculation and pass the SrcArray as parameter to that function, as shown below and still works fine.
    var zzz = function1(SrcArray);

    where function1 is defined outside main
    function1(Src) {return Src[1]+Src[2]+Src[3];}
    //**************************************
    Because all the above work, I assumed it will work for "nested functions" [passing the Src to an other function] but does not work anymore.

    Here is an example [ExtCond1 is a global var]:

    function1(Src) {return (ExtCon1) ? (Src[1]+Src[2]) : function2(Src);}

    function1 returns correct result only when ExtCond1 is true [and calculation is done in THIS function].
    When calling function2 it returns null.
    Important: function2 is a valid function which it is called directly from main and works fine.

    Can anyone explain why and how can this be overcome?
    I know it has to do with "parameters conversion" but did not find anywhere an explaination I could use.
    NOTE: Please remember you are talking to a novice programmer and not very bright person so, please, try to be simple and clear. Thank you.
    Mihai Buta

  • #2
    You can igoner this post.
    I found the solution.
    Mihai Buta

    Comment

    Working...
    X