roArray.Append: invalid parameter type roFloat

I’m trying to update a MarkupList’s columnWidths field. document says it’s an array of floats.
When I try append a float it gives a big old error;

filterrow.columnWidths.Append(m.filterUnderline.width)

BRIGHTSCRIPT: ERROR: roArray.Append: invalid parameter type roFloat: …

Can anyone tell me what I’m doing wrong, should this work?

ifArray.Append() takes an array argument.

Try using ifArray.Push()

hmm maybe i need ‘push’ instead of ‘append’, and is there a way to make this array resizeable, recreate it on the fly?
roArray.Push: push ignored for non-resizable array

Update: Thanks Belltown! I’m getting closer…

hmm yeah, no luck.

  if filterrow.columnWidths.Count() < 1
      filterrow.columnWidths = CreateObject("roArray", 0, true)
      ? "created new filterrow.columnWidths array"
  end if
  filterrow.columnWidths.Push(w)

output:

created new filterrow.columnWidths array
BRIGHTSCRIPT: ERROR: roArray.Push: push ignored for non-resizable array: ...
created new filterrow.columnWidths array
BRIGHTSCRIPT: ERROR: roArray.Push: push ignored for non-resizable array: ...
created new filterrow.columnWidths array
BRIGHTSCRIPT: ERROR: roArray.Push: push ignored for non-resizable array: ...

guess the next option will be to define a bunch of “0” values then overwrite them…

No luck, trying to re-assign them but they keep the value of 0 even after I overwrite them. I wonder if there’s any way to do this (have a MarkupGrid with column widths based on the size of the contained text label)?

“joetesta” wrote:
No luck, trying to re-assign them but they keep the value of 0 even after I overwrite them. I wonder if there’s any way to do this (have a MarkupGrid with column widths based on the size of the contained text label)?

This is not an area I’m familiar with, but my impression is that conglomerate field values are not mutable in place.
Instead, you could have a local variable that you set, then assign it to the field all at once.

E.g.


   columnWidths = filterrow.columnWidths
   columnWidths.Push(m.filterUnderline.width)
   filterrow.columnWidths = columnWidths

thank you for the suggestion.
hmm seems the dilemma is that the child labels are not aware of each other and the parent MarkupGrid doesn’t have a way to loop over the “itemComponentName” items. It can loop over the ‘content’ field but that doesn’t actually contain the labels that are aware of their widths through boundingRect(). I could use a ‘global’ variable to build up this array but that doesn’t seem good. I may try it just to see if it works and if it does, maybe there’s another way or maybe that’s the only way…
thanks again

“joetesta” wrote:
hmm yeah, no luck.


      filterrow.columnWidths = CreateObject("roArray", 0, true)
...
  filterrow.columnWidths.Push(w)
...
BRIGHTSCRIPT: ERROR: roArray.Push: push ignored for non-resizable array: ...

Huh, there are multiple things going on here.
First, don’t ever be seen in public doing CreateObject("roArray", 0, true) instead of [ ] :face_with_tongue: (unless there is a reason, in which case i am very, very curious about it)
Second, it’s curious that filterRow.columnWidths returns a non-resizable array.
But the crux of the problem is to realize the filterrow.columnWidths.push() actually equals filterRow.getField("columnWidths").push() and that causes the array to be cloned. So if you succeed pushing something in it, that won’t be in the right array.

What firmware# is that by the way?

First, thanks - are those absolutely equal in every situation? Seems I ran into trouble in the past and started doing it the “long” way.
Second, yeah i have no idea why it’s not resiezeable.
But to me it seems the cruz of the problem is that the parent component has no visibility into the items defined by “itemComponentName” and so no way to loop over them, the individual component items themselves aren’t aware of their neighbors, so I can’t figure any way to have the parent MarkupGrid size its columns based on the labels they contain. That’s what I’m trying to solve.

Maybe I can do a getfield, alter field, setfield with the array for each element as the widths are defined. I’ll try some more today, thanks EnTerr!

“joetesta” wrote:
First, thanks - are those absolutely equal in every situation? Seems I ran into trouble in the past and started doing it the “long” way.
Yes, unless RokuKC corrects me :P.
In this case they are, when you need an empty, regular list. We can split hairs if you needed pre-sized array or one that cannot be resized - and that’s what i say i’d be interested to hear a real, meaningful case - but yours here isn’t.

Second, yeah i have no idea why it’s not resiezeable.
Right, that one is upon the RSG Maker (peace and blessings be upon him). It might be that fields return non-resizable typed arrays in meek attempt to keep developers from the mistake thinking they can mutate compound fields - which just silently does not work, you have to re-assign. And that’s the biggest, baddest mistake of RSG - that fields can be accessed by “.” but that causes a full copy to be made, regardless if rvalue or lvalue. As to the crux of the problem, no clue - have not looked at that component.

This works for updating the columnWidths field

  widths = m.itemlabel.getParent().getParent().columnWidths
  i = 0
  for each cw in widths
    if cw = 0
      widths[i] = m.filterUnderline.width
      exit for
    end if
    i++
  end for
  m.itemlabel.getParent().getParent().columnWidths = widths

However it’s not working correctly in that when assigning the content to the node, the sequence of the items is different than the order the code above gets executed, so the widths are being assigned to the wrong columns… hmm one step forward but now what…?

I got it! This feels like coding gymnastics;

  widths = m.itemlabel.getParent().getParent().columnWidths
  content = m.itemlabel.getParent().getParent().content

  i = 0
  while i < content.getChildCount()
    c = content.getChild(i)
    if c.title = m.itemlabel.text
      ? i; ". "; m.itemlabel.text; " width: "; m.filterUnderline.width
      widths[i] = m.filterUnderline.width
      i = content.getChildCount()
    end if
    i++
  end while
  m.itemlabel.getParent().getParent().columnWidths = widths

Appreciate all your help, and any feedback on what I have here. Thank you!!