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: 
btpoole
Channel Surfer

roInt & roInteger

Really don't know what is going on with this. I have an array that I know contains certain values. I am using a control value that I know exist in the array to search for in the array. The control value types as roInteger. The array element value types as roInt. Like I said, I know the value exist in the particular field. Is it possible that I get a false on my return due to a roInt compared to roInteger? Can a roInt be converted to roInteger?
Thanks
0 Kudos
12 REPLIES 12
EnTerr
Roku Guru

Re: roInt & roInteger

There is no "roInteger" - there are "Integer" and "roInt", which is a boxed Integer.
Don't worry about it - they completely miscible - for comparison, arithmetics etc
0 Kudos
btpoole
Channel Surfer

Re: roInt & roInteger

Thanks. If there is no roInteger why does the debugger show roInteger?
0 Kudos
EnTerr
Roku Guru

Re: roInt & roInteger

"btpoole" wrote:
Thanks. If there is no roInteger why does the debugger show roInteger?

It does?! Where?
Show a snippet from the console pls
0 Kudos
btpoole
Channel Surfer

Re: roInt & roInteger

"EnTerr" wrote:
"btpoole" wrote:
Thanks. If there is no roInteger why does the debugger show roInteger?

It does?! Where?
Show a snippet from the console pls

----- Compiling dev 'BETA' ------

------ Running dev 'BETA' runuserinterface ------
RUNUSERINTERFACE
IN USERDATA
IN GetAuthData
USER DATA NOT EMPTY
IN HOME
[DetailsScreen] init
IN ENTRY INT
ENTER LOAD DATA. . .
in roundTime  1486049010
IN P TASK
TASK RAN
IN SETMODE   
DEVICE MODE. . .720p
IN TASK
WEATHER CREATED>>>>>>>>>>  
CHANNEL LIST CONTENT CREATE>>>>>>>>>>>>>>
IN UPDATECONTENT STATUSinvalid
NOW TIME   1486049013
buildtimeslotArray Complete>>  58
buildContent Array Complete>>  1698
NUMBER OF CHANNELS  33
in setGridContent
roInteger
roInteger
roInteger
roInteger
roInteger
roInteger
roInteger
This is from debugger window, didn't copy whole thing. The rointeger is the type of the current time as seconds rounded to nearest half hour. I actually found why my code was failing in the initial question. Thought maybe it had something to do with the types.
0 Kudos
TaylorAtWild
Visitor

Re: roInt & roInteger

I too have the roInteger data type on an up to date system with software version 7.6.0 build 4125. 

I cannot cast it to a native Integer, which is causing me problems in development. Overall the language has been terrible to develop for and needs major improvements in the core language before I would use it willingly. 

Invalid
 1272
<Component: roArray> =
[
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
    <Component: roAssociativeArray>
]
roInteger
Invalid
 1922
roInteger
Invalid
 1913
roInteger
Invalid
 1909
roInteger
Invalid
 1905
roInteger
Invalid
 1901
roInteger
Invalid
 1896
roInteger
Invalid
 1922
roInteger
Invalid
 1913
roInteger
Invalid
 1909
roInteger
Invalid
 1905
roInteger
Invalid
 1901
roInteger
Invalid
 1896
<Component: roArray> =
[
    false
]

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.


Current Function:
008:       decoder = JSONDecoder()
009:       json = decoder.decodeJSON(m.shows)
010:       if json <> invalid
011:          m.names = CreateObject("roArray", 10, true)
012:          m.nids = CreateObject("roArray", 10, true)
013:          m.Categories = CreateObject("roAssociativeArray")
014:          for each cat in json.categories
015:                 if type(cat.shows) = "roArray" and cat.shows.Count() <> 0
016:*                    m.Categories[cat.nid] = CreateObject("roAssociativeArray")
017:                     m.names.Push(cat.title)
018:                     m.nids.Push(cat.nid)
019:                     i = 0
020:                     print cat.shows
Type Mismatch. (runtime error &h18) in pkg:/source/loadShows.brs(16)
016:                    m.Categories[cat.nid] = CreateObject("roAssociativeArray")



Above i am trying to cast the roInteger object to an integer using the % mutator.
0 Kudos
belltown
Roku Guru

Re: roInt & roInteger

Can you post the code that you think is giving you problems.
0 Kudos
RokuMarkn
Visitor

Re: roInt & roInteger

roInteger is just a typo for roInt in the debugger.  There should be no problem converting an object of that type to an integer.  I agree you should post your code; your problem is something different than you think it is.

--Mark
0 Kudos
renojim
Community Streaming Expert

Re: roInt & roInteger

I'm going to guess that cat.nid is a string (or at least not an integer).  Try printing out its type:
print type(cat.nid)
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
NB_
Roku Guru

Re: roInt & roInteger

"TaylorAtWild" wrote:

011:          m.names = CreateObject("roArray", 10, true)
012:          m.nids = CreateObject("roArray", 10, true)
013:          m.Categories = CreateObject("roAssociativeArray")
014:          for each cat in json.categories
015:                 if type(cat.shows) = "roArray" and cat.shows.Count() <> 0
016:*                    m.Categories[cat.nid] = CreateObject("roAssociativeArray")
017:                     m.names.Push(cat.title)
...

Ok, so a few things:

  1. Come on people, stop doing `CreateObject("roArray", 10, true)` and `CreateObject("roAssociativeArray")` when can say `[ ]` or `{ }`. Not only is this shorter and more readable - but it is actually faster.

  2. I am guessing the above you get an error because you are trying to index roAA with an integer. Unlike other scripting languages however, B/S takes only strings as dictionary keys - so do `m.Categories[cat.nidtoStr()] = {}` above

  3. if you want to check for a type, better to check for capability than type() equaling particular string literal, i.e. `if GetInterface(myVar, "ifInt") <> invalid then ...` - that handles both boxed and unboxed types
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.