EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014
10:28 AM
Re: Help Parse XML
"malort" wrote:
AA does not have a .count()
Oh <censor> me!
Apparently i live in the future, because on the box where i wrote and tested this
BrightScript Debugger> ? {}.count()Let me think what i can do.
0
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014
11:29 AM
Re: Help Parse XML
"btpoole" wrote:My apologies - turned out my code relied on a feature that is not in current firmware.
I kinda that it was all good since it got thru the attributes but it kicks on res.count < 1 line. It breaks to the console as you thought.
To fix it, replace res.count() < 1 on the erroring line with res.isEmpty(). I fixed my original post, you can copy&paste from that.
Try the example and see if any hiccups?
Thanks @malort for spotting the issue - you insisting with example that "AA does not have a .count()" made me realize the err in my ways. And while fixing it i saw second issue too - that present day formatJSON() does not work on arrays.
When I ?type(xml) I get nothing back.Here you probably ran into that known bug of the firmware, where every other time on error it does not give you the console but instead completely exits the channel. Even so often (1 out of 2) it catches me off-guard. Try hitting Enter first just to see if console is responsive or not ("hanging").
btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014
11:45 AM
Re: Help Parse XML
EnTerr
No need for apologies. As I was looking over the code, I was trying to figure out the <2 followed by <1 on next line. Thought maybe using = 0 instead of < 1, but isEmpty() is better. Thanks again. I will try this and see how it runs.
Thanks again
No need for apologies. As I was looking over the code, I was trying to figure out the <2 followed by <1 on next line. Thought maybe using = 0 instead of < 1, but isEmpty() is better. Thanks again. I will try this and see how it runs.
Thanks again
btpoole
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014
06:05 PM
Re: Help Parse XML
Since there is not a .count(), is there anyway to count the number of shows (name) that may be present in a particular amount of time say 1 hour?
Also, on the dump function, I have pushed the day and time values to array:
day.push(day_sched[0].attr)
time.push(hour_sched[0].attr)
is there a way to push the show(called out as name in file) and network to an array? I have tried:
showname.push(hour_sched.name)
?showname
networkname.push(hour_sched.network)
?networkname
Kinda of odd, it gives me a Dot operator error on these lines yet it prints just as I thought it would:
the show name
the network
Also, on the dump function, I have pushed the day and time values to array:
day.push(day_sched[0].attr)
time.push(hour_sched[0].attr)
is there a way to push the show(called out as name in file) and network to an array? I have tried:
showname.push(hour_sched
?showname
networkname.push(hour_sched
?networkname
Kinda of odd, it gives me a Dot operator error on these lines yet it prints just as I thought it would:
the show name
the network
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2014
01:10 AM
Re: Help Parse XML
"btpoole" wrote:
Since there is not a .count(), is there anyway to count the number of shows (name) that may be present in a particular amount of time say 1 hour
You might have been confused by our exchange above. There is no .count() for dictionaries ("roAssociativeArray", the ones in curly brackets, e.g. {key: "value"} ) but .count() for arrays (roArray, e.g. [1, "two"] ) is working fine, no worries.
Accordingly, looking at previous example
function dump(schedule):
for i = 1 to schedule.count()-1:
day_sched = schedule[i]
day = day_sched[0].attr
for j = 1 to day_sched.count()-1:
hour_sched = day_sched[j]
time = hour_sched[0].attr
for k = 1 to hour_sched.count()-1:
? day, time, hour_sched[k].name
end for
end for
end for
end function
- schedule.count()-1 will give you how many days are included in the schedule
- when looking at a specific day (i.e. inside for i loop), day_sched.count()-1 gives the number of time slots
- when focusing on a specific time slot in particular day (i.e. inside for j ), hour_sched.count()-1 gives the number of shows there
I don't understand the rest of your question/comment. Maybe try being more specific, copy&paste (small) piece of code that gives you trouble, also copy&paste the exact error, etc
- « Previous
- Next »