Type Mismatch from roAssociativeArray

I am getting a Type Mismatch error from roAssociativeArray, any ideas what I’m doing wrong?

Backstory:
I added “play all” functionality based off some ideas from this thread: http://forums.roku.com/viewtopic.php?f=34&t=73760 (thanks rokujoel!) and it mostly works great except when the list comes to an end. When the last video finishes, I can no longer make any selections without restarting the channel.

As far as I can tell, what’s happening is from this:

  
    if type(episode) <> "roAssociativeArray" then
        print "invalid data passed to showVideoScreen"
        return -1
    endif

so I get the -1 which this function doesn’t know what to do with:


function PlayAllvideos(showlist,showindex)
   result=""
   while true
      ?"show index=";showindex
      result=ShowVideoScreen(showlist[showindex])
      print "result=";result
      if result="user cancelled playback" then 
         return result
      end if
      showindex=showindex+1
   end while
end function

So I’m guessing that it’s looking for the next video, which is invalid, and that ends up breaking the app. How I can make the PlayAllVideos function exit normally?

Looks like a couple of bugs in that code of Joel’s that you copied.

First, return -1 should be return “” since the function it’s contained in has a string as a return type.

Second, the PlayAllvideos function doesn’t terminate when it’s reached the end of showlist.
Change while true to while showindex < showlist.Count ()

That works! Thank you for your help.