Forum Discussion

funmay's avatar
funmay
Contributor
6 years ago

How to put specify multiple List separator in a function

Hi,

How can i pass multiple list separation  e.g comma[","] vertical line["|"] within a function to handle any parameter passed with any list separator.

 

See my eaxmple below,but i am not getting it

 

function TextString(array)

 



if(aqString["Contains"](array,",") == 0)
{
aqString["ListSeparator"] = ','
}

else if (aqString["Contains"](array,"|") == 0){
aqString["ListSeparator"] = '|'
}

/*Get the value of the first number*/
var FirstStringTobeginLooping = aqString["GetListItem"](array,0);

}

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    So... what's not working?  You don't clarify what errors or problems you running into.  It would be helpful to understand where the problem is.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      After I posted that, I tried it out... and yeah, it's not working... but that's because you have your logic incorrect.

      aqString.Contains returns the position of the first instance of the desired substring.  IF it doesn't find the string, it returns -1.  So... change your logic to the following

       

      function TextString(array)
      { 
      if(aqString["Contains"](array,",") != -1)
      {
      aqString["ListSeparator"] = ','
      }
      else if (aqString["Contains"](array,"|") != -1){
      aqString["ListSeparator"] = '|'
      }
      /*Get the value of the first number*/
      var FirstStringTobeginLooping = aqString["GetListItem"](array,0);
      }