Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
joetesta
Roku Guru

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?
aspiring
0 Kudos
11 REPLIES 11
belltown
Roku Guru

Re: roArray.Append: invalid parameter type roFloat

ifArray.Append() takes an array argument.

Try using ifArray.Push()
joetesta
Roku Guru

Re: roArray.Append: invalid parameter type roFloat

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...
aspiring
0 Kudos
joetesta
Roku Guru

Re: roArray.Append: invalid parameter type roFloat

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...
aspiring
0 Kudos
joetesta
Roku Guru

Re: roArray.Append: invalid parameter type roFloat

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)?
aspiring
0 Kudos
RokuKC
Roku Employee
Roku Employee

Re: roArray.Append: invalid parameter type roFloat

"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
0 Kudos
joetesta
Roku Guru

Re: roArray.Append: invalid parameter type roFloat

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
aspiring
0 Kudos
EnTerr
Roku Guru

Re: roArray.Append: invalid parameter type roFloat

"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 `[ ]` 😛 (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?
0 Kudos
joetesta
Roku Guru

Re: roArray.Append: invalid parameter type roFloat

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!
aspiring
0 Kudos
EnTerr
Roku Guru

Re: roArray.Append: invalid parameter type roFloat

"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.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.