Java Array Creation error

Sort:
You are not authorized to post a reply.
Author
Messages
brihyn
Veteran Member
Posts: 95
Veteran Member
    I've got some java scripting to assist with pulling up images, and for one section, I need to strip out leading 0's that are on the screen to find the correct image. I found some great code on the web, but Lawson is screaming at the commented-out line where I declare the array. Is there a way to do this that Design Studio approves of?
    Here's the code I have:
    function removeLeadingZeros(str)
    {
     if (str == null)
     {
      return null;
     }
    // char[] chars = str.toCharArray();
     index = 0;
     for (; index < str.length();index++)
     {
      if (chars[index] != '0')
      {
       break;
      }
     }
     return (index == 0) ? str :str.substring(index);
    }
    Sam Simpson
    Veteran Member
    Posts: 239
    Veteran Member
      Is toCharArray() a valid javascript? I thought this was usually used in VB where you load string into a unicode array.
      brihyn
      Veteran Member
      Posts: 95
      Veteran Member
        you might be right. Found another possible solution, but Lawson isn't liking it either. The search goes on.
        Sam Simpson
        Veteran Member
        Posts: 239
        Veteran Member
          I guess to answer my question, toCharArray() is a valid statement used by JVM. It is one way of converting your str into an array called chars (without declaring an array). Going back to your dilemna, I don't know if the function is a valid function in design studio. Maybe there is a need to update your JVM.
          John Henley
          Senior Member
          Posts: 3348
          Senior Member
            Also C#.
            try:
            var chars = str.split()
            Thanks for using the LawsonGuru.com forums!
            John
            John Henley
            Senior Member
            Posts: 3348
            Senior Member
              Or, better:
              str.replace(/^[0]+/g,"")
              Thanks for using the LawsonGuru.com forums!
              John
              You are not authorized to post a reply.