index of item in array

morteza_karimi
morteza_karimi Member Posts: 13 ✭
Is there something similar to indexOf() method of javascript that returns the index of a given item in an array?
Tagged:

Comments

  • konstantin_shiriazdanov
    konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    you can look at source code of isIn() builtin function of standard library and modify it to return the index instead of boolean
  • MBartlett21
    MBartlett21 Member, OS Professional, Developers Posts: 2,064 ✭✭✭✭✭
    Here is an example function:

    function indexOf(value, arr is array) returns number
    {
        for(var i = 0; i < size(arr); i += 1)
            if(value == arr[i])
                return i;
        return -1;
    }

    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100