B4J Question List1.Add error

Discussion in 'B4J Questions' started by Put Claude, May 25, 2015.

  1. Put Claude

    Put Claude Active Member Licensed User

    In B4J
    If Lgpgsv1.Size < 20 Then Lgpgsv1.Add("0") will give the error 'java.lang.UnsuportedOperationExeption'
    Lgpgsv1.Add("0") also will give the error 'java.lang.UnsuportedOperationExeption', so I think this is the devil,
    I cannot add anything to the list.

    Put Claude Belgium
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you post the code that creates the list?
     
  3. Put Claude

    Put Claude Active Member Licensed User

    Dim sf As JStringFunctions 'in Process_Globals, maybe the use of this lib causes the problem
    '......
    'extract the items of this string to a list
    Lgpgsv1.Initialize
    Lgpgsv1= sf.Split(newstr,",") 'splitt all items into a list
    If Lgpgsv1.Size < 20 Then Lgpgsv1.Add("0") 'uphere I got the error

    '--------------------------------------
    'I did a workaround like this:
    'extract the items of this string to a list
    Lgpgsv1.Initialize
    Lgpgsv1= sf.Split(newstr,",") 'splitt all items into a list
    If Lgpgsv1.Size < 20 Then newstr = newstr & "0"
    Lgpgsv1.Initialize 're-initialize
    Lgpgsv1= sf.Split(newstr,",") 'again splitt all items into a list
     
  4. Daestrum

    Daestrum Well-Known Member Licensed User

    Looks like if you use
    Code:
    myList = sf.split(??,",")
    you get the error
    If you change it to
    Code:
    myList.AddAll(sf.split(....))
    you can then add things to the end of the list.
    Think you have been caught by java reference to object in this case the sf list has a definite size, it wont let you extend it, and using
    mylist = sf.split(...) you set your list as a reference to the sf list.
     
  5. Put Claude

    Put Claude Active Member Licensed User

    Thanks a lot
    Problem solved

    Lgpgsv1.Initialize
    Lgpgsv1.AddAll(sf.split(newstr,","))
    If Lgpgsv1.Size < 20 Then Lgpgsv1.Add("0")

    'now I can add to the list
    Thanks again!!!

    Put Claude Belgium
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice