btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2017
06:39 PM
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
Thanks
12 REPLIES 12
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2017
08:17 PM
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
Don't worry about it - they completely miscible - for comparison, arithmetics etc
btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2017
03:45 AM
Re: roInt & roInteger
Thanks. If there is no roInteger why does the debugger show roInteger?
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2017
08:52 AM
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
btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2017
12:28 PM
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.
TaylorAtWild
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2017
02:40 PM
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.
Above i am trying to cast the roInteger object to an integer using the % mutator.
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.
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2017
03:58 PM
Re: roInt & roInteger
Can you post the code that you think is giving you problems.

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2017
04:50 PM
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
--Mark
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2017
09:59 PM
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.
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.
NB_
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2017
09:54 AM
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:
- 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.
- 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
- 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