MIPS中的数组元素

时间:2016-09-23 03:55:17

标签: arrays mips elements

如何从阵列中取出元素? 即。

/* Array for active buttons
0: Company Name 1: Country 2: Industry 3: Search 4: Company Name - Seller Name 5: Company Name - Buyer Name 6: Country - USA 7: Country - China 8: Country - Israel 
9: Country - Russia 10: Country - India 11: Country - Japan 12: Industry - Tech 13: Industry - Consumer 14: Industry - Pharma 15: Industry - Financial 16: Industry - Biotech 17: Industry - Industrial 
18: Date 19: Valuation 20: Industry - Business
*/
$scope.activeButtonArray = new Array(21);
for (var i = 0; i < $scope.activeButtonArray.length; i++) { $scope.activeButtonArray[i] = false; }
//pos = position in array
$scope.updateActiveButtons = function(pos) {
    console.log($scope.activeButtonArray[20]);
    if(pos != 0 || pos != 1 || pos != 2 || pos != 3 || pos != 4 || pos != 5) {
        $scope.activeButtonArray[pos] = !$scope.activeButtonArray[pos];
    } else if(pos == 3 && !$scope.activeButtonArray[pos]) {
        $scope.activeButtonArray[pos] = true;
    } else if(pos == 3 && $scope.activeButtonArray[pos]) {
        $scope.activeButtonArray[pos] = false;
    }
    if(pos == 18 || pos == 19) {
        $scope.activeButtonArray[0] = false;
        if($scope.activeButtonArray[6] == false && $scope.activeButtonArray[7] == false && $scope.activeButtonArray[8] == false && $scope.activeButtonArray[9] == false && $scope.activeButtonArray[10] == false && $scope.activeButtonArray[11] == false) {
            $scope.activeButtonArray[1] = false;
        }
        if($scope.activeButtonArray[12] == false && $scope.activeButtonArray[13] == false && $scope.activeButtonArray[14] == false && $scope.activeButtonArray[15] == false && $scope.activeButtonArray[16] == false && $scope.activeButtonArray[17] == false && $scope.activeButtonArray[20] == false) {
            $scope.activeButtonArray[2] = false;
        }
    }
    if(pos == 0) {
        $scope.activeButtonArray[0] = true;
        if($scope.activeButtonArray[4] || $scope.activeButtonArray[5]) {
            $scope.activeButtonArray[0] = true;
        }
        if($scope.activeButtonArray[6] == false && $scope.activeButtonArray[7] == false && $scope.activeButtonArray[8] == false && $scope.activeButtonArray[9] == false && $scope.activeButtonArray[10] == false && $scope.activeButtonArray[11] == false) {
            $scope.activeButtonArray[1] = false;
        }
        if($scope.activeButtonArray[12] == false && $scope.activeButtonArray[13] == false && $scope.activeButtonArray[14] == false && $scope.activeButtonArray[15] == false && $scope.activeButtonArray[16] == false && $scope.activeButtonArray[17] == false  && $scope.activeButtonArray[20] == false) {
            $scope.activeButtonArray[2] = false;
        }
        if($scope.search.text == undefined || $scope.search.text == '') {
            $scope.activeButtonArray[3] = false;
        }
    }
    if(pos == 1) {
        if($scope.activeButtonArray[4] == false && $scope.activeButtonArray[5] == false) {
            $scope.activeButtonArray[0] = false;
        }
        if($scope.activeButtonArray[6] == true || $scope.activeButtonArray[7] == true || $scope.activeButtonArray[8] == true || $scope.activeButtonArray[9] == true || $scope.activeButtonArray[10] == true || $scope.activeButtonArray[11] == true) {
            $scope.activeButtonArray[1] = true;
        }
        if($scope.activeButtonArray[12] == false && $scope.activeButtonArray[13] == false && $scope.activeButtonArray[14] == false && $scope.activeButtonArray[15] == false && $scope.activeButtonArray[16] == false && $scope.activeButtonArray[17] == false  && $scope.activeButtonArray[20] == false) {
            $scope.activeButtonArray[2] = false;
        }
        if($scope.search.text == undefined || $scope.search.text == '') {
            $scope.activeButtonArray[3] = false;
        }
    }
    if(pos == 2) {
        if($scope.activeButtonArray[4] == false && $scope.activeButtonArray[5] == false) {
            $scope.activeButtonArray[0] = false;
        }
        if($scope.activeButtonArray[6] == false && $scope.activeButtonArray[7] == false && $scope.activeButtonArray[8] == false && $scope.activeButtonArray[9] == false && $scope.activeButtonArray[10] == false && $scope.activeButtonArray[11] == false) {
            $scope.activeButtonArray[1] = false;
        }
        if($scope.activeButtonArray[12] == true || $scope.activeButtonArray[13] == true || $scope.activeButtonArray[14] == true || $scope.activeButtonArray[15] == true || $scope.activeButtonArray[16] == true || $scope.activeButtonArray[17] == true  || $scope.activeButtonArray[20] == true) {
            $scope.activeButtonArray[2] = true;
        }
        if($scope.search.text == undefined || $scope.search.text == '') {
            $scope.activeButtonArray[3] = false;
        }
    }
    if(pos == 3) {
        if($scope.activeButtonArray[4] == false && $scope.activeButtonArray[5] == false) {
            $scope.activeButtonArray[0] = false;
        }
        if($scope.activeButtonArray[6] == false && $scope.activeButtonArray[7] == false && $scope.activeButtonArray[8] == false && $scope.activeButtonArray[9] == false && $scope.activeButtonArray[10] == false && $scope.activeButtonArray[11] == false) {
            $scope.activeButtonArray[1] = false;
        }
        if($scope.activeButtonArray[12] == false && $scope.activeButtonArray[13] == false && $scope.activeButtonArray[14] == false && $scope.activeButtonArray[15] == false && $scope.activeButtonArray[16] == false && $scope.activeButtonArray[17] == false  && $scope.activeButtonArray[20] == false) {
            $scope.activeButtonArray[2] = false;
        }
    }
    if(pos == 4) {
        $scope.activeButtonArray[4] = true;
        $scope.activeButtonArray[5] = false;
    }
    if(pos == 5) {
        $scope.activeButtonArray[4] = false;
        $scope.activeButtonArray[5] = true;
    }
}

如何编写我想使用a0中的元素的代码?

0 个答案:

没有答案