Forum Discussion

4 Replies

  • Nevermind, in poking around the examples I found:

    Function tostr(any)

    Within generalUtils.brs

    This seems to do what I want.
  • I came up with the following:

    Function toStr(v As Dynamic, levels = 1 As Integer, debug = 5 As Integer) As String
    Log("toStr", 7, "vType:" + type(v) + " levels:" + Stri(levels), debug)
    out = ""
    if v = invalid return "invalid"
    if type(v)= "roString" return v
    if type(v) = "roFloat" OR type(v) = "Float" return Str(v)
    if type(v) = "roInt" OR type(v) = "Integer" return Stri(v)
    if type(v) = "roTimespan" return Stri(v.TotalMilliseconds()) + "ms"
    if type(v) = "roDateTime" return Stri(v.asSeconds())
    If type(v) = "roBoolean" Then
    if(v) Then return "True" Else return "False"
    End If
    If type(v) = "roArray" Then
    If levels > 0 Then
    i = 0
    out = chr(11) + "--- Start roArray ---" + chr(13) + chr(10)
    for each e in v
    out = out + chr(11) + "[" + Stri(i) + "]" + toStr(e, levels - 1) + chr(13) + chr(10)
    i = i + 1
    next
    out = out + chr(11) + "--- End roArray ---" + chr(13) + chr(10)
    return out
    Else
    return "{roArray}"
    EndIf
    End If
    If type(v) = "roAssociativeArray" Then
    out = chr(11) + "--- Start roAssociativeArray ---" + chr(13) + chr(10)
    for each e in v
    out = out + chr(11) + "[" + e + "]" + toStr(v[e], levels - 1) + chr(13) + chr(10)
    next
    out = out + chr(11) + "--- End roAssociativeArray ---" + chr(13) + chr(10)
    return out
    Else
    return "{roAssociativeArray}"
    End If
    return "{unknown}"
    End Function
    • chaklasiyanikun's avatar
      chaklasiyanikun
      Roku Guru

      I found similar issue. Is there available any good solution. I checked my variable datatype using Type(Myval). It's roArray and I'm trying to convert with string. I tried above solution add genaraliutilities and Add ToStr() in Code. and Before Adding Utilities Simply I write ToStr() But both way doesn't work.

      Is there any solution for this?