HMS

Home Media Server for Roku Players
git clone https://www.brianlane.com/git/HMS
Log | Files | Refs | README | LICENSE

commit aa1d499f95b41171a27a9813e15d3d67abc234bb
parent d5cd5d3d8ee6b8e33001c078bf28788173abab78
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Sat, 19 Nov 2022 11:00:43 -0800

Move debug functions to debugUtils.brs

Diffstat:
AHMS/source/debugUtils.brs | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MHMS/source/generalUtils.brs | 99-------------------------------------------------------------------------------
2 files changed, 105 insertions(+), 99 deletions(-)

diff --git a/HMS/source/debugUtils.brs b/HMS/source/debugUtils.brs @@ -0,0 +1,105 @@ +'******************************************************************** +'** Home Media Server Application - Debug functions +'** Copyright (c) 2022 Brian C. Lane All Rights Reserved. +'******************************************************************** + +'****************************************************** +'Dump the bytes of a string +'****************************************************** +Sub DumpString(str As String) + print "DUMP STRING" + print "---------------------------" + print str + print "---------------------------" + l = Len(str)-1 + i = 0 + for i = 0 to l + c = Mid(str, i) + val = Asc(c) + print itostr(val) + next + print "---------------------------" +End Sub + + +'****************************************************** +'Walk a list and print it +'****************************************************** +Sub PrintList(list as Object) + print "---- list ----" + PrintAnyList(0, list) + print "--------------" +End Sub + + +'****************************************************** +'Print an associativearray +'****************************************************** +Sub PrintAnyAA(depth As Integer, aa as Object) + for each e in aa + x = aa[e] + PrintAny(depth, e + ": ", aa[e]) + next +End Sub + + +'****************************************************** +'Print a list with indent depth +'****************************************************** +Sub PrintAnyList(depth As Integer, list as Object) + i = 0 + for each e in list + PrintAny(depth, "List(" + itostr(i) + ")= ", e) + i = i + 1 + next +End Sub + + +'****************************************************** +'Print anything +'****************************************************** +Sub PrintAny(depth As Integer, prefix As String, any As Dynamic) + if depth >= 10 + print "**** TOO DEEP " + itostr(5) + return + endif + prefix = string(depth*2," ") + prefix + depth = depth + 1 + str = AnyToString(any) + if str <> invalid + print prefix + str + return + endif + if type(any) = "roAssociativeArray" + print prefix + "(assocarr)..." + PrintAnyAA(depth, any) + return + endif + if islist(any) = true + print prefix + "(list of " + itostr(any.Count()) + ")..." + PrintAnyList(depth, any) + return + endif + + print prefix + "?" + type(any) + "?" +End Sub + + +'****************************************************** +'Print an object as a string for debugging. If it is +'very long print the first 500 chars. +'****************************************************** +Sub Dbg(pre As Dynamic, o=invalid As Dynamic) + p = AnyToString(pre) + if p = invalid p = "" + if o = invalid o = "" + s = AnyToString(o) + if s = invalid s = "???: " + type(o) + if Len(s) > 4000 + s = Left(s, 4000) + endif + print p + s +End Sub + + + diff --git a/HMS/source/generalUtils.brs b/HMS/source/generalUtils.brs @@ -294,86 +294,6 @@ End Function '****************************************************** -'Walk a list and print it -'****************************************************** -Sub PrintList(list as Object) - print "---- list ----" - PrintAnyList(0, list) - print "--------------" -End Sub - - -'****************************************************** -'Print an associativearray -'****************************************************** -Sub PrintAnyAA(depth As Integer, aa as Object) - for each e in aa - x = aa[e] - PrintAny(depth, e + ": ", aa[e]) - next -End Sub - - -'****************************************************** -'Print a list with indent depth -'****************************************************** -Sub PrintAnyList(depth As Integer, list as Object) - i = 0 - for each e in list - PrintAny(depth, "List(" + itostr(i) + ")= ", e) - i = i + 1 - next -End Sub - - -'****************************************************** -'Print anything -'****************************************************** -Sub PrintAny(depth As Integer, prefix As String, any As Dynamic) - if depth >= 10 - print "**** TOO DEEP " + itostr(5) - return - endif - prefix = string(depth*2," ") + prefix - depth = depth + 1 - str = AnyToString(any) - if str <> invalid - print prefix + str - return - endif - if type(any) = "roAssociativeArray" - print prefix + "(assocarr)..." - PrintAnyAA(depth, any) - return - endif - if islist(any) = true - print prefix + "(list of " + itostr(any.Count()) + ")..." - PrintAnyList(depth, any) - return - endif - - print prefix + "?" + type(any) + "?" -End Sub - - -'****************************************************** -'Print an object as a string for debugging. If it is -'very long print the first 500 chars. -'****************************************************** -Sub Dbg(pre As Dynamic, o=invalid As Dynamic) - p = AnyToString(pre) - if p = invalid p = "" - if o = invalid o = "" - s = AnyToString(o) - if s = invalid s = "???: " + type(o) - if Len(s) > 4000 - s = Left(s, 4000) - endif - print p + s -End Sub - - -'****************************************************** 'Try to convert anything to a string. Only works on simple items. ' 'Test with this script... @@ -428,25 +348,6 @@ End Function '****************************************************** -'Dump the bytes of a string -'****************************************************** -Sub DumpString(str As String) - print "DUMP STRING" - print "---------------------------" - print str - print "---------------------------" - l = Len(str)-1 - i = 0 - for i = 0 to l - c = Mid(str, i) - val = Asc(c) - print itostr(val) - next - print "---------------------------" -End Sub - - -'****************************************************** 'Validate parameter is the correct type '****************************************************** Function validateParam(param As Object, paramType As String,functionName As String, allowInvalid = false) As Boolean